Day 1: Part 2
This commit is contained in:
4671
day1/input.txt
Normal file
4671
day1/input.txt
Normal file
File diff suppressed because it is too large
Load Diff
25
day1/main.py
Normal file
25
day1/main.py
Normal 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)
|
||||
Reference in New Issue
Block a user