Guest User

Untitled

a guest
Nov 21st, 2018
125
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.33 KB | None | 0 0
  1. import random
  2.  
  3. M,N=10,10
  4.  
  5. matrix=[[random.randrange(2) for y in range(M)] for x in range(N)]
  6.  
  7. In [35]: matrix
  8. Out[35]: [[0, 0, 1, 0], [0, 0, 1, 0], [1, 1, 0, 1], [0, 1, 0, 0]]
  9.  
  10. In [36]: from itertools import combinations
  11.  
  12. In [37]: [(i,j) for i,j in combinations(range(len(matrix)), 2) if matrix[i] == matrix[j]]
  13. Out[37]: [(0, 1)]
Add Comment
Please, Sign In to add comment