Did the day 3 :3

This commit is contained in:
Daniel Cortés
2020-12-03 02:20:42 -03:00
parent 42edc83f90
commit 95009b7fe6
2 changed files with 346 additions and 0 deletions

323
2020/day_3/input Normal file
View File

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

View File

@@ -0,0 +1,23 @@
with open('input') as f:
data = [line.strip() for line in f]
width, height = (len(data[0], len(data))
slopes = ((1, 1),(3, 1),(5, 1),(7, 1),(1, 2))
result = 1
for slope in slopes:
trees = 0
right, down = slope
while(down < height):
if data[down][right%width] == '#':
trees += 1
right += slope[0]
down += slope[1]
result *= trees
print(slope, trees)
print(result)