2015 day 3 part 1
This commit is contained in:
parent
fd57f4c5b1
commit
88582d2e2b
1
2015/3/input.txt
Normal file
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
18
2015/3/part1.py
Normal 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()
|
||||
|
Loading…
Reference in a new issue