Day 13 (reduce)
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
from functools import reduce
|
||||
from math import gcd
|
||||
|
||||
|
||||
@@ -20,9 +21,5 @@ def merge(a, b, x, y):
|
||||
|
||||
lines = [x.strip() for x in open("input.txt")]
|
||||
busses = ((int(x), -idx) for idx, x in enumerate(lines[1].split(',')) if x != 'x')
|
||||
|
||||
current = (1, 0)
|
||||
for bus in busses:
|
||||
current = merge(*current, *bus)
|
||||
|
||||
print(current[1])
|
||||
sequence = reduce(lambda fn, fm: merge(*fn, *fm), busses, (1, 0))
|
||||
print(sequence[1])
|
||||
|
||||
Reference in New Issue
Block a user