Merge Brechtje's branch into benchmark branch

bram-benchmarks
Bram 2025-12-01 23:43:42 +01:00
commit 6a253d294c
3 changed files with 44 additions and 0 deletions

1
.gitignore vendored
View File

@ -270,6 +270,7 @@ Cargo.lock
*.pdb
# ---> Custom files
brechtje/**/*.txt
# If your structure requires you to ignore certain files or folders,
# you may add them here.

22
brechtje/1/1-1.py Normal file
View File

@ -0,0 +1,22 @@
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
elif pos > 99:
pos -= 100
if pos == 0:
password += 1
print(password)

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'):
for _ in range(int(line[1:])):
pos -= 1
if pos == -1:
pos = 99
elif pos == 0:
password += 1
elif line.startswith('R'):
for _ in range(int(line[1:])):
pos += 1
if pos == 100:
pos = 0
password += 1
print(password)