I'm trying to create "make-change" that will return a ls of coins whose sum = the input, and it needs to contain the least number of coins possible. Ex: (make-change 99)
=> (quarter quarter quarter dime dime penny penny penny penny)
I'm trying to create "make-change" that will return a ls of coins whose sum = the input, and it needs to contain the least number of coins possible. Ex: (make-change 99)
=> (quarter quarter quarter dime dime penny penny penny penny)
Here's the lines along which
make-changeshould operate:consthe largest coin you can use onto the result of(make-change (- x value))wherevalueis the amount of the coin that you just used.You can tell this procedure will terminate, since the amount will become smaller and smaller via step 2 until it is finally amenable to concluding with step 1.