Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import numpy as np
- # %%
- n1 = np.array([0,1,1])
- n2 = np.array([0,1,0])
- n3 = np.array([1,0,1])
- n_diag_descending = np.diagonal([n1,n2,n3])
- n_diag_ascending = np.diagonal(np.fliplr([n1,n2,n3]))
- # %% Vertical sum
- vs = np.sum([n1,n2,n3], axis=0)
- # %% Horizontal sum
- hs = np.sum([n1,n2,n3], axis=1)
- # %% Diagonal sum descending
- dsd = np.sum([n_diag_descending])
- # %% Diagonal sum ascending
- dsa = np.sum([n_diag_ascending])
- # %%
- def winner(*args):
- vals = np.concatenate((args))
- print(vals)
- if 3 in vals:
- print('Player 1 win')
- elif 0 in vals:
- print('Player 0 win')
- else:
- print('No one won this round')
- winner(hs, vs, [dsd], [dsa])
- # %%
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement