This is probably straightforward but I'm new to this sort of programming and struggling to wrap my head around what I need to do.
I'm trying to build a list of filters to apply to an image. I have seven filters I can apply and each filter can either be 0
or 1
(on or off). The filters are:
filters = [
'Exposure',
'Noise',
'Pressure',
'XQ Mix',
'Invert',
'Desaturate',
'Equalise'
]
What I want to produce is every possible permutation of these filters in their states. There should be 128 possible permutations (2^7) but when I run the following code I get 5080 permutations:
perms = permutations(filters)
perm_count = 0
for p in perms:
print(p)
perm_count = perm_count + 1
print str(perm_count) + ' total permutations'
I'm likely using the wrong method – all this is doing is shuffling the sequence of filters, which I don't care about.
I tried updating the filter list to have two items for each filter, eg. ['Exposure0', 'Exposure1']
etc, but running combinations(filters, 7)
against this gives me duplicate values (eg. both on and off states in the same list).
I'm struggling here – can anyone give me a nudge in the right direction for approaching something like this? Looking in the docs, something like product('ABCD', 'xy') --> Ax Ay Bx By Cx Cy Dx Dy
seems along the right lines but I still can't wrap my head around it. Help appreciated.