28 lines
682 B
Python
28 lines
682 B
Python
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
|
|
# file = "./ex.txt"
|
|
file = "./input.txt"
|
|
|
|
def turn_lock(direction:str, steps:int, pos:int) -> int:
|
|
if direction == "R":
|
|
pos += steps
|
|
while pos >= 100:
|
|
pos -= 100
|
|
else:
|
|
pos -= steps
|
|
while pos < 0:
|
|
pos += 100
|
|
return pos
|
|
|
|
if __name__ == "__main__":
|
|
solution, position = 0, 50
|
|
input_file = open(file, "r")
|
|
for line in input_file:
|
|
line = line.strip()
|
|
if line == "":
|
|
continue
|
|
position = turn_lock(line[0], int(line[1:]), position)
|
|
if position == 0:
|
|
solution += 1
|
|
print(f"The Password is: {solution}") |