diff --git a/days/input/day10_input b/days/input/day10_input new file mode 100644 index 0000000..3eb93ec --- /dev/null +++ b/days/input/day10_input @@ -0,0 +1,36 @@ +#.....#...#.........###.#........#.. +....#......###..#.#.###....#......## +......#..###.......#.#.#.#..#....... +......#......#.#....#.##....##.#.#.# +...###.#.#.......#..#............... +....##...#..#....##....#...#.#...... +..##...#.###.....##....#.#..##.##... +..##....#.#......#.#...#.#...#.#.... +.#.##..##......##..#...#.....##...## +.......##.....#.....##..#..#..#..... +..#..#...#......#..##...#.#...#...## +......##.##.#.#.###....#.#..#......# +#..#.#...#.....#...#...####.#..#...# +...##...##.#..#.....####.#....##.... +.#....###.#...#....#..#......#...... +.##.#.#...#....##......#.....##...## +.....#....###...#.....#....#........ +...#...#....##..#.#......#.#.#...... +.#..###............#.#..#...####.##. +.#.###..#.....#......#..###....##..# +#......#.#.#.#.#.#...#.#.#....##.... +.#.....#.....#...##.#......#.#...#.. +...##..###.........##.........#..... +..#.#..#.#...#.....#.....#...###.#.. +.#..........#.......#....#.......... +...##..#..#...#..#...#......####.... +.#..#...##.##..##..###......#....... +.##.....#.......#..#...#..#.......#. +#.#.#..#..##..#..............#....## +..#....##......##.....#...#...##.... +.##..##..#.#..#.................#### +##.......#..#.#..##..#...#.......... +#..##...#.##.#.#.........#..#..#.... +.....#...#...#.#......#....#........ +....#......###.#..#......##.....#..# +#..#...##.........#.....##.....#.... \ No newline at end of file diff --git a/days/test_day10.py b/days/test_day10.py new file mode 100644 index 0000000..2cfc16b --- /dev/null +++ b/days/test_day10.py @@ -0,0 +1,25 @@ +from math import atan2 +import os +from typing import Tuple + + +inputfile = os.path.join(os.path.dirname(__file__), "input/day10_input") + + +def calc_arc(origin: Tuple[int, int], target: Tuple[int, int]) -> float: + return atan2(target[0] - origin[0], target[1] - origin[1]) + + +def test_day10a(): + with open(inputfile) as fp: + lines = [x.rstrip() for x in fp.readlines()] + asts = [(x, y) + for x, line in enumerate(lines) + for y, m in enumerate(line) + if m == '#'] + + max = 0 + for my in asts: + angles = {calc_arc(my, target) for target in asts} + max = len(angles) if len(angles) > max else max + assert max == 303