Solve 13.1

This commit is contained in:
2021-05-09 16:20:03 +03:00
parent 5c985c7a49
commit 5ede0fe44d
2 changed files with 16 additions and 0 deletions
+14
View File
@@ -0,0 +1,14 @@
with open("input") as f:
t, buses = f.read().strip().split("\n")
t = int(t)
buses = buses.split(',')
first = map(int, filter(lambda x: x!='x', buses))
a, b = min((x-t%x, x) for x in first)
print(a*b)
# https://en.wikipedia.org/wiki/Chinese_remainder_theorem