Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- i=[list(x)for x in inputtt.split('\n')]
- r,c,s,q,e,w=(0,)*6
- # ->
- r=c=s=q=e=w=0
- o=lambda y,x:0<=x<len(i[0])and 0<=y<len(i)
- # ->
- o=lambda y,x:len(i[0])>x>=0<=y<len(i)
- d='\\/_|'
- # -> ('\/' == '\\/')
- d='\/_|'
- for l in i:
- if l.count('x'):r=i.index(l);c=l.index('x')
- for a,b in(1,0),(0,1),(-1,0),(0,-1):
- y,x=r+a,c+b;f=0
- if o(y,x):f=i[y][x]
- # -->
- y,x=r+a,c+b;f=o(y,x)and i[y][x]
- if f in d:s=f;w=d.index(f);q,e=y,x
- k=lambda y,x,g=[1,1,0,1][w],v=[1,-1,1,0][w]:o(y,x)and i[y][x]==s and(exec('i[y][x]=0')==0)+1+k(y+g,x+v)+k(y-g,x-v)
- # ->
- and exec('i[y][x]=0')or 1+k(y+g,x+v)+k(y-g,x-v)
- print(k(q,e))
Add Comment
Please, Sign In to add comment