Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- G, J = [[1 if j < 2 else 0 for i in range(4)] for j in range(4)], 1
- def disp(g): print(" | ".join(map(lambda x: str(x), g)))
- def tour(J, G):
- list(map(disp, G))
- print('Tour de J ', J)
- a, b, c, d = tuple(map(lambda x: int(x), input('> ').split(' ')))
- dx, dy, sd = abs(a-c), abs(b-d), abs(a-c)+abs(b-d)
- 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)) \
- 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]==' '):
- G[b][a], G[d][c] = ' ', J
- else: tour(J, G)
- while sum(map(sum,[list(map(lambda x:0 if type(x)==str else x,G[i])) for i in range(4)]))>=2 and \
- sum(map(sum, [list(map(lambda x:0 if type(x)==str else not x,G[i])) for i in range(4)]))>=2:
- u, J = tour(J, G), int(not J)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement