Created
December 14, 2015 11:22
-
-
Save TimCastelijns/36c9be24887d49d28797 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
visited = [(0, 0)] | |
with open('day3.txt', 'r') as f: | |
s = f.readline() | |
x, y = 0, 0 | |
for direction in s: | |
if direction == '>': | |
x += 1 | |
elif direction == '<': | |
x -= 1 | |
elif direction == '^': | |
y += 1 | |
elif direction == 'v': | |
y -= 1 | |
visited.append((x, y)) | |
print len(set(visited)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment