diff --git a/03/input b/03/input new file mode 100644 index 0000000..02364e0 --- /dev/null +++ b/03/input @@ -0,0 +1,323 @@ +.##.............##......#.....# +.#.#................#.......... +...#..#.##..#.#......#.#.#.#..# +..#......#........#..#..#.#.#.. +.......#....#..#..#.......#.... +..#..#..##.#...#........#.###.. +..#...#..#.....#.##....#....... +....#..###.#......#.##..#...##. +..#..........#.##.#...#........ +#...#............##....#..##... +.......##....#.....##..#.#..#.# +..#..#..#...#....#....#....#... +.#...#.##........#####........# +..#..#......#.....##...#....... +....#......##....#.#....#.#..## +#.#.##....##..#.........#.###.. +##..###..#..#.......###.......# +...#.#......#.........#....#... +.....#..........#.....##..#.#.. +....##......#.#..#....#.#...... +..#.....#..##.......##......#.. +.........##.##.#..##........... +....#...#.....#....#.#.###....# +.##.#..#...##..#.......#......# +##..#..#..####..#.#..#...#..... +..###..#..#..#.###..#....#.##.. +......#...###.#.#.....#........ +.....#...#.#...#.......#.....#. +#........#..##...........#..#.. +.#.##.##...#.....#.#....#..#... +..##.##....#.....#....#....##.. +#.........##...##..#.....#..#.. +........#.####....#...##.....#. +.#.#...#..#..#.#......##.....#. +..#..........##..#.#.#....#...# +#.......#...#...#.....#.##.#... +..#.....#..#.....####.#..#.#.## +...#.#..#...#.....#...#.#.#.#.# +.#..##....##.....#..#....###... +....#......##.#.#.....#......#. +..#.#...#......#.....##.......# +..#...###...#..#.#...#..#.....# +#..............#.....#....##..# +.#...#.......#.............#... +..###....#.##........#.#....... +#.##.......#..#............###. +#...#..##.#.#............###### +..##..#....#.#.###...#..##.##.. +.#...#.###.#....#...#....#...#. +#...#.......#...........#...##. +##.#......#####.............#.. +....#..#......##..#..........#. +#.....#.....#.#.......#...#...# +....#...#.#..##........#.#..##. +..##.....##............#.#.###. +#.........#........#..###...... +............#.................. +.#.###...####...#.#..#......#.. +...##.###.#....##.#..####..#.## +..#####.#.##...#.#...##.##....# +........##...#...#....##.....## +#...........###...#.#...##.#... +##......#...#.......###........ +..#..#.##.#..###....#..#.###.#. +...#.#.#...#....#.##..#...#.... +........#.##...##.#.....##...## +.#..........##..#..#..#.#...#.. +#.#...#.##.#....#.##..#........ +.#.#.#....##..##.####.....###.. +..#....##....#..#..#..##....... +..##...#.......#...##.#....#... +...####.#.#...........#.#...#.. +....####.....#.#.....#....##.## +..#.....#.#.............##....# +#.#....#####.##..####.#...#.#.. +#.#....#.##.#.#.##..#.#...#.... +......#.......#.......#.....#.. +..#.....#....###.###..#..#..#.. +#..#....##.###...##.....#...... +..#..#...#..#.##..........#.... +...#.#.#......#....#.##..#..##. +....##.#....#..#...##....###... +##.#.###.....#..#.#.#..#.....## +##..#.#........#...#..#.#...... +....#.#.......##.#...........#. +.......##...#...#...#.....#.... +.....#....#..#..###.#...#...... +............#.#..#......#.#.... +...##..#.##....##..##.#......#. +#.#.#......#.#.....#.#.#..#.#.# +...###..........#..#..#.##..... +......#......#......###..##.... +#...##...#....#....#..#...#.#.. +.......#..#......##.......#.... +...#..#..#.....#.....#......##. +..#....###..........##..#...#.. +..........#..#.#...#......#..#. +#...#....#.##.........#.#.#...# +.#.#.#...#.#...#.#..#..#....#.# +#.##....#..#.........#.##.##..# +..#.#..##.#....#.###.#...#....# +.#.......#...#.#.........#....# +.......#...#..........#.#..#... +...#.....##..#....#...###...#.# +#....##.##..........#.......#.. +.##..##......#...#....#.##....# +....#.....##...##.#..#......... +...#.#..##.#.#..#.......#....#. +.#...#.#.#.#..#..#.##.......#.. +..#..##...#.#..#.......#.#####. +.......#.#...........#....#.#.. +.#.###..........#...#..#...#... +..#.#............##......##.... +...##..#...###...##....#.#.##.. +....#.##...#..#.#.#...........# +....#..#....##.....#.##.#.....# +..##......##.#.........#....#.# +###...#...#..#.#...#........... +.####.....#.....#.#....#..#.... +.#....#..#..#..#...##.....###.# +#....##.#....#.##..#......##..# +.........#..#.#.....#.#....##.# +.....#.#...#....#.#...#....#..# +.#...#.#.....#.#......#.#...... +#....##.......#.............#.. +#..#...#........##..#..#......# +####..##.#..##..#.........####. +.#.##..#.#..#.#.#.##...#..#.#.# +.##.#..#............#......#... +###....#.##....#..#...#........ +.....#..###..........#..#...... +.##..##.....#..##....#...#..... +#...##...........#..#...###..#. +#..##....#...#.##.##....#...... +...#...#..#.#.......##.......## +....#.....#..#...#.........#.#. +.#...##.#......#.#..#..#...##.. +...##...##.##...##...#..#...... +#..##.#..#..#............#...#. +..#.....#.........#........#.#. +#.#...#...#......#.#......#.... +.##.....##.#.#....#.##...##.#.. +.##..##.#.#....#.##............ +.#.##.....##.#...#...###....#.. +.#..............#.#....###.###. +....#..#...#.#.#..........#.#.# +.#.#..#.#.#...###..#...##...... +.#.#.....###......#..........#. +........#.##...............#.#. +...#.#.#......#..#..##........# +..#.##......#.......#..#......# +...#...#...#...#..#..#........# +..#....#.....#....#..##........ +.....#..#...##....#......##.... +...##..##..#..........##....#.# +..#....#..#...#.##..#.....##... +###...#.#....#........#.......# +......#...#..#....###.........# +..###.#...#...#...#.#..###.#... +.##.#.......#.#..#..#......#.#. +...##...........#.#..#.#..#.... +.......#.....####.#.....#...#.# +......##......##.#.#.#...#.#..# +..###.#####..#....#.#...#..##.. +.....#..#......#........#...... +#..##....#.#.##....#....#...... +.#....#.##.####.##..#..#......# +#...##...#.#...##.#.##.##...#.. +........#.#........#.#...#..#.. +.#....###..#......#.##.###..#.. +.#..#..#..#..#...#.#.........## +....#...#..#..............#.... +........#...##.....#.......#... +..#......#.#..#.#..#.#.#...###. +....#...####....###....#......# +#...#.#...................#.##. +..#.#.###...#....##....##...... +#..##..#.........#....#....#### +.#....###...#.#...#......#...#. +......#..#.#..#.##...#.#.#..#.. +.#...#.#.....#..##......#..#... +##.#..##.....##.#.#.......##... +.##.##.##..#...#.#.##.##....... +.#.#......#.....#...#.#..#..... +...#...........#..#.##..##..#.. +.....#...##......#........#.#.. +....#..............##.........# +..####.#....##..##......##.#.#. +.#.#..#...#..........#...###..# +....#.#.##.....###.#..#.##..... +.......##.#.#..#...#...##.#.... +...#.##.....#....#...#...#..... +##.#.##..#..#.#.....#.#..#..... +..#..##........#....###..#..#.. +..#.........##.....#......#...# +...##..........##......#.#.#... +#.....#..#..#......#......#.... +.##...#..##....#.......##..#.#. +.#...##...##......####.##.#.... +.....#.........#.#.####......#. +...#.....#.#.........##..#..... +##.#.###.#..#.#..#............# +...##..#.#....#....#..#........ +..#.###......#...#.#.....#...#. +....##.##..#.....#...#.#.#....# +.......#.#..#...........#.#.... +.#.#..##.#.......#.#..#.....### +...#.#.....#.#..#.##..#...#.#.. +...#......##....#.............. +......#...#.................... +..#........#...##.##.#..#.#.#.. +.#.###.#.##..##..#....##....#.. +.....#..#.#...#.#..#..#.......# +..........#.##.#..##..####..... +............#.#......#......... +.#....#..#......#.....##....... +.....#........#.....##.#..#.#.. +#..#.##...#.#.....#...#.####... +......#...#....#.##..##.#...#.. +.#.#.##......##....#.#....#.##. +#.#.#....#.###....##....##..... +.##..#...#.##......#..#..#...## +...#....###....#...........#.#. +#.#.##.##...##....#....##.#...# +.#.#######.......#......#...... +#......#...#.#.#.###....#.##..# +......##..#..##.........##.#.## +....##...#.#....##.....#.....#. +..#.#........##........#.#..##. +.....#..#.##.....#.....#..#.#.. +.#..............#.......#...... +.............#..#..........#... +.#..#.##....##.#..#...##....... +...........#..#.......#.#....#. +.#..#..........##...#.#.#...#.. +......#....#..###....#......#.. +.#...#...##..#..#..##..#..#.#.. +#.#.........#....#..........##. +...##..#..##...#....##...##.##. +..#....#.####.........#.....##. +.....#.#...#.#...#.##.#...##..# +#...#.....#..#.......#...#..#.. +..#.......#..##.#.....#....#... +.#.....#..##.#.....#...#.#...#. +.....#.##..........##....#...#. +...#....#...#........##...#...# +....##...#....#..........#..... +...#....##..#..####..##.#...#.# +#...###.###..#....##.#......... +.#.......#......#.........#.... +..#..##..#.........##.......... +#......#.#.##...#...#####...... +......#.....####......#....#... +.........#..#..#...#....#.#.... +....#........#...##....#....... +...##.#...#..........#....#.... +........#.......#.##..#..#...#. +....#..##...........#.....#..#. +#....#...............#.#....#.. +.#........#....#.#...#.......#. +#.......##..........#.......#.. +...#....#...##.#..#.......#.... +#..#.##...#.#...#...#...#....#. +###...#...#....#....#....#...#. +##......#.#.......#....#..#.... +......#......#....#.#.#..###..# +.#.#.##.....#..#..........#.... +##...#.#.#..##....#.....#.#.... +#.##...#...#.#...####..#....... +.....##..#.#.#....#..##..#.#... +....###.#.........##.....#..... +......##...........#........#.# +.#.........##.................. +.........##...#.............#.# +......##...#...#.........#..##. +#..#.......#..##.......###..... +....#.#.....#............##.... +.....#..#......#....#.....##... +##......##...................#. +#....#............#.#.###.##... +.#.....#........#.....#...#.... +......##.......######......##.. +.#....##....#..###....#.......# +..............##.#..#.......#.# +.#..#..........#..#.##......... +......##.#..#......#.#....##.#. +#.....#.##...#.....#...#..#...# +.#....#..##.....#.....#.#.#.... +..#......#.##..#.........#.#.#. +.#..##...#...#.....#..#..#.#..# +#.#.##.##.................#.#.# +.#..#.#..##.#.......#.......##. +#...#...#..##...#...##...#...#. +....#......#..#...#.....##..#.. +..............##......#...#.#.. +..##..#.......#..#..###.#.#.... +.#..#..#...#.......#...#...##.# +.#...#.......###..#.##.###..... +##.#...#......#.....#..#....... +##....##............#.....#..#. +.....#...##......##.....#....## +#...##..#....#..##....###.#...# +.....#..#.#.....#.##..##....#.. +.#.....#.#........#...#.#...... +......#....#.#........#.#...... +.##..#...............###...##.# +.......###.#.#......###.....#.. +.......#..##...#....#.##..#.##. +..#.......##.......#.....#....# +.#......#....#..##..#.#.#..##.. +###......#...#..#.............# +.#....#..#.#......##........... +.#....#.##.....#..#.......#..## +....#...#...#..#.....#..##..#.# +#.#.#.......##.#..#.#....#..... +##.#.......#...#...#.#......##. +#....#.#...........#######..... +...#.#.##.#......##..###....... +..#.#....#..#.................# +........#..##..#.....#....#.##. +...#.#..#..#..#..............## +.##.......###.#......#....#..## +..##.##.#......#....#..#...#..# diff --git a/03/part1 b/03/part1 new file mode 100755 index 0000000..d3fee85 --- /dev/null +++ b/03/part1 @@ -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) diff --git a/03/part2 b/03/part2 new file mode 100755 index 0000000..ebade70 --- /dev/null +++ b/03/part2 @@ -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)