advent-of-code/2020/13/solution1.py
2020-12-17 14:00:54 +01:00

23 lines
496 B
Python

import re
with open('input', 'r') as f:
arrival = int(f.readline())
buses = list(map(int, re.findall(r'[0-9]+', f.readline().strip())))
earliest = None
earliest_bus = None
print(f'{arrival=}')
for bus in buses:
wait = bus - arrival % bus
wait = 0 if wait == bus else wait
if earliest is None or wait < earliest:
earliest = wait
earliest_bus = bus
print(bus, wait)
print(f'{earliest=} {earliest_bus=}')
print('Solution')
print(earliest * earliest_bus)