I’m trying to make a specific combination so that it adds up to "4" by adding the following specs:
a+a+a+a+a+a+a+a = 0.5 per/unit = (In total it sum:) 4
b+b+b+b = 1 per/unit = (In total it sum:) 4
c+c = 2 per/unit = (In total it sum:) 4
That way I want to know the result and print the combinations on the screen:
a+a+a+a+a+a+a+a = 4
a+a+a+a+a+a+b = 4
a+a+a+a+b+b = 4
a+a+b+b+b = 4
a+a+a+a+a+a+c = 4
a+a+b+c = 4
a+a+c+b = 4
b+a+a+a+a+a+a = 4
b+b+a+a+a+a = 4
b+b+b+a+a = 4
b+b+c = 4
b+c+a+a = 4
b+a+c = 4
b+c+a = 4
c+a+a+a+a = 4
c+b+a+a = 4
c+a+a+b = 4
My code:
from itertools import combinations
numbers=[2,4,8]
for c in combinations(numbers, 3):
print(c)
Is there a way to do it that specific way?
Thanks very much for readme.
Source: Windows Questions