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.

 A function recursively that takes a list and an int. It
The function takes a list, and an integer. it checks the best combination of elements that would reduce the given integer. Elements in the list can be used multiple times when we subtract them from the given integer. For example, helper([3,4,7,8], 66) would result in 2 because 8+8+8+8+8+8+8+8 = 64
66-64 = 2
there is no element that is less than 2 so it returns 2.

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

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!