2015 day 3 part 1

This commit is contained in:
Tristan 2018-11-30 13:28:56 +00:00
parent fd57f4c5b1
commit 88582d2e2b
2 changed files with 19 additions and 0 deletions

1
2015/3/input.txt Normal file

File diff suppressed because one or more lines are too long

18
2015/3/part1.py Normal file
View file

@ -0,0 +1,18 @@
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()