as an example I have numbers 0 and 255. I want combinations that would look like this
[[0, 0], [0, 255], [255, 0], [255, 255]]
my current code looks like this, where "a" is the list of numbers, it could be 2 or more.
def combinations(a):
if len(a) == 0:
return [[]]
final = []
for i in combinations(a[1:]):
final += [i, i+[a[0]]]
return final
but it instead gives this output [[], [0], [255], [255, 0]]
I am looking for a way to solve it recursively without using any libraries.