Skip to content

Instantly share code, notes, and snippets.

@TimCastelijns
Created December 14, 2015 11:22
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TimCastelijns/36c9be24887d49d28797 to your computer and use it in GitHub Desktop.
Save TimCastelijns/36c9be24887d49d28797 to your computer and use it in GitHub Desktop.
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