aoc/2015/03/part1.py
2019-01-02 01:12:02 +00:00

22 lines
401 B
Python

import os
path = os.path.dirname(os.path.abspath(__file__))
with open(path+"/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()