solved day 1 part 2
parent
a11800d0d7
commit
325b32655a
|
|
@ -5,17 +5,17 @@ password = 0
|
||||||
|
|
||||||
for line in input:
|
for line in input:
|
||||||
if line.startswith('L'):
|
if line.startswith('L'):
|
||||||
pos -= int(line[1:])
|
for _ in range(int(line[1:])):
|
||||||
|
pos -= 1
|
||||||
|
if pos == -1:
|
||||||
|
pos = 99
|
||||||
|
elif pos == 0:
|
||||||
|
password += 1
|
||||||
elif line.startswith('R'):
|
elif line.startswith('R'):
|
||||||
pos += int(line[1:])
|
for _ in range(int(line[1:])):
|
||||||
|
pos += 1
|
||||||
# keep subtracting or adding 100 until position is between 0 and 99
|
if pos == 100:
|
||||||
while pos < 0 or pos > 99:
|
pos = 0
|
||||||
if pos < 0:
|
password += 1
|
||||||
pos += 100
|
|
||||||
password += 1
|
|
||||||
elif pos > 99:
|
|
||||||
pos -= 100
|
|
||||||
password += 1
|
|
||||||
|
|
||||||
print(password)
|
print(password)
|
||||||
Loading…
Reference in New Issue