day 1-1
This commit is contained in:
28
01/01-1.py
Normal file
28
01/01-1.py
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
#!/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}")
|
||||||
4317
01/input.txt
Normal file
4317
01/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
0
requirements.txt
Normal file
0
requirements.txt
Normal file
Reference in New Issue
Block a user