aoc/2015/03/part1.py
2018-12-10 23:56:11 +00:00

19 lines
334 B
Python

with open("input.txt", "r") as commands:
x = 0
y = 0
history = []
for command in commands.readlines()[0]:
if command == ">":
x += 1
elif command == "<":
x -= 1
elif command == "^":
y += 1
elif command == "v":
y -= 1
if not [x, y] in history:
history.append([x, y])
print(len(history))
commands.close()