In what concerns the continuous evaluation solving exercises grade during the semester, you should submit until 23:59 of November 30th
(this exercise will still be available for submission after that deadline, but without counting towards your grade)
[to understand the context of this problem, you should read the class #07 exercise sheet]
In this problem you should submit a function as described. Inside the function do not print anything that was not asked!
Mr. Frond, the school guidance counselor, is working on a math exercise involving coins. He has a set of distinct coin values and wants to explore all possible ways to combine one, two or three coin values to form a sum. He needs to create a set of all unique possible sums that can be made by picking any single, pair oor triplet of coin values (possibly equal) from the given set.
Write a function possible_sums(coins) that given a set coins of integer coin values, creates a set with all distinct amounts that can be made by summing one, two or three coins from the set (possibly repeating some values).
The following limits are guaranteed in all the test cases that will be given to your program:
1 ≤ |coins| ≤ 10 | number of coins in the set |
Example Function Calls | Example Output |
sums = possible_sums({1,2,10}) print(type(sums)) print(sorted(list(sums))) |
<class 'set'> [1, 2, 3, 4, 5, 6, 10, 11, 12, 13, 14, 20, 21, 22, 30] |