Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #-*-coding:utf8;-*-
- print("AoC 2015 Day 3 Part 1")
- from collections import Counter
- Directions = '^><^>>>^<^v<v^^'
- x=0
- y=0
- movelst=[(0,0)]
- dirmap={
- '^':1,
- 'v': -1,
- '>' : 1,
- '<' : -1
- }
- def move(direction):
- global x, y
- if direction in "<>":
- x += dirmap[direction]
- else:
- y += dirmap[direction]
- movelst.append((x,y))
- for direction in Directions:
- move(direction)
- counts = dict(c for c in Counter(movelst).items())
- numhomes = len(counts)
- numstops = len(movelst)
- print(f"Santa made {numstops:,} stops at {numhomes:,} homes.")
- print ("Finished...")
Advertisement
Add Comment
Please, Sign In to add comment