fork(1) download
  1. d={}
  2. s=input()
  3. n=len(s)**2
  4. p=0
  5. for c in s:d[p]=(p in d)and d[p]^1or 1;p=[p-1,p+1,p-n,p+n]["<>^v".index(c)]
  6. print(d)
  7. print(sum(v for k,v in d.items()))
Success #stdin #stdout 0.01s 9992KB
stdin
><><
stdout
{0: 1, 1: 1}
2