initial commit on day 9

This commit is contained in:
Juan José Gutiérrez de Quevedo Pérez 2020-12-09 09:26:04 +01:00
commit f896e7c753
31 changed files with 8328 additions and 0 deletions

12
3/1.py Normal file
View file

@ -0,0 +1,12 @@
count = 0
width = None
x = 0
with open("input") as f:
for passline in f:
passline = passline.strip()
width = len(passline)
if passline[x] == "#":
count += 1
x = (x + 3) % width
print(count)

23
3/2.py Normal file
View file

@ -0,0 +1,23 @@
def calculate_trees(dx, dy):
count = 0
width = None
x = 0
y = 0
with open("input") as f:
for passline in f:
if not bool(y % dy):
passline = passline.strip()
width = len(passline)
if passline[x] == "#":
count += 1
x = (x + dx) % width
y = y + 1
return(count)
i1 = calculate_trees(1, 1)
i2 = calculate_trees(3, 1)
i3 = calculate_trees(5, 1)
i4 = calculate_trees(7, 1)
i5 = calculate_trees(1, 2)
print(i1*i2*i3*i4*i5)

323
3/input Normal file
View file

@ -0,0 +1,323 @@
......#...........#...#........
.#.....#...##.......#.....##...
......#.#....#.................
..............#.#.......#......
.....#.#...##...#.#..#..#..#..#
.......##...#..#...........#...
.......#.##.#...#.#.........#..
..#...##............##......#.#
.......#.......##......##.##.#.
...#...#........#....#........#
#............###.#......#.....#
..#........#....#..#..........#
..#..##....#......#..#......#..
........#......#......#..#..#..
..#...#....#..##.......#.#.....
.....#.#......#..#....#.##.#..#
......###.....#..#..........#..
.#................#.#..........
.........#..#...#......##......
##...#....#...#.#...#.##..#....
...##...#....#.........###.....
.#.#....#.........##...........
....#.#..#..#...........#......
..#..#.#....#....#...#.........
..........##.....#.##..........
..#.#....#..##......#.#.....##.
..#...#.##......#..........#...
......#....#..#.....#.....#...#
#.#...##.#.##.........#..#.....
...#.#.#.........#.....#.#.#...
..#.........#...............#..
#..##.....#.........#....#.....
...#....##..##...........##..#.
......##.................#.#...
##.......#....#.#.#.....#......
....#.#...#.................##.
#...#.........##.....#.........
#....#.###..#.....##.#....#....
#..#....#...#....#.#.#.........
.......#...........#....#.....#
#...#.............#........#...
.......#.....#...#..#.........#
.##.....##.....##.......#......
....##...##.......#..#.#.....#.
.##.........#......#........##.
.......#...#...###.#..#........
..#..###......##..##...........
.#..#......##..#.#.........#...
...#.......#........#...#.#....
...#....#..#....#.....##.......
............#......#..........#
.#.......#......#.#....#..#.#..
##.........#.#.#..........#....
....##.....#...................
.......#..#........#...........
....##.#..#......###.......#...
....#....#...#.#......#...#...#
.......#.....##..#....#...#....
#...#........#.........#..##...
...........##.........#.#...#..
....................#....#.##..
.#..#..#.........#....#..#..##.
......................#........
..###....#.......#.....###.##..
......#......#.......#.....#..#
.....#...#.##...#......#....#..
.....#.....##.............#....
....#......##..#....#.......#..
.##....#..##......###....#..#..
...###.#.............##...#.#..
.....#.....#.....#...#..#.#....
..#.#.....###......#.......#...
..........#.##......#.........#
..##..#.......................#
........#......#............#..
#..#..#..#.#......#..#....#....
...##......#.............#....#
...........#..#..##.......#....
.....#.........#.#..#..........
##...#.......#.#....#..#..#....
#.#.#...........#.##.#.#..###..
#..#...........#.........##....
............#.#..............#.
.#....#....##.#...........#..#.
....#...#..#...#....#....#.....
....#....#...#..#......#.......
.#.#.........#.......#.##......
.#..##...#........#...........#
##...#..#...#...#.....#...#....
....###.#..#.......##.#..#...#.
...##.......####...##.#........
#....#....#.#............#..#..
#.#.#...#...................##.
##......#...........#..........
#..#..#....#.#...#......#......
.##...#.....#...#........#.....
..#............#..............#
###........#..#....#...#......#
###..##......#.##...........#..
........#......#..#.....#......
...#..........#..#...........#.
....#..#..#....#........#....#.
.#.................#####..##..#
.....#...##..#..........#.##...
..#..............#...####......
.....#.##..................#.#.
...#.#..#..#........#..........
...........#....#.#..#.........
.....##.......#......#..#.#.#..
...#.............##...#........
...............#.......##.##.##
.....#........#........#.#..#..
...#..#.........#...##...###...
...#.#.............###.#.....#.
.#..........#......###.#.#.....
....##..##.............###.....
..#..#.#...##...#.......##.....
..........###........#.....#.#.
#.#....#..#..#......#...#...#..
.........#......##.......#.#..#
...#.....#.........##..#..#....
.....##.#..##.##..##...........
...#.#.##....#..#..#......#..#.
#....#....#.............#...##.
#......#..#.####.#.##.#....##..
##.#.#....##..................#
.....##......#.......##.......#
..#......#.#..#...##......##...
..#....##....#.........#..##...
.###.....#....##...........#...
.........#......#.#........#...
...#...#..#.#....######.#..#...
###......#.#.#.........##.#....
.....#...#.........#...#.......
....#.............#.#.........#
..##...#...#.......#......#....
.....#...#.#...#...#..#........
.#......#......................
...###..#..#....#...##.#.......
.#.#.....##...#...#.....#...##.
.....###..###....##............
.....##....#..#.....#.##.......
#........#.........#...#..#....
...#.#.........#..#.......#.#..
....#.#....##.....#..........#.
.#..#....#..#.#..#..#.........#
#...#....#..............#......
.........#.....#.##...##...###.
.....#....##............#..#...
.....#.#...........#..#....#...
.#..........#...#......#.....#.
.#...........#.....#..#........
..............#......##...#..#.
...#.........#..#....#..##...##
..##...#..................#....
#.....#.................#......
...#......#..#..........#.#....
......#..#.....#.....##...#..#.
......#........#..........#....
...##.##....#..##.#..........#.
..........#..#.#.##............
..##........................#..
.....#.#.#......#....#....##...
#....#.........#........#......
.##.......#...#...#........##..
....##......#....#.#..........#
..#.......#..............#.....
.....#......#.#...#..#.#.#....#
.....#..#........#.##.##.......
##........#..........#.........
.....#..##....#.#......###..##.
#.#...##.........#.#.....#..#..
#....#.#...#........#.....#..#.
........................#......
....###......#............#...#
...#..##......#..##.........#..
.............#...#......#..#..#
....#......#....#...........#..
..#.#.####.#.....##........#..#
#..#...#..#..#.......#.#..#....
..#..#..#....#.#.........##..#.
.......#......#.#............#.
...#.............#.#.....#.....
...#.#.........##...#.#.......#
........#...#...........##...#.
..........#....#......#....##..
..........#...........#........
...#..#...#..........#......#..
......#......#....#.....#..#.#.
........##.................#..#
.#........#.#...........#......
#...#........#.#.#.....#.#.#...
.........#........#..#..#....#.
##........#..........#....#..#.
.#.##...........#..#.#..##....#
.......#.#....#..#......#......
..#.....#........##..#......###
..#...#..................#....#
......#...#..#.##.......#......
........#...#.#................
.........#............#........
..#.....##....#.#..##..........
#.....#..........#....#........
....#.#...#...##....#.....##...
..#.#.......#.............#...#
...##..............#......#....
#......#...#................##.
.#.#...#.#..#..................
...##.......#...........#.#.#..
#......#.#.#........#.##...####
.......#..#.#.........#.#.##..#
..............#....#.........#.
...........#.#..#....##......#.
#.............#...##..#.......#
.........#............#...#.##.
.......#.........#.#.....#..#..
........................#.#.##.
#......#.#......#.........#....
...#.......#.......#.....#.....
#..#....#................#...#.
........#.#..##......#.........
#..#...##....##....##.........#
.......#...#...###.............
#.#..#........#.#.#............
#.....#........##.........#.#..
.#..........#....#.#....###....
.#.....#...#.#........#..#.##..
...#.##......#..#.............#
..##..#.#...................#..
.....#....#...#.#...#...#......
.....#..#.#....#.#.............
#.#....#.#.##..###..........#..
........#.#.............#..#...
.........#.......#.............
.##.#............##...#........
......#................#.......
...............#..#...........#
...#.......#...#.##.....#....#.
##..##..#..........#...........
.##.#.......#...#..#...#...#...
....#..#...........#....#.##...
.#........#........#....#......
.......#...#.##.#..#.#..#......
.#..#......#....#...##....#.#..
......#...##.#.....##.###.....#
.#....#..#......#...#.#.....#..
#............#....##...##.##...
#...#.#....#...#.......##...##.
#...........#.##..#....#.....#.
...#..#...#.........#.......#..
.#....#.....#............#.#..#
.#.....#.#...#.#....##......###
..#..#.#.#...#..#.............#
...#...#..#....#........#...##.
.......#.....#...##...........#
#.##.................#...##...#
..............##........#.....#
............#...#..#.......#.#.
#.#.....#.........#...#......#.
#.###..#......#..#..#...#.....#
.....#.......#.................
........#..#......#.#...#......
#.......#..#........#...#..#...
..#...#.......##.............#.
#.......#.......##...#.........
.........#....#.#..##.....#...#
..#.....#.#.......#....#.......
...#.......#.....#..##.#..#....
....#.......#.#.#..............
.#..#......#........#.#..##..##
....#...#.##.#...#....##...#...
#..##..#.....#.......#.........
....#..#..#.#............#.....
#.......##...##..##............
...............................
....#.......#.##...#.....#.#...
...#........#....#.#..#..#.....
##.......#.....##.#.#....#....#
#.............#...........#.##.
#...........#.#..........#.....
#..#....#....#.#.........#.#...
......#.#.#..#.#.#.............
...#.....#........##....#......
..#...#...#.#.......#......#...
.##........#...#..#..........#.
..#...........#..##.....##.....
............#..#.#...#.....#...
..........#....##.......#......
....#....#.................#..#
....#...............#.........#
..#.#...#......#..........##...
.....#...........#.........#..#
.......#.....##.....#.#........
.#.#..........#....#...........
.#..##....#........#....#......
....#.#..#.......#..#.........#
..#....#.....#......#..#.......
......#........#.......#...#.#.
.......#.......#....#.....##...
....##........#..#...#.#..#...#
.#......#...........##....#....
##....##......#.......#.......#
.##....#.##......#.......##..#.
...#..#.#.#.......#..#.###.....
..........##....#..#.##........
...#........###.#..#........#..
.....#....#..##....#.....#....#
#..........#..........#.#....#.
..#....#.....#..............#..
#..................#......#.##.
.#...#.#.....#.........##......
...#...........#.....#......#..
......#.....#.#..##......##....
...#....###..#.....#..#..##..##
......#.......##..#..#.........
#..#.#....#.#..#..........##.#.
..#..#..##..#.#.#.#.....#......
..#.#...#..#.....###.#.........
##.#.#......#........#.####....
.............#..#..#....#......
...##..........#.......#.#....#
..#.....................#......
..#..#...##...#.##........#....