Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def recur(combs, ar):
- res = []
- for comb in combs:
- for x in ar:
- res.append(comb + [x])
- return res
- def gen_combs(ars):
- combs = [[]]
- for ar in ars:
- combs = recur(combs, ar)
- return combs
- def no_recur(ars):
- combs = [[]]
- for ar in ars:
- new_combs = []
- for comb in combs:
- for x in ar:
- new_combs.append(comb + [x])
- combs = new_combs
- return combs
- ars = [[1, 2, 3], [10, 20], [100, 200, 300]]
- print(gen_combs(ars))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement