aoc/2015/03/part1.py

22 lines
401 B
Python
Raw Permalink Normal View History

2019-01-02 01:12:02 +00:00
import os
path = os.path.dirname(os.path.abspath(__file__))
with open(path+"/input.txt", "r") as commands:
2018-11-30 13:28:56 +00:00
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()