aoc2015/d03/part1.py

23 lines
230 B
Python

import sys
s = sys.stdin.read()[:-1]
cp = (0,0)
P = {cp}
dep = {
'<':(1,0),
'>':(-1,0),
'v':(0,1),
'^':(0,-1),
}
for c in s:
x,y = cp
dx,dy = dep[c]
cp = (x+dx,y+dy)
P.add(cp)
print(len(P))