day 1 part 2

This commit is contained in:
magical 2025-12-02 02:15:14 +00:00
parent 97bbeebeb0
commit 2e6bf3a11d

View File

@ -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)