Complete day 3
This commit is contained in:
parent
12e300446b
commit
9cc0c3f8d6
|
@ -0,0 +1,323 @@
|
|||
.##.............##......#.....#
|
||||
.#.#................#..........
|
||||
...#..#.##..#.#......#.#.#.#..#
|
||||
..#......#........#..#..#.#.#..
|
||||
.......#....#..#..#.......#....
|
||||
..#..#..##.#...#........#.###..
|
||||
..#...#..#.....#.##....#.......
|
||||
....#..###.#......#.##..#...##.
|
||||
..#..........#.##.#...#........
|
||||
#...#............##....#..##...
|
||||
.......##....#.....##..#.#..#.#
|
||||
..#..#..#...#....#....#....#...
|
||||
.#...#.##........#####........#
|
||||
..#..#......#.....##...#.......
|
||||
....#......##....#.#....#.#..##
|
||||
#.#.##....##..#.........#.###..
|
||||
##..###..#..#.......###.......#
|
||||
...#.#......#.........#....#...
|
||||
.....#..........#.....##..#.#..
|
||||
....##......#.#..#....#.#......
|
||||
..#.....#..##.......##......#..
|
||||
.........##.##.#..##...........
|
||||
....#...#.....#....#.#.###....#
|
||||
.##.#..#...##..#.......#......#
|
||||
##..#..#..####..#.#..#...#.....
|
||||
..###..#..#..#.###..#....#.##..
|
||||
......#...###.#.#.....#........
|
||||
.....#...#.#...#.......#.....#.
|
||||
#........#..##...........#..#..
|
||||
.#.##.##...#.....#.#....#..#...
|
||||
..##.##....#.....#....#....##..
|
||||
#.........##...##..#.....#..#..
|
||||
........#.####....#...##.....#.
|
||||
.#.#...#..#..#.#......##.....#.
|
||||
..#..........##..#.#.#....#...#
|
||||
#.......#...#...#.....#.##.#...
|
||||
..#.....#..#.....####.#..#.#.##
|
||||
...#.#..#...#.....#...#.#.#.#.#
|
||||
.#..##....##.....#..#....###...
|
||||
....#......##.#.#.....#......#.
|
||||
..#.#...#......#.....##.......#
|
||||
..#...###...#..#.#...#..#.....#
|
||||
#..............#.....#....##..#
|
||||
.#...#.......#.............#...
|
||||
..###....#.##........#.#.......
|
||||
#.##.......#..#............###.
|
||||
#...#..##.#.#............######
|
||||
..##..#....#.#.###...#..##.##..
|
||||
.#...#.###.#....#...#....#...#.
|
||||
#...#.......#...........#...##.
|
||||
##.#......#####.............#..
|
||||
....#..#......##..#..........#.
|
||||
#.....#.....#.#.......#...#...#
|
||||
....#...#.#..##........#.#..##.
|
||||
..##.....##............#.#.###.
|
||||
#.........#........#..###......
|
||||
............#..................
|
||||
.#.###...####...#.#..#......#..
|
||||
...##.###.#....##.#..####..#.##
|
||||
..#####.#.##...#.#...##.##....#
|
||||
........##...#...#....##.....##
|
||||
#...........###...#.#...##.#...
|
||||
##......#...#.......###........
|
||||
..#..#.##.#..###....#..#.###.#.
|
||||
...#.#.#...#....#.##..#...#....
|
||||
........#.##...##.#.....##...##
|
||||
.#..........##..#..#..#.#...#..
|
||||
#.#...#.##.#....#.##..#........
|
||||
.#.#.#....##..##.####.....###..
|
||||
..#....##....#..#..#..##.......
|
||||
..##...#.......#...##.#....#...
|
||||
...####.#.#...........#.#...#..
|
||||
....####.....#.#.....#....##.##
|
||||
..#.....#.#.............##....#
|
||||
#.#....#####.##..####.#...#.#..
|
||||
#.#....#.##.#.#.##..#.#...#....
|
||||
......#.......#.......#.....#..
|
||||
..#.....#....###.###..#..#..#..
|
||||
#..#....##.###...##.....#......
|
||||
..#..#...#..#.##..........#....
|
||||
...#.#.#......#....#.##..#..##.
|
||||
....##.#....#..#...##....###...
|
||||
##.#.###.....#..#.#.#..#.....##
|
||||
##..#.#........#...#..#.#......
|
||||
....#.#.......##.#...........#.
|
||||
.......##...#...#...#.....#....
|
||||
.....#....#..#..###.#...#......
|
||||
............#.#..#......#.#....
|
||||
...##..#.##....##..##.#......#.
|
||||
#.#.#......#.#.....#.#.#..#.#.#
|
||||
...###..........#..#..#.##.....
|
||||
......#......#......###..##....
|
||||
#...##...#....#....#..#...#.#..
|
||||
.......#..#......##.......#....
|
||||
...#..#..#.....#.....#......##.
|
||||
..#....###..........##..#...#..
|
||||
..........#..#.#...#......#..#.
|
||||
#...#....#.##.........#.#.#...#
|
||||
.#.#.#...#.#...#.#..#..#....#.#
|
||||
#.##....#..#.........#.##.##..#
|
||||
..#.#..##.#....#.###.#...#....#
|
||||
.#.......#...#.#.........#....#
|
||||
.......#...#..........#.#..#...
|
||||
...#.....##..#....#...###...#.#
|
||||
#....##.##..........#.......#..
|
||||
.##..##......#...#....#.##....#
|
||||
....#.....##...##.#..#.........
|
||||
...#.#..##.#.#..#.......#....#.
|
||||
.#...#.#.#.#..#..#.##.......#..
|
||||
..#..##...#.#..#.......#.#####.
|
||||
.......#.#...........#....#.#..
|
||||
.#.###..........#...#..#...#...
|
||||
..#.#............##......##....
|
||||
...##..#...###...##....#.#.##..
|
||||
....#.##...#..#.#.#...........#
|
||||
....#..#....##.....#.##.#.....#
|
||||
..##......##.#.........#....#.#
|
||||
###...#...#..#.#...#...........
|
||||
.####.....#.....#.#....#..#....
|
||||
.#....#..#..#..#...##.....###.#
|
||||
#....##.#....#.##..#......##..#
|
||||
.........#..#.#.....#.#....##.#
|
||||
.....#.#...#....#.#...#....#..#
|
||||
.#...#.#.....#.#......#.#......
|
||||
#....##.......#.............#..
|
||||
#..#...#........##..#..#......#
|
||||
####..##.#..##..#.........####.
|
||||
.#.##..#.#..#.#.#.##...#..#.#.#
|
||||
.##.#..#............#......#...
|
||||
###....#.##....#..#...#........
|
||||
.....#..###..........#..#......
|
||||
.##..##.....#..##....#...#.....
|
||||
#...##...........#..#...###..#.
|
||||
#..##....#...#.##.##....#......
|
||||
...#...#..#.#.......##.......##
|
||||
....#.....#..#...#.........#.#.
|
||||
.#...##.#......#.#..#..#...##..
|
||||
...##...##.##...##...#..#......
|
||||
#..##.#..#..#............#...#.
|
||||
..#.....#.........#........#.#.
|
||||
#.#...#...#......#.#......#....
|
||||
.##.....##.#.#....#.##...##.#..
|
||||
.##..##.#.#....#.##............
|
||||
.#.##.....##.#...#...###....#..
|
||||
.#..............#.#....###.###.
|
||||
....#..#...#.#.#..........#.#.#
|
||||
.#.#..#.#.#...###..#...##......
|
||||
.#.#.....###......#..........#.
|
||||
........#.##...............#.#.
|
||||
...#.#.#......#..#..##........#
|
||||
..#.##......#.......#..#......#
|
||||
...#...#...#...#..#..#........#
|
||||
..#....#.....#....#..##........
|
||||
.....#..#...##....#......##....
|
||||
...##..##..#..........##....#.#
|
||||
..#....#..#...#.##..#.....##...
|
||||
###...#.#....#........#.......#
|
||||
......#...#..#....###.........#
|
||||
..###.#...#...#...#.#..###.#...
|
||||
.##.#.......#.#..#..#......#.#.
|
||||
...##...........#.#..#.#..#....
|
||||
.......#.....####.#.....#...#.#
|
||||
......##......##.#.#.#...#.#..#
|
||||
..###.#####..#....#.#...#..##..
|
||||
.....#..#......#........#......
|
||||
#..##....#.#.##....#....#......
|
||||
.#....#.##.####.##..#..#......#
|
||||
#...##...#.#...##.#.##.##...#..
|
||||
........#.#........#.#...#..#..
|
||||
.#....###..#......#.##.###..#..
|
||||
.#..#..#..#..#...#.#.........##
|
||||
....#...#..#..............#....
|
||||
........#...##.....#.......#...
|
||||
..#......#.#..#.#..#.#.#...###.
|
||||
....#...####....###....#......#
|
||||
#...#.#...................#.##.
|
||||
..#.#.###...#....##....##......
|
||||
#..##..#.........#....#....####
|
||||
.#....###...#.#...#......#...#.
|
||||
......#..#.#..#.##...#.#.#..#..
|
||||
.#...#.#.....#..##......#..#...
|
||||
##.#..##.....##.#.#.......##...
|
||||
.##.##.##..#...#.#.##.##.......
|
||||
.#.#......#.....#...#.#..#.....
|
||||
...#...........#..#.##..##..#..
|
||||
.....#...##......#........#.#..
|
||||
....#..............##.........#
|
||||
..####.#....##..##......##.#.#.
|
||||
.#.#..#...#..........#...###..#
|
||||
....#.#.##.....###.#..#.##.....
|
||||
.......##.#.#..#...#...##.#....
|
||||
...#.##.....#....#...#...#.....
|
||||
##.#.##..#..#.#.....#.#..#.....
|
||||
..#..##........#....###..#..#..
|
||||
..#.........##.....#......#...#
|
||||
...##..........##......#.#.#...
|
||||
#.....#..#..#......#......#....
|
||||
.##...#..##....#.......##..#.#.
|
||||
.#...##...##......####.##.#....
|
||||
.....#.........#.#.####......#.
|
||||
...#.....#.#.........##..#.....
|
||||
##.#.###.#..#.#..#............#
|
||||
...##..#.#....#....#..#........
|
||||
..#.###......#...#.#.....#...#.
|
||||
....##.##..#.....#...#.#.#....#
|
||||
.......#.#..#...........#.#....
|
||||
.#.#..##.#.......#.#..#.....###
|
||||
...#.#.....#.#..#.##..#...#.#..
|
||||
...#......##....#..............
|
||||
......#...#....................
|
||||
..#........#...##.##.#..#.#.#..
|
||||
.#.###.#.##..##..#....##....#..
|
||||
.....#..#.#...#.#..#..#.......#
|
||||
..........#.##.#..##..####.....
|
||||
............#.#......#.........
|
||||
.#....#..#......#.....##.......
|
||||
.....#........#.....##.#..#.#..
|
||||
#..#.##...#.#.....#...#.####...
|
||||
......#...#....#.##..##.#...#..
|
||||
.#.#.##......##....#.#....#.##.
|
||||
#.#.#....#.###....##....##.....
|
||||
.##..#...#.##......#..#..#...##
|
||||
...#....###....#...........#.#.
|
||||
#.#.##.##...##....#....##.#...#
|
||||
.#.#######.......#......#......
|
||||
#......#...#.#.#.###....#.##..#
|
||||
......##..#..##.........##.#.##
|
||||
....##...#.#....##.....#.....#.
|
||||
..#.#........##........#.#..##.
|
||||
.....#..#.##.....#.....#..#.#..
|
||||
.#..............#.......#......
|
||||
.............#..#..........#...
|
||||
.#..#.##....##.#..#...##.......
|
||||
...........#..#.......#.#....#.
|
||||
.#..#..........##...#.#.#...#..
|
||||
......#....#..###....#......#..
|
||||
.#...#...##..#..#..##..#..#.#..
|
||||
#.#.........#....#..........##.
|
||||
...##..#..##...#....##...##.##.
|
||||
..#....#.####.........#.....##.
|
||||
.....#.#...#.#...#.##.#...##..#
|
||||
#...#.....#..#.......#...#..#..
|
||||
..#.......#..##.#.....#....#...
|
||||
.#.....#..##.#.....#...#.#...#.
|
||||
.....#.##..........##....#...#.
|
||||
...#....#...#........##...#...#
|
||||
....##...#....#..........#.....
|
||||
...#....##..#..####..##.#...#.#
|
||||
#...###.###..#....##.#.........
|
||||
.#.......#......#.........#....
|
||||
..#..##..#.........##..........
|
||||
#......#.#.##...#...#####......
|
||||
......#.....####......#....#...
|
||||
.........#..#..#...#....#.#....
|
||||
....#........#...##....#.......
|
||||
...##.#...#..........#....#....
|
||||
........#.......#.##..#..#...#.
|
||||
....#..##...........#.....#..#.
|
||||
#....#...............#.#....#..
|
||||
.#........#....#.#...#.......#.
|
||||
#.......##..........#.......#..
|
||||
...#....#...##.#..#.......#....
|
||||
#..#.##...#.#...#...#...#....#.
|
||||
###...#...#....#....#....#...#.
|
||||
##......#.#.......#....#..#....
|
||||
......#......#....#.#.#..###..#
|
||||
.#.#.##.....#..#..........#....
|
||||
##...#.#.#..##....#.....#.#....
|
||||
#.##...#...#.#...####..#.......
|
||||
.....##..#.#.#....#..##..#.#...
|
||||
....###.#.........##.....#.....
|
||||
......##...........#........#.#
|
||||
.#.........##..................
|
||||
.........##...#.............#.#
|
||||
......##...#...#.........#..##.
|
||||
#..#.......#..##.......###.....
|
||||
....#.#.....#............##....
|
||||
.....#..#......#....#.....##...
|
||||
##......##...................#.
|
||||
#....#............#.#.###.##...
|
||||
.#.....#........#.....#...#....
|
||||
......##.......######......##..
|
||||
.#....##....#..###....#.......#
|
||||
..............##.#..#.......#.#
|
||||
.#..#..........#..#.##.........
|
||||
......##.#..#......#.#....##.#.
|
||||
#.....#.##...#.....#...#..#...#
|
||||
.#....#..##.....#.....#.#.#....
|
||||
..#......#.##..#.........#.#.#.
|
||||
.#..##...#...#.....#..#..#.#..#
|
||||
#.#.##.##.................#.#.#
|
||||
.#..#.#..##.#.......#.......##.
|
||||
#...#...#..##...#...##...#...#.
|
||||
....#......#..#...#.....##..#..
|
||||
..............##......#...#.#..
|
||||
..##..#.......#..#..###.#.#....
|
||||
.#..#..#...#.......#...#...##.#
|
||||
.#...#.......###..#.##.###.....
|
||||
##.#...#......#.....#..#.......
|
||||
##....##............#.....#..#.
|
||||
.....#...##......##.....#....##
|
||||
#...##..#....#..##....###.#...#
|
||||
.....#..#.#.....#.##..##....#..
|
||||
.#.....#.#........#...#.#......
|
||||
......#....#.#........#.#......
|
||||
.##..#...............###...##.#
|
||||
.......###.#.#......###.....#..
|
||||
.......#..##...#....#.##..#.##.
|
||||
..#.......##.......#.....#....#
|
||||
.#......#....#..##..#.#.#..##..
|
||||
###......#...#..#.............#
|
||||
.#....#..#.#......##...........
|
||||
.#....#.##.....#..#.......#..##
|
||||
....#...#...#..#.....#..##..#.#
|
||||
#.#.#.......##.#..#.#....#.....
|
||||
##.#.......#...#...#.#......##.
|
||||
#....#.#...........#######.....
|
||||
...#.#.##.#......##..###.......
|
||||
..#.#....#..#.................#
|
||||
........#..##..#.....#....#.##.
|
||||
...#.#..#..#..#..............##
|
||||
.##.......###.#......#....#..##
|
||||
..##.##.#......#....#..#...#..#
|
|
@ -0,0 +1,25 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
slope = []
|
||||
with open("input") as fh:
|
||||
for ln in fh:
|
||||
row = []
|
||||
for c in ln:
|
||||
if c == "#":
|
||||
row.append(True)
|
||||
elif c == ".":
|
||||
row.append(False)
|
||||
elif c == "\n":
|
||||
pass
|
||||
else:
|
||||
raise RuntimeError("impossible")
|
||||
slope.append(row)
|
||||
xmod = len(slope[0])
|
||||
x = 0
|
||||
y = 0
|
||||
trees = 0
|
||||
while y < len(slope):
|
||||
trees += slope[y][x % xmod]
|
||||
x += 3
|
||||
y += 1
|
||||
print(trees)
|
|
@ -0,0 +1,34 @@
|
|||
#!/usr/bin/python3
|
||||
|
||||
slope = []
|
||||
with open("input") as fh:
|
||||
for ln in fh:
|
||||
row = []
|
||||
for c in ln:
|
||||
if c == "#":
|
||||
row.append(True)
|
||||
elif c == ".":
|
||||
row.append(False)
|
||||
elif c == "\n":
|
||||
pass
|
||||
else:
|
||||
raise RuntimeError("impossible")
|
||||
slope.append(row)
|
||||
def trees(slope, right, down):
|
||||
xmod = len(slope[0])
|
||||
x = 0
|
||||
y = 0
|
||||
trees = 0
|
||||
while y < len(slope):
|
||||
trees += slope[y][x % xmod]
|
||||
x += right
|
||||
y += down
|
||||
print(right, down, trees)
|
||||
return trees
|
||||
|
||||
t1 = (trees(slope, 1, 1))
|
||||
t2 = (trees(slope, 3, 1))
|
||||
t3 = (trees(slope, 5, 1))
|
||||
t4 = (trees(slope, 7, 1))
|
||||
t5 = (trees(slope, 1, 2))
|
||||
print(t1 * t2 * t3 * t4 * t5)
|
Loading…
Reference in New Issue