Created
July 17, 2016 21:06
-
-
Save vanryan/63506b5645b65d730d55ff2fb8d9910a to your computer and use it in GitHub Desktop.
Computes the cartesian product of input iterables using itertools
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| from itertools import product | |
| A = map(int,raw_input().split()) | |
| B = map(int,raw_input().split()) | |
| A.sort() | |
| B.sort() | |
| res = product(A, B) | |
| # you can also get res from | |
| # tmp = [A,B] | |
| # res = list(product(*tmp)) | |
| for i in res: | |
| print i, | |
| # you can print faster with: | |
| # print " ".join(map(str, res)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment