I have two lists, both of the same length:
a = [1,2,3]
b = [4,5,6]
How can I get all possible results, from iterating over a
and either choosing to replace it with the corresponding element from b
, or not doing so?
output[0] = [1,2,3] # no replacements
output[1] = [4,2,3] # first item was replaced
output[2] = [1,5,3] # second item was replaced
output[3] = [1,2,6] # third item was replaced
output[4] = [4,5,3] # first and second items were replaced
output[5] = [4,2,6] # first and third items were replaced
output[6] = [1,5,6] # second and third items were replaced
output[7] = [4,5,6] # all items were replaced