From 795b015ac906b9cdb1b734bc821790f46a32bc84 Mon Sep 17 00:00:00 2001 From: flifloo Date: Thu, 3 Dec 2020 12:46:51 +0100 Subject: [PATCH] Finish day 3 part 2 --- 2020/day 3/P2/input.txt | 323 +++++++++++++++++++++++++++ 2020/day 3/P2/toboggan_trajectory.py | 17 ++ 2 files changed, 340 insertions(+) create mode 100644 2020/day 3/P2/input.txt create mode 100644 2020/day 3/P2/toboggan_trajectory.py diff --git a/2020/day 3/P2/input.txt b/2020/day 3/P2/input.txt new file mode 100644 index 0000000..fd04fb1 --- /dev/null +++ b/2020/day 3/P2/input.txt @@ -0,0 +1,323 @@ +....#...............##...#...#. +#...#..#.....##.##.#.##....#... +...#.....#...#................. +#..#..#.......#...#.#.......... +...##..#.#..........##...#..... +........###.#.##..#............ +...###......##.#..#.#...#.#.... +......##..#.#....#...#......... +.................#......#...... +..............##....#.......... +#.....................#...#.#.# +.##..#............##...##.##..# +.....#.####...#..##......#.#..# +#.......#.#..#......##.#.#....# +.....##...###.#..........##.... +#...........#.##....##.....#..# +..###..##.##.....#....#........ +...#.#.#............#.#..#....# +#......#....#...##.#.#.#.#..#.. +.......#.#...#..#..#..##......# +.....#..#.............#..#...#. +##..#.##.....#........#........ +....##....#..#...........#...#. +.......#........##.......##.... +..##...#.......#........##.#... +..........#..#.....##........#. +..#..##..#............#........ +.#.#...#...#.......#......#.... +....#....#.....#.#.........###. +.............#...#....#..#.#... +##.#...#..#......#.#.##.....#.. +#...##.#..........#..#.#...#... +#####.......#.#.....#..#....... +#...#...#........#....#...#.... +......##.#..#..#............#.. +....#....#.......#...###....... +.#......##...#.##....#...#..... +..#....#...##.....#.#...##.#... +#.......#........#.####........ +#.##..#..#.........#.#........# +.#...#.#.#.#......#....#.#..#.. +#...####...##.##.#....#......## +..#...#......##........#.....#. +...#.#....##................... +...##................#......... +...##.....##........#....#..#.. +.........#..#.....#............ +.#..#.......................#.. +.#.........#..##........#.#.#.# +......#.....##..#.##...#..#.##. +..#..............##.......#.... +...............##....#...##..#. +###...#..###.........#...#..... +...#..#...#....#.....##........ +....#..##...#........#......... +..#......#.......#.....#..#.... +.#...........##.....###....#... +.#..#.....##.........##.....#.. +....##.#.....#................# +..#..#......#.#..#....#..##.... +#.....#...##............#...... +.#.............#....#.......#.. +#.........#..#...##.#...#.#.##. +...#......#..####....#.#.....#. +......#........#..........##.## +......##.#..##.##.....#........ +##.....#..##.##..#.......##.... +.##.........#...........#...#.. +.....#...###..#...#...........# +..........#.#......#.###.....#. +...#.............#.##......##.. +#.##.........#..###...........# +....#..##....#..#..#........### +...#........##.......##..#..#.. +...#......#..#.#............... +#......###....#.#..#.#..#....#. +#.#.####.#.........#..#.#.#.... +.....#....#...............#...# +.#........#......#.#...#....... +................#...#.....##... +.............#...####.......... +.................##....##.###.. +#................#......#...... +.###.#........#..##.....#..###. +..#.#..#...#..#.#...#.#.....#.# +.....#............#..##..#..#.# +#........##.#...#.....#........ +#.#.#..###......###............ +...#..#...........##...#.....#. +......#........#...#.#....#.... +....#..........#.#..#.#....##.. +...#.....##..#......#.#.##...#. +.........#..#................#. +..#....#.##.....#.......#...... +...#.....#.......##.##.....#... +#...#..............#..###..#... +#.#......#.#....#........##..#. +...#...##...##..#.........#.... +..#...#......##.#.#.#....##.... +#.......#.......#..#..#........ +.........#..#.....#....#.....## +.#......#.......#.#..#..#...#.# +..#....#.#..#.................. +#.....####..........#.#.....#.# +.#..#.#.#....#.#.....#.#....... +....##......#..#.....#.#.#...#. +...##...#......##.#....##.#.... +..#..##....#...#...........#... +.......#........#...##.#....... +#.#..#....##.#....##........... +.......#............#..##..##.. +#.#.#.....#....##.#.#.#.....#.. +##...#...#.......#..#...#.....# +##..##.##..........#........##. +..............#.....#..#..##... +.......#...#.........#....#.#.. +...#..#..#....#.#....##........ +..#.......#....#....##......... +#...#.....#..#.#...##....#..... +.....##..#..##..#.............. +.....##............#....#.#.... +..#.....#....##.#.....#..#..... +#...#..#..#......#.#.#..##..... +.............................## +#...#.#................#....#.# +.#.#.#....##......###..##...... +#.....#..#.##.#.#.##...###..... +.........#............##..#.... +.#..#...#....#.....#.#........# +...............#......#..#..... +...................###........# +.###..##..##.......#.#......... +#.........#......#....#.#...#.. +.#.#....#.......#.#..##...##... +.#.....#....##.......#.#.....#. +.........#...#....#.#.......... +....###..#..##.#...##....#..#.. +...#.#..##.#.........###.#..#.. +#...#...........#....#......... +....##...........#.#.#......### +#....#...........##..#......... +###....#.....#.......#....###.. +.#.......#....#.#.#.#......#.#. +........#...............#.#.#.. +....#.........#.....#...##.##.# +...#............#.............# +..........#..#................. +........#.....##............#.# +..#...##........#...#.....#.#.. +....#........#.#.#..........#.. +#.#...#...........#............ +....#.#...##...........#.....#. +...........#.#..#.....#........ +.....#..#..#..#.....#.#.....#.# +#.....#.......#.......#...#.... +#.........#....#.#........#..#. +...#..#.........#.....#..#..... +...#..#.............#.......... +.#.......#..........#.....#...# +.....#.#......#.......#....#... +...#.....#..#..##....##....#... +.#.#.#..#...#.....#....#....... +..##.#..........#.....#.#...... +..#..#.............#...##..##.. +.#.............#..#....##...#.. +..#...#.....#.................# +..##.......#.....#...#....#.... +.#..#.##.........#...#.#...#... +...##.......##..#.....##.##...# +........####.#.........#....... +..#.#...##.#..#..#.......##.#.. +.#..#............###..#..#..... +#.....#.#...#.#.......#........ +..........#......#.#...#...#... +..#......#..#..#.#...#......... +..###........#.#....#.#...##... +.#.....#..#.#......#........#.. +.#...#..#...#....#.......#..#.. +..#....#..#.....#.#........#... +#..#.#.........#..........#..#. +.#.....##....#.........#.#.#.#. +#.#...#.....#.#.#....#.#..#.... +.........#...................#. +..#.....#..##...#..........#.#. +..............#....#.........#. +.#....#.....#..............##.. +#...#...#.#........##.........# +....###....#.#....#.#.........# +.....#........#.....##......... +.#...##..##..#.........##...... +............#.....#........#... +..#....#.......#......#..#.#.#. +#.......#.#...........#..##.#.. +......#.##......#....#.......#. +.....#........#...###.....#.... +###..........#........#.#.#.... +.....#...#.#...#...#...##.....# +.##...#.#........#.#....#...... +......#.........#.....#.#...... +.....#.##.....###.#...#...##..# +.#.#.......##....#..#..#.##.... +.####...###.#.#.#.#............ +......#..##...#..........#.##.# +......#............#........... +.....#.#..#.......##...##...... +......#........#..#....#.#.#.#. +#..#..#.....#..#.....#.......#. +.#...#.....#..............#.... +.#....#..#.##.#............#### +..........#....#.##...#.#...... +...#.#.#.#.#.......#.........#. +##........#..##..#.........#... +..#......#...#..#.#.....#...... +..#.#......#...#...#.#......... +........................##..... +...#.##.#........#...#.......#. +..#.#......#....##........#.#.. +#......#.##........#..#......#. +.....#..#..#.............#..... +......#......#........#....#... +...#....###.....#..#.#....#.... +#.......................#....#. +..#...#...................#.... +....#..#.....##.#..#...#.....#. +...#.........#...#.......#..... +..#....#.....#...#...#.#####... +.....####......#...........#... +......#.#..........#...#.#.#..# +###..#.#....#..#............... +...#...###..#..#.#.#........... +.....#...#.##.#.#.###..##...... +.........#...........#....##.#. +....#..#......#................ +...........#..#..#...#.#....... +..#.....#......##.###.......... +.........#...................#. +..........#...#.#....##........ +..#...##....#....#.......#...## +#......#.....#...#...#...#..... +....##...#.#.......#.#...##.... +...#.....#....#.....#....#..... +#....##.....##..##..........##. +.....#.....#.#.#............... +.#.##....#.....#.#..#....#..##. +.....#.#.....##....#........... +.........#..#.......##..##..... +..#....##.....###...#....#.#... +............#......#.#...#..#.. +#..##......#.#.##....#.#....... +.#.#.....#...#.#.#....#.....#.. +#....#..#.#....#...#........... +......#.#.....#...#.#.#......#. +###..#....#.###.............#.. +..............#####........###. +..#..#.#.#.#......#......#..... +###.........#.#..........#..#.# +.#.........#...#......####..... +..#.......####..#....#...#..#.. +#.#..#.#...............#.#.#.#. +###....#.....##.#....#......##. +..#..#........#....###.#.#..... +...#.#..........#.....#...#.... +....#......##.#............#..# +...##...#.....#..##....#..#.#.# +.......#.....#..#....#....##.#. +.#..#....#..#......##....##...# +..#......#...#.#..###..#.##.... +#...#.....#......##...#.......# +.....#.#.....#...##............ +.#..##.##..#..##.#........#.... +....#.#......##...#.#.#.#..##.. +.#..............##........#.... +.##....#..#..#....#...#......#. +............###....##.......##. +..............####.....#....... +........##..##.#...#.......#... +....#..#.....##.......#####...# +.##..##..#.....#...#..#..#....# +##..#.#.#...........#.......... +#..#......#...#....#........... +...#..##.#..........#..#....... +........#.#.....#......##...... +.....#....#............#....... +.#.#..#....##......#.......###. +.#..#.#........#......#...##..# +...#....#......#..#........#.## +.........#..#...#..#.#.##...... +....###.#...........#...#...... +.##............#.......#..##... +##...#.#...............#.#...## +..#..#.....#.#..#..#........... +..#..#.##..#......#.##..#.#.... +..#...#......#.#...#....##.#... +...###....####......#....#...#. +.......##........#.....##....#. +.........##..........#...#..... +.....#............#.##.#....#.# +..........#...#....##.......... +....................#......#... +#......#..#...#.............##. +...........#................... +..#...#.........#.##.#..##.#... +#.#....#.#.....#............#.. +.#..#.....#.....####......#.#.. +#....#.......##..#...........#. +............#...#.....#..#.#... +#...........#...#####....#...#. +..........#...###..##.........# +#.....###............#..#..#.#. +...##.....#....#......#.....#.. +#....#.......#..#......###...#. +...##.##......##..##..........# +.......#.#..#.#..#.#.#.#..#..#. +..#..###...#....#.....#......#. +...#.........#..#.##.#.....###. +..#.........#.##.#..#..#..###.. +..####..#.........#.........#.# +..#.#...#.......#....##........ +.#......#.#.................... +..........#.......#.#..#..#.... +..#........#....#.#..#......... +..#.....#.............#....#... +##...#.........#.....#...#..... diff --git a/2020/day 3/P2/toboggan_trajectory.py b/2020/day 3/P2/toboggan_trajectory.py new file mode 100644 index 0000000..dd7a196 --- /dev/null +++ b/2020/day 3/P2/toboggan_trajectory.py @@ -0,0 +1,17 @@ +from functools import reduce + + +m = [m for m in open("input.txt").read().split("\n")[:-1]] + + +tl = [] +for i in ((1,1), (1, 3), (1, 5), (1, 7), (2,1)): + j = (0, 0) # y, x + t = 0 + while j[0] < len(m): + if m[j[0]][(j[1] % len(m[0]))] == "#": + t += 1 + j = (j[0] + i[0], j[1] + i[1]) + tl.append(t) + +print(reduce(lambda y, x: y*x, tl))