In my code below a list (coins) is given and from that list, it prints all the permutations of the sum of 3 numbers in coins that add up to 65.
However, in my opinion, it should also print the permutations of the numbers 30, 30, and 5:
(30, 30, 5)
(30, 5, 30)
(5, 30, 30)
Now it will only print:
(50, 10, 5)
(50, 5, 10)
(10, 50, 5)
(10, 5, 50)
(5, 50, 10)
(5, 10, 50)
My code:
coins = [50, 30, 10, 5]
from itertools import permutations
perm = permutations(coins, 3)
for i in list(perm):
if sum(i)==65:
print(i)
How can these permutations be included without just adding them to the code?