solved day 1 part 1

bram-benchmarks
Brechtje van Gessel 2025-12-01 09:21:18 +01:00
parent 1030b26b31
commit 0118bf9920
1 changed files with 7 additions and 5 deletions

View File

@ -8,11 +8,13 @@ for line in input:
pos -= int(line[1:]) pos -= int(line[1:])
elif line.startswith('R'): elif line.startswith('R'):
pos += int(line[1:]) pos += int(line[1:])
if pos < 0: # keep subtracting or adding 100 until position is between 0 and 99
pos += 100 while pos < 0 or pos > 99:
elif pos > 99: if pos < 0:
pos -= 100 pos += 100
elif pos > 99:
pos -= 100
if pos == 0: if pos == 0:
password += 1 password += 1