From 4dec21f362c03136e9811a4f4c162fcd8c50544e Mon Sep 17 00:00:00 2001 From: Tom van der Lee Date: Thu, 2 Dec 2021 17:39:03 +0100 Subject: Added day 10 --- day3/__init__.py | 43 -------- day3/example.txt | 11 -- day3/input.txt | 323 ------------------------------------------------------- 3 files changed, 377 deletions(-) delete mode 100644 day3/__init__.py delete mode 100644 day3/example.txt delete mode 100644 day3/input.txt (limited to 'day3') diff --git a/day3/__init__.py b/day3/__init__.py deleted file mode 100644 index 4954c15..0000000 --- a/day3/__init__.py +++ /dev/null @@ -1,43 +0,0 @@ -from functools import reduce -from typing import List, Generator - -from aoc import BaseAssignment - - -class Assignment(BaseAssignment): - def read_input(self, example = False) -> List: - return list(super().read_input(example)) - - def slope(self, input: List, dx: int, dy: int) -> Generator: - for y, row in enumerate(input[::dy]): - x = (y * dx) % len(row) - yield (x, y) - - def get_trees_for_slope(self, input: List, dx: int, dy: int): - trees = 0 - - for x, y in self.slope(input, dx, dy): - if x == 0 and y == 0: - continue - - if (input[y * dy][x]) == '#': - trees += 1 - - return trees - - - -class AssignmentOne(Assignment): - def run(self, input: List): - return self.get_trees_for_slope(input, 3, 1) - -class AssignmentTwo(Assignment): - def run(self, input: List): - return reduce(lambda accumulator, value: accumulator * value, [ - self.get_trees_for_slope(input, 1, 1), - self.get_trees_for_slope(input, 3, 1), - self.get_trees_for_slope(input, 5, 1), - self.get_trees_for_slope(input, 7, 1), - self.get_trees_for_slope(input, 1, 2), - ]) - diff --git a/day3/example.txt b/day3/example.txt deleted file mode 100644 index 8f551de..0000000 --- a/day3/example.txt +++ /dev/null @@ -1,11 +0,0 @@ -..##....... -#...#...#.. -.#....#..#. -..#.#...#.# -.#...##..#. -..#.##..... -.#.#.#....# -.#........# -#.##...#... -#...##....# -.#..#...#.# \ No newline at end of file diff --git a/day3/input.txt b/day3/input.txt deleted file mode 100644 index 6cfcb73..0000000 --- a/day3/input.txt +++ /dev/null @@ -1,323 +0,0 @@ -...#...#....#....##...###....#. -#.#...#...#....#.........#..#.. -.#....##..#.#..##..##.......... -.....#.#.............#..#...... -.......#...#.##.#......#..#.#.. -#.#....#......##........##..... -.....##.#....#..#...#...##...#. -...#...#..#.......#..#...##...# -..........#...........##....... -..#..#..#...................#.. -#..#....#.....##.#.#..........# -.#.##.......###.....#.#...#.... -.#..##....##....#.......#...### -#.#..##...#.#..#............... -.........#....#.......##.#.#... -...###...##....##...#..##.#..#. -....#.........#..#...#.......#. -....................#..#.#.#... -..#....#..........#...........# -.#.....#..#.....##........##..# -#..##..#...##............#..##. -.#..##....#..........#..#.##.#. -..#####..#.#............##..... -...###.#....##..#.#....#.....#. -.#.......##....#...#.#.....##.. -...#....#...##.#...#..#........ -.####.....#....#.#.#...#....... -...#....#.....#.......#........ -#..#.#.......#...#............# -...#.....###.##....#.#.###.#... -.#.........#.......#.#....##... -#.#..#...#.#...##......#..#.... -.....#...#..#.#...#..###..#.... -......#.........#...###........ -.....#..##...#..........#.....# -..#..#.#.##.#...#....#....##..# -##....#.##...#.##.#..##....#... -.....#.#.#.#..#....##.#...#.#.. -.....##.......#........#....... -...#.#.....#...#...##.#......## -........#..#.#...#.#.....#.#..# -#..##...#.#...##..##...#.#...## -.##.#.#..#...#.....#.#.##.#...# -.#.####.........##.........#..# -.##..............#....#...#...# -......#...#..#...#..#..###.#... -.......##...#.#.#..##..#......# -.....#....#..##..#.........#... -.....#..#.#.#........#.#.####.. -#..#.......###....##........... -#..##..........#.#......#.#.... -.....##........#...#..##....... -###...#.##.#.#.#.#.##...##..... -....#...#........##.#.##..##... -.#..#.#.#......#.......##..#..# -.#...#.................#....#.. -.##..#..........#..##.......#.. -.#.#.#.....#..#.#.........##..# -...#......##...#.......#...##.. -##...###....#.###.............# -#.....#.#..#.#..#........#.#.#. -.....#.#......##..#.#.....#.##. -.......#...........#..#.......# -..#....#.#.#......#.....#...#.. -.....##........#..##..#..##.... -#.#........#...##....#.#..##... -#......#......#....#..#...#.##. -....#.#.......#.#.#............ -......####.#.##...#.#.##.....## -..###.#.#..#.........#.####.... -.#.......#..#.#....#.#..#.#.##. -#....#....#............##...##. -....#....#............#....#..# -..#........#..#....#..#..#...#. -.#......##....#..........#....# -#.##.....#..........#.###.#.... -....##...#.....#.#......#.##... -#.#.....#.......###.###..#..#.# -..###..##.............#.####.## -#....#.....#....#..##.......#.. -.....#....#...#.#.#.#..#...#.## -...#.....#..#....###......#.#.# -##.........#.#..#..#.#..#.....# -.#.....#.#....#.........##..#.# -.#.#..#.###..#..#..........#... -.##....#.#.#...#......##.....#. -#.#....#....#...#...##...#..#.. -#...#........#....#....#......# -#......#...#..#.#.##.....##..#. -....#...#......##...#..#....#.. -.#......##.##.......#.......#.. -.#...#..####...........#.#.#... -.........#...#.#.........#..... -#.##.....#.#..#.#.###...###..#. -#...##.###......#.###..##.#.##. -...##.#.....#....#..#......#... -#....###.#..#...##.....#......# -........###...#...#............ -........#....#...#...#....#...# -#....#..#..#....#.#........#.#. -##...#.....#.#..........#..#..# -#.#...##.....#........#...#...# -##.#.#.......#...#..#.###....#. -.#.......#....##..##...#.....#. -#....#....#.....#.......#...... -.##.##.##...##...#.#.#..#..#... -#..#..#.##....#......##....###. -.......#.#.........#..##.#...## -.#..##...#....#.....#.......... -..#.#...#......#.#..#.......... -.##....#.#.#.##.......###...#.. -..##.#...#.#.#.#.......#..#.... -#..#.......#...#........#.....# -.....#.......#......###..#..... -...##.#.......#.....##.....##.. -##..#.......#.#.....#....#..... -..#....#.##.##...#...#......#.. -.#..#.###.#....###........#...# -....##.##...##..#..#.#....#.... -..###...##.....##.............. -#....#...##...#....#..........# -.##........#......##...##...#.# -..#.#.##..........#......#..... -...#...#.........#.##........## -..#.#..#.#..#...#....#...#..... -...##...#..#.###.#..#.#...#.... -....###........#..#..##...#.... -#.#....##.......#.#........#... -.###...#..#.#.#.#..#...#..##.## -..#.........#####.#......#..#.. -#.....#.....##..#....#...#...#. -...#..#....##....##.....##.#... -.........#............#.##..... -....##.#..#....#.##.......#..## -.###....#.#..#......#.#.......# -.###...###.#.........#.#..#...# -.....#........#..#.#..#.#..##.# -.###..#....##.........#..##.... -..#.......#..#..##...#.###.#... -#.......#...........#.#...#.### -#.##.##...##.#...##..#.....#... -..#..#........###.#.....##..... -#.....##....#...##...####..#..# -....#........#...#...#......... -......#.#.#.#.......#..#.....## -..#..#....#.....#.#...##......# -..#....#...#.###.........#.###. -...#......##..#.#.....#...#.... -...#.......#...#...#........##. -............#...#..#....#.....# -....##......................#.. -#.#.#....#....#..........##.... -#.#.....#.#.##..#...#.##....##. -...#...#..#...#..#.#.#.......#. -#.....#..........#.........##.# -#...##..#..#.#.......###....#.. -.#...#..##....#.....##.......#. -....#.##.....#.........#.#....# -........#.#...####..#.......#.# -.####...#.#......####.....#.##. -###..#....#..#.......#.#..##..# -#......#.#....##..#.##.#....#.# -...###...#...#..##.#..#..#.#... -...##..##....#..#.....#........ -.....#..............#......#..# -......#....#......#..#......... -#..#.....#.##...........##..... -.#..#.#..................##.... -#.#..#..##...#....#.#......#... -.##.#.##......#.##...#...#...#. -..#...#.........#.#..#.#....#.. -.#.####.#..#.#......##.#..#.... -#..#.......#....#.............. -....#............#..#.......... -.....#####.....#.....#..##...## -#.#....#.#...............#..##. -.#.#..#...#......#.....#.#.#... -.#....#.#.#......#.....##....#. -....#....#.##..#.......###...## -.....#..#.##...#...#...#..#.#.. -##..#........#.#..#..##......#. -.#..#..##.......#..#.....#..... -.#.#.....###..##.#.#........... -..##..##.####..........#..#.... -..##..#..#...#....#......#.#... -#...#.#......##.....##.#..###.. -#..#..............#........##.# -.........#.##..#.#..#..##.##.#. -#....##....#.#..#.#...##..#.... -.#....#.......#............##.. -.......#.#.......#...#.#......# -......##...#.......#.#........# -..###..#.#.##....##...#....##.. -..##.##..........##..###....... -.#.#.#..#..#.#.......#.#...##.. -..#..##.........#.###..#......# -....#.#.#...##.#...#...##..###. -..###..##.........##...#...#..# -.#..##...#.......#.......#..#.# -........##....##....#.#.###.#.# -#.....#.#.................#.#.. -....#.#.#.....##.####.#......#. -....#.......#.#.##.##.......... -...#...........#...#.##...#.### -#....#....#..........#.##...... -##..#...........##.....##.##... -.#.##...##..##....#..#.....#### -#...#...#.##..........##..##... -....##..#....#.....#.#...#....# -..#....#..##...###.#.#......... -#......#.#.#...#...#.........#. -#............###.#.#.#..##...#. -.##.....####...##..##..#..##.#. -#..#........#.....#.#.....#...# -#............#....#.#.#........ -......##...##.#....#.....#...#. -..#........##......#.#.....##.. -.#..#..#.....##.......#..#.#..# -.#....#..#....##.#.#.#..#..#.## -.####.#..........#...#..##..... -...###..###...##..#............ -#..#.....##.#...#..##..#....... -.....##....#...###.##...#...... -...##..#...#..#..##....##....#. -...###....#.###.#.#.##....#.... -##.#.#.....#....#.#....#..#.... -.......##.....#.#..##...##...#. -.#....#.#...##.#..#....#.....#. -..#...#..#...#.##........#...#. -#....#......##.#....##...#.#..# -.....#..#..#..#......#...#.#.#. -..###....#........#...#.......# -###...#.......#.#.......##.##.. -......##.....#.#........#....#. -#.##..#.#.#.#..#....#.##.....#. -..........#.##.#...#...#..#..#. -..#...##.#..........#..##.###.. -..###..##.##..#.#...##.####..#. -#.#.#...............##....###.# -....#.........#.#....#.#....#.# -..#...#.###...#....###.....#... -..#..#....#...#............#... -.#..#....#..##.....##.......... -..#....#.#...#.#.#.#.......##.# -.........#....##........#.#.... -...#..##.#..#.##...#...#.#....# -....####...#...####.#....###..# -......##...#.##.#.......#..#... -#.#...#.#...#.#...#....#.#.#... -.#.....##...#.....###.#....#... -......##.....###...#.#...#.#... -#..#..##.#.#......#....#..#..#. -....#.###.....#..#...#.##.....# -##.##........#......#....#..##. -##.....##.#.....#.....##.....#. -.....#.##...#.#..#.#.#.....#... -.#.##..#...#.#..#.....#.#...... -.....##.......#..#...##..#..#.. -#.....#..#.####......#........# -.#..#..##.#..##............#..# -.##..#.#....##.##.....#......#. -.......##.........#..#......... -.#...#.......................#. -#......#.#....##.#.......#..#.. -..##..##......#.......#....#.#. -##......#......##...##......... -..#....####....#.#.....##.#.#.. -..........#..#.#.#.....#..#.#.. -##..##...........##.......#.... -##....#.#....#..#......###....# -...#.#.#..#.......##.......#... -#....#.......#.......#......... -...##......##....#...#......#.# -#......#####.#.........#.....#. -#..#.............#..#....#...#. -.......#.##..#..#..#..#....#### -......#.##..##..........###...# -.#.##....###..#........#....##. -#......#..#...###.#...#.....#.. -.#.#.......#....##.......#.#... -..#.##..#..##.....#.........#.# -#.#...#..#.##....#.......##.... -.#.....###....#.#..#...#.....#. -#...#..#.......#.#.....##...#.# -#.#####.........#....##.....#.. -#....#..##...#....#.##.......#. -.#.#.........##....##....#..... -...#..##.......#....#.#.#...... -#.###.##...###....#.....#.####. -.#...#.#.#..##.#..........#.... -#.#.....#.##.#..####.....##.#.. -...###.##..####.......#......## -.##..#.........#...#.#.....#.## -..#.....##....###.....#.#...##. -#....#....#..#....#.##......... -......###....#.#..#..#....##... -.#.#................#.......##. -...#.......#.........#.#....... -...#..........#...##.....###... -....#......#...#............... -.##...#....#.....#.##......#... -.#.....###...##..##...#.#...... -....##........#.....#...#....#. -#.........#.#...##...#.#..#.... -...#.#.....#.#........#.#....#. -.#........#.....#.#.#.#.#..#... -....#...#.....#.#....#........# -..###.#....#.#....##...##..#.## -.#....#.#.####.#.#.....#....... -.#...#...#.................##.# -..................##..#..#.#.#. -.#..#............##....###..... -.......#....#...........#...... -....#.#.#.....###.........#..## -...#.#....#.#.##.#.##.....##..# -.#.##.#...##...#.......#.....## -.#............#...#..##...#.#.# -#.##..#.##..#..##.###.#........ -..............##....#...#..#.#. -.#.#...#.#....#....###........# -.#....#.#....#......###........ -..#.......##......#.##.....#... -.....#......#..#...#.#.....#... \ No newline at end of file -- cgit v1.2.3