Merge Brechtje's branch into benchmark branch
commit
6a253d294c
|
|
@ -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.
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
@ -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)
|
||||
Loading…
Reference in New Issue