input = open("input") t = 0 t2 = 0 dial = 50 for line in input: line = line.strip().replace("L","-").replace("R","") n = int(line) 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)