Hi, guys. I'm racking my brain trying to figure out a generic way to do what the following Python code does for lists of three lists. I could just be stressed out and lacking sleep, but I don't see a good way!
This correctly outputs:
but I need to do it for any complexity. Thoughts?
Code Select
possibles = ['ABCDE', '12345', 'XYZ']
def compute_paths(lst):
paths = []
for a in lst[0]:
for b in lst[1]:
for c in lst[2]:
paths.append([a, b, c])
return paths
for path in compute_paths(possibles):
print ''.join(path)
This correctly outputs:
Code Select
A1X
A1Y
A1Z
A2X
A2Y
...
E4Y
E4Z
E5X
E5Y
E5Z
but I need to do it for any complexity. Thoughts?