From 84a8e32404b9d69dfd7cac127a1f7f6539dec443 Mon Sep 17 00:00:00 2001 From: Rokas Puzonas Date: Mon, 14 Dec 2020 21:44:41 +0200 Subject: [PATCH] Looked up solution for part 2 of day 13 --- 13/part2.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) create mode 100644 13/part2.py diff --git a/13/part2.py b/13/part2.py new file mode 100644 index 0000000..fdf5cd4 --- /dev/null +++ b/13/part2.py @@ -0,0 +1,16 @@ + +def getBuses(filename): + with open(filename, "r") as f: + f.readline() + return {i:int(x) for i, x in enumerate(f.readline().split(",")) if x != "x"} + +buses = getBuses("input.txt") +step = list(buses.values())[0] +t = step + +for dt, busId in buses.items(): + while (t + dt) % busId != 0: + t += step + step *= busId + +print(t) \ No newline at end of file