advent-of-code/py/aoc/y2018/d01.py
2022-12-06 15:18:08 +01:00

17 lines
392 B
Python

def find_repeat(freqs):
total = 0
found = {total}
while True:
for n in freqs:
total += n
if total in found:
return total
else:
found.add(total)
def solve(inputstr):
freqs = [int(freq) for freq in inputstr.splitlines()]
print(f"Part 1: {sum(freqs)}")
print(f"Part 2: {find_repeat(freqs)}")