Guest User

Untitled

a guest
Jun 25th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.28 KB | None | 0 0
  1. #Input
  2. A = [1,2,0]
  3. #Output
  4. B = [[0,0,0],
  5. [1,0,0],
  6. [1,1,0],
  7. [1,2,0],
  8. [0,1,0],
  9. [0,2,0]]
  10.  
  11. >>> from itertools import product
  12. >>> A
  13. [1, 2, 0]
  14. >>> list(product(*[list(range(e+1)) for e in A]))
  15. [(0, 0, 0), (0, 1, 0), (0, 2, 0), (1, 0, 0), (1, 1, 0), (1, 2, 0)]
  16. >>>
Add Comment
Please, Sign In to add comment