aoc/2015/3/part1.py
2018-11-30 13:28:56 +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()