Question: A function recursively that takes a list and an int. It would check what combination of numbers on the would result in the lowest number.
A function recursively that takes a list and an int. It would check what combination of numbers on the would result in the lowest number. The numbers in the list can be used multiple times.
For example, helper([1,2,4], 15) would result in 0 because 4 + 4 + 4 + 2 + 1 = 15
Another example is
helper([63, 45, 50, 25, 21], 133)
This would result in 1 because 45 + 45 + 21 + 21 = 132
132 - 131 = 1
This is the body of the function, you can only fill up the missing spaces.
def helper(1st, money): # base case if ...: cur_min = money product = lst[0] tmp = money while ...: return
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
