2025 01
This commit is contained in:
parent
dd5e59433c
commit
0b6ef73f4b
1 changed files with 37 additions and 0 deletions
37
Python/2025/01/main.py
Normal file
37
Python/2025/01/main.py
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
input = open("input", 'r')
|
||||
|
||||
rotations = []
|
||||
|
||||
for i, line in enumerate(input):
|
||||
rotations.append((line[0], int(line[1:])))
|
||||
|
||||
password = 0
|
||||
password_CLICK = 0
|
||||
dial = 50
|
||||
|
||||
# print("The dial starts by pointing at", dial)
|
||||
for direction, length in rotations:
|
||||
clicks = length // 100
|
||||
length = length % 100
|
||||
length *= 1 if direction == "R" else -1
|
||||
|
||||
dial_new = dial + length
|
||||
|
||||
if (dial_new <= 0 < dial) or \
|
||||
(dial < 100 <= dial_new):
|
||||
clicks += 1
|
||||
|
||||
dial = dial_new % 100
|
||||
|
||||
password_CLICK += clicks
|
||||
if dial == 0:
|
||||
password += 1
|
||||
|
||||
# if clicks == 0:
|
||||
# print("The dial is rotated", length, "to point at", dial)
|
||||
# else:
|
||||
# print("The dial is rotated", length, "to point at", dial,
|
||||
# "| during this rotation, it points at 0:", clicks, "times")
|
||||
|
||||
print(password)
|
||||
print(password_CLICK)
|
||||
Loading…
Add table
Add a link
Reference in a new issue