You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
AdventOfCode19/days/test_day10.py

25 lines
675 B

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