Advertisement
Guest User

Untitled

a guest
May 25th, 2019
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.76 KB | None | 0 0
  1. G, J = [[1 if j < 2 else 0 for i in range(4)] for j in range(4)], 1
  2. def disp(g): print(" | ".join(map(lambda x: str(x), g)))
  3. def tour(J, G):
  4. list(map(disp, G))
  5. print('Tour de J ', J)
  6. a, b, c, d = tuple(map(lambda x: int(x), input('> ').split(' ')))
  7. dx, dy, sd = abs(a-c), abs(b-d), abs(a-c)+abs(b-d)
  8. if 0<=a<4 and 0<=b<4 and 0<=c<4 and 0<=d<4 and (((dx==0 and dy==2) or (dx==2 and dy==0)) \
  9. and G[(b+d)//2][(a+c)//2]==J and G[d][c]==int(not J)) or (sd==1 and G[b][a]==J and G[d][c]==' '):
  10. G[b][a], G[d][c] = ' ', J
  11. else: tour(J, G)
  12. while sum(map(sum,[list(map(lambda x:0 if type(x)==str else x,G[i])) for i in range(4)]))>=2 and \
  13. sum(map(sum, [list(map(lambda x:0 if type(x)==str else not x,G[i])) for i in range(4)]))>=2:
  14. u, J = tour(J, G), int(not J)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement