25 lines
588 B
Python
25 lines
588 B
Python
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) |