Guest User

Untitled

a guest
Apr 23rd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.45 KB | None | 0 0
  1. >>> list(itertools.product([0,1,2],[3,4,5]))
  2. [(0, 3), (0, 4), (0, 5), (1, 3), (1, 4), (1, 5), (2, 3), (2, 4), (2, 5)]
  3.  
  4. >>> my_product([0,1,2], [3,4,5])
  5. [(0, 3), # element 0 from both iterables
  6. (0, 4), (1, 3), # elements 0,1 and 1,0 (sums to 1)
  7. (0, 5), (1, 4), (2, 3), # elements 0,2 and 1,1 and 2,0 (sums to 2)
  8. (1, 5), (2, 4), # elements 1,2 and 2,1 (sums to 3)
  9. (2, 5)] # elements 2,2 (sums to 4)
Add Comment
Please, Sign In to add comment