attempt 1

bram-benchmarks
Brechtje van Gessel 2025-12-01 17:06:32 +01:00
parent 0118bf9920
commit a11800d0d7
1 changed files with 21 additions and 0 deletions

21
brechtje/1/1-2.py Normal file
View File

@ -0,0 +1,21 @@
input = open("input.txt", "r").read().splitlines()
pos = 50
password = 0
for line in input:
if line.startswith('L'):
pos -= int(line[1:])
elif line.startswith('R'):
pos += int(line[1:])
# keep subtracting or adding 100 until position is between 0 and 99
while pos < 0 or pos > 99:
if pos < 0:
pos += 100
password += 1
elif pos > 99:
pos -= 100
password += 1
print(password)