Day 1: Part 2

This commit is contained in:
2025-12-01 23:44:56 +01:00
parent 94c5906232
commit f25ccf9b15
2 changed files with 4696 additions and 0 deletions

25
day1/main.py Normal file
View File

@@ -0,0 +1,25 @@
rotations = []
with open("day1/input.txt") as f:
lines = f.readlines()
for line in lines:
line = line.strip("\n")
dirrection, turns = str(line[0]), int(line[1::])
if dirrection == "R":
rotations.append(turns)
elif dirrection == "L":
rotations.append((-1)*turns)
else:
print("Something went wrong")
pointer = 50
count = 0
for r in rotations:
step = 1 if r > 0 else -1
for _ in range(abs(r)):
pointer = (pointer + step) % 100
if pointer == 0:
count += 1
print(count)