2020 day 3
This commit is contained in:
parent
de078fee90
commit
f01c268237
|
@ -0,0 +1,10 @@
|
|||
import numpy as np
|
||||
with open('input03', 'r') as file:
|
||||
treemap = np.array([[c=='#' for c in line.strip()] for line in file.readlines()])
|
||||
rows, cols = treemap.shape
|
||||
r = np.arange(rows)
|
||||
print(f'Part 1: {treemap[r, (r*3)%cols].sum()} trees hit')
|
||||
|
||||
slopes = [(1,1), (1,3), (1,5), (1,7), (2,1)]
|
||||
tps = [treemap[np.arange(0, rows, i), (np.arange(-(-rows//i))*j)%cols].sum() for i,j in slopes]
|
||||
print(f'Part 2: {"*".join([str(t) for t in tps])} = {np.prod(tps)}')
|
|
@ -0,0 +1,323 @@
|
|||
..#.......#..##...#...#..#.#...
|
||||
..##..#..#.....#.........#....#
|
||||
...#.##..#.#......#.#....#.....
|
||||
...#.....#......#...#..........
|
||||
.......#.#..#..#....##....##...
|
||||
.#......#......#.#..#....#.#...
|
||||
.#..........#.....###.##..#.#..
|
||||
....#...##...........#.........
|
||||
##......#.#...#...#....##.#...#
|
||||
.....#.....#.#..#....###...#..#
|
||||
.#....#.........#...#.......#.#
|
||||
.##......#.#.........#....#.#..
|
||||
...#........###..#......##....#
|
||||
.#.....###..........#...#....##
|
||||
............#......#...#...#..#
|
||||
.....#.#....#.#.#...........#.#
|
||||
....#.....#...##.##.....###..#.
|
||||
.....#.##......#.##.#...#.#.#..
|
||||
##.....#.##.##....#..##......#.
|
||||
.....#.....#........#........##
|
||||
#..#...#.#.#..##....#....##..#.
|
||||
.#......................##..#..
|
||||
#.#.#................#.....#...
|
||||
..#....#.#.#..##..#..#.....##..
|
||||
.....###..#.............#....##
|
||||
..#....#.#...#......###..#.....
|
||||
.......####.....##......#......
|
||||
..##...#..#...#.#..#......#....
|
||||
..##..#..#.....#......##.##....
|
||||
.#......#................#..#.#
|
||||
...............#....#.......#..
|
||||
#...........#.#.#........#.#...
|
||||
...#...#..#.....##..#.##...#.#.
|
||||
.#.#..#.#.....#...#..##....#.##
|
||||
.........#...#.#.#....#.......#
|
||||
............##.#..#.#........#.
|
||||
#..#..#........#......####.....
|
||||
..#.#...#...#...#.#...#..#..#..
|
||||
#....................#.#.#....#
|
||||
.......#.....#....#....##..#...
|
||||
.......#.............##.....#..
|
||||
..##..#.......#..#.........#..#
|
||||
..##.#........#...#...#..#..#..
|
||||
..##.#...#................#..#.
|
||||
..#.....##...##......###.....#.
|
||||
.....#.....#......#......#.....
|
||||
....##.#.#....#.....#..........
|
||||
...#...#.#.....#.###.....#....#
|
||||
......##....#..##...##.#.......
|
||||
......................##......#
|
||||
.##......#...#...#...##.#.##.#.
|
||||
#.......#...#.....#........#.#.
|
||||
...............#......#.......#
|
||||
.#..##...#....#.....###....##..
|
||||
...#..###...#..#....#.#..#.....
|
||||
.#...#....#.................#..
|
||||
.......##....#..##......#.#....
|
||||
....#.....#.....###...#....#...
|
||||
..##..#..##........#...........
|
||||
....#..#.#............#........
|
||||
####.....##.........#....#.....
|
||||
........#.....#......#......##.
|
||||
#..........#........#....#...##
|
||||
#..#...###.....##.....#.##...#.
|
||||
......#....##.............#..#.
|
||||
..#......###...#...#..##.....#.
|
||||
#.##...#......##.###....#....#.
|
||||
...............#....#.....###.#
|
||||
#......#........#.#..##.#.....#
|
||||
#..............#..##.#....#....
|
||||
.##....###...#...#.#....#....#.
|
||||
.......#...#.......#....#..##..
|
||||
..##.#.....#..#...............#
|
||||
.##..............#.......#...#.
|
||||
.....#...#.#..#.........#..#...
|
||||
........#.#.###......#..#......
|
||||
..#.......###..#...#...........
|
||||
............#.#.....#....#...#.
|
||||
#...#..#......#..#......#......
|
||||
..##..#......#..#.......#.....#
|
||||
............#.##.....#.#...#...
|
||||
....#.#...#.#...#........##....
|
||||
........##...#...##.....#.#..#.
|
||||
.#..........#.##...............
|
||||
###.#..#...###..###..#........#
|
||||
....#..#............#...#.#.#..
|
||||
.#....###........#.......#...#.
|
||||
..........#..#.....#......#....
|
||||
..##..#.#....#..#.....##....#..
|
||||
...#...............#......#....
|
||||
......#.#.#...###.....##.#.....
|
||||
.#...#.#.#.#....#.....#..#..#.#
|
||||
..#.....#..##....#......#.#.#..
|
||||
##.#....#.......#.#.#.......#..
|
||||
.#.#.#........##.#....#........
|
||||
...#..#...#.#.........#..#....#
|
||||
#.#......#.#.#..#.#............
|
||||
......#.....#.....#.......#..#.
|
||||
.........#..#.##..#..###....#.#
|
||||
.......#..........#..#.........
|
||||
......#.#.##...#.#...##........
|
||||
...........##..##.##....#......
|
||||
..#..#...#.###...##.....#..#..#
|
||||
.#...##.......#.#..........#..#
|
||||
##......#...........#.#........
|
||||
..#..#.....##..#.#.......#...#.
|
||||
.#....#..#.....###.......#...#.
|
||||
...#..#...#...###.#.###..#.....
|
||||
.......#...#.##......#.#.#.#...
|
||||
.#.......#...#...#...##........
|
||||
...#........#....#..#.#...#.#..
|
||||
..#............#.....#.#....#..
|
||||
#.....#.#..#.#....#...#.#.#....
|
||||
#......#......##.#...........#.
|
||||
.#..#.........##.#........#....
|
||||
.#....#.#...#........#......#..
|
||||
....#..#..#....#..#.#.....#..#.
|
||||
.##.#.....#..#.#...#.....#..###
|
||||
#..#......#..##....##..#.......
|
||||
.......#..##....#.###..........
|
||||
.#......#..........#........#..
|
||||
.........#.....#......#.#......
|
||||
.....#..#.......#...#.#....#...
|
||||
.#......#...#..#......#.....#.#
|
||||
#.#.#..#.........#.......##....
|
||||
...#..#.....#.#..#......#...#..
|
||||
.##...#...#.#....#.....#.#...#.
|
||||
..#......##......#....#.#..#...
|
||||
....#.#.....#..#...........#...
|
||||
.#........#....#....#...#......
|
||||
..#.#.....#.......#.#.#.##..##.
|
||||
...#..#.##.......#...#.........
|
||||
....##.#.#..#.#..#.#.#..#.#.#.#
|
||||
......#.......#.....#...##.#...
|
||||
..#.##.....#....#...#...##.##.#
|
||||
..##.........##.........#..#...
|
||||
.....###......####..#.#...#....
|
||||
...#....#....##.............#.#
|
||||
.#.........#.......##..#.#.....
|
||||
...#..#........#...............
|
||||
........#........##......#.#...
|
||||
##...#......#.....#.##........#
|
||||
.............#.#........#......
|
||||
.......##.........#.......#....
|
||||
....#.......#......#..###....#.
|
||||
.#.##........#.....#......#....
|
||||
#...........##...#..##.........
|
||||
.....#.#........#........##...#
|
||||
#.........#..##.....#...#....#.
|
||||
.........#...####..#....###....
|
||||
###.#..##.......#....#....#.##.
|
||||
...........#.....#.#...#..#....
|
||||
.##......###.#.#.#....#........
|
||||
....#..................#.###.#.
|
||||
#..##...#......#...#......###..
|
||||
.#.....#..##......#.#.#.#......
|
||||
..##...#..#.......##.#.......#.
|
||||
...#..#..##..##..##.#..####....
|
||||
......#..#..............#.#####
|
||||
....#....#..#...#...#.#........
|
||||
.###...#.......#..#........#...
|
||||
........#.#......##...#........
|
||||
.#..#.......##.......#.....##..
|
||||
...##..........##...........#..
|
||||
......................#..#.#.#.
|
||||
#..#.....#......#.....#....#.##
|
||||
..#......#.....#....#...#.##.#.
|
||||
............#...#...#......#.##
|
||||
........##.......#......##.....
|
||||
..#.##.....#....#..##...#......
|
||||
........#.#...##.#..#...#....#.
|
||||
...##............##.....#..#...
|
||||
...###.##....#....#.#.#.#..#...
|
||||
............#..#....#..#.....##
|
||||
...#......##.......#......##..#
|
||||
.......#......#........#.....#.
|
||||
.#....#.##..........#..........
|
||||
..###.........#..#...##.....#..
|
||||
##....##..#.......###....#.#.#.
|
||||
#.......#.#.##.................
|
||||
..#..........#................#
|
||||
....#.#....#...###...#......#..
|
||||
.#..........#..#..##.....#...##
|
||||
.#.....###....#.#...#.#........
|
||||
.........##.........#..#.#.....
|
||||
.#.....##....#......##.#....#..
|
||||
###..#...#..#.........#......#.
|
||||
..##.....#....#............#...
|
||||
.....##.##....#.....#..#..#....
|
||||
.......###...#..........#......
|
||||
...#........#....#.##.#........
|
||||
........###....##........##.#..
|
||||
....#....#........#.....##.....
|
||||
.#........#.#........#...#..#..
|
||||
#..#..#......#....##.#..###....
|
||||
...........#...#...#....#.#...#
|
||||
.#..#.....#.##..#......##......
|
||||
..#.#...............##..##.###.
|
||||
...#.#...#............##.#..#..
|
||||
.#.#....#....#................#
|
||||
...#..#.#.##.#.#....#......#...
|
||||
.........#..#.......##.##.#....
|
||||
..............#..##.#.....#....
|
||||
......#.........#...#...##.#..#
|
||||
....##.....#.#...#.#.####.#....
|
||||
#..#.#....#.##.......#....#....
|
||||
...##....#...................##
|
||||
##.#.......#....#.#.........#.#
|
||||
.##.#..###...#.#.........#.....
|
||||
...#.#.#..#...#...#.##....#..#.
|
||||
....#.....###...#....##........
|
||||
.............#....#....#....#..
|
||||
#...#.....#.#...#.#............
|
||||
#.#....#...........##.......#..
|
||||
..#..#.........#....###.......#
|
||||
....###..................##...#
|
||||
.#........#.....##...#......#..
|
||||
#..#......#..#.....#.##..#...#.
|
||||
....#........#.##.#......#.....
|
||||
#.#...#...............####...##
|
||||
#.#.....##..#.####.............
|
||||
##...##..#.##........#.#...#...
|
||||
...#...........#............#..
|
||||
...#..#..#........##...........
|
||||
..#.##..#.#...#...#..#......#..
|
||||
.....##......#...##.....##.....
|
||||
.......##.....##....#..........
|
||||
..........#.#...............#.#
|
||||
#.#..........#..#..##..#...#..#
|
||||
.#.#..#.###................#...
|
||||
#...#...#....#...#....#.##.##..
|
||||
.#................###.....##...
|
||||
.....##.#.....##.#.....#.....##
|
||||
.......#.......#......#.#......
|
||||
..#....#......#.....#.....#..#.
|
||||
#......#..##..####.....#.#..#..
|
||||
.......#...###..#...#.....#....
|
||||
#.#.#......#.............#..###
|
||||
.#.#.......#..#.#..#..#...#.#..
|
||||
..#.#......#......#.#....#.....
|
||||
..#..###..#.#.....#....#.......
|
||||
..........#........#......#..#.
|
||||
##..........##....##..###.##...
|
||||
...#....#.......#..##.......#..
|
||||
##...#............##...#.#.#.#.
|
||||
...........#...#.#....#.....##.
|
||||
.#................#.......#...#
|
||||
....##.#..#.#.........###.###.#
|
||||
#..#...###..#...#......#..##...
|
||||
..##........#.#..##.#..........
|
||||
...#..#...#...............#.#..
|
||||
##.##....#...#........#...#....
|
||||
#..#......#.##.................
|
||||
.....#..##.##.......#..........
|
||||
...#.....#........#......#.....
|
||||
.....#..#......#.....##...#....
|
||||
#......#...###....#....###.....
|
||||
................###..#..#..#.##
|
||||
......#.......#..........#.#..#
|
||||
###..#..#.##.............#.#...
|
||||
....##.#.......#...#..##.......
|
||||
..#.....##..#..#..#.#..........
|
||||
.#.......#.#..#........##......
|
||||
..............#.........#......
|
||||
..#........##....#.#.#......##.
|
||||
.#.#.........#.#...#.#.........
|
||||
..........#..#.##.#....#...#.#.
|
||||
............##....#.....###...#
|
||||
#....#..#...#.#...#.....#....#.
|
||||
.#...##.....#......#..#........
|
||||
.#..#...###.#..##........#...#.
|
||||
#..#...##.####.......#.....#...
|
||||
#.##..#...#......#.#.......#.#.
|
||||
#.#.....##...#.#...............
|
||||
#...........##.##.#.........#..
|
||||
...#...........#.#.#.#....#..#.
|
||||
..#......#.#.#....##..#.#.....#
|
||||
.........#.#.##...##...#.#.#...
|
||||
...........#..#.####.#..#.#.###
|
||||
#........#.#......#..#...#.....
|
||||
...#....#......##...#.#........
|
||||
......#.#....#.##....#....#..##
|
||||
.......###......#.#.....#......
|
||||
#..........##..................
|
||||
.###.......##..#..##...##......
|
||||
##.#..............#....#....##.
|
||||
#....#.....#.##.....#..#....#.#
|
||||
.......#.......#..#..#..##..#..
|
||||
......#...........#..##....#...
|
||||
.....#.......#..#......#..#..##
|
||||
.##...#......#........#....#...
|
||||
.....#..#....#...............##
|
||||
..#.....#....#..#.##....#.#....
|
||||
#.#......####...#..#.........#.
|
||||
#.#........#..#........#...#...
|
||||
..#..............#.......###.#.
|
||||
...#.#....##.#......#........#.
|
||||
....###.......##.#.....##.....#
|
||||
.........#......#.#.......##.##
|
||||
.......#.#....#.#...#...#....#.
|
||||
....#....#....#.#.......##.....
|
||||
#...#.....#..#.....#...........
|
||||
#...#..#...#.#..#.............#
|
||||
........###..#........#........
|
||||
.............#....#..###..#.#.#
|
||||
#...............#..#.#.........
|
||||
##.....###..#......#...#....#..
|
||||
.#...................##.#.##...
|
||||
#..#........#.#...#..#...#.....
|
||||
................#.#.........#..
|
||||
#.....##.#.#...#..#.........##.
|
||||
...#.....#....#..####.#........
|
||||
....#.#...........#............
|
||||
.....#........##..........#....
|
||||
..#.......#.#.#.####..#......#.
|
||||
#.......#...##.#.#..#.#.#......
|
||||
##........#.#...###............
|
||||
..##........#........#...#.#.#.
|
||||
#.#..#.#.......#....#........#.
|
||||
..............#....#.........#.
|
||||
#....#.#........#.............#
|
||||
..##...#..........#........#...
|
||||
..#..#..#....#....#............
|
Loading…
Reference in New Issue