diff --git a/day01/sol.py b/day01/sol.py index d44c3b1..608cc4f 100644 --- a/day01/sol.py +++ b/day01/sol.py @@ -1,13 +1,23 @@ input = open("input") t = 0 +t2 = 0 dial = 50 for line in input: line = line.strip().replace("L","-").replace("R","") n = int(line) - dial += n - dial %= 100 + sgn = n/abs(n) + # this is O(n) + # could do something fancier but + # none of the inputs are large enough + # for this to be a noticeable slowdown + for i in range(abs(n)): + dial += sgn + dial %= 100 + if dial == 0: + t2 += 1 if dial == 0: t += 1 print(t) +print(t2)