You have n coins and each coin has an integral value. Your task is to count how many sums you can form using the coins.
For example, if the coins are [3,4,5], there are 7 possible sums: 3, 4, 5, 7, 8, 9 and 12. Notice that a sum must have at least one coin, i.e., an empty set is not counted.
You may assume that 1 \le n \le 100 and that each coin has a value in the range 1 \dots 100.
In a file coins.py
, implement a function count
that returns the number of possible sums.
def count(t): # TODO if __name__ == "__main__": print(count([3,4,5])) # 7 print(count([1,1,2])) # 4 print(count([2,2,2,3,3,3])) # 13 print(count([42,5,5,100,1,3,3,7])) # 91