You are given coin values and a sum . Find the maximum number of coins that sum up to .
You may assume that and that . One of the coin values is always . The algorithm should be efficient for all these cases.
In a file maxcoin.py
, implement a function find
that returns the desired count.
def find(x, coins): # TODO if __name__ == "__main__": print(find(5, [1, 2, 5])) # 5 print(find(10, [1])) # 10 print(find(8, [1, 2, 3, 4, 5])) # 8
Explanation: When and the coins are , the optimal solution is , which contains coins.