You need to combine some small pieces of chocolate (1 ounce) and some large pieces of...

90.2K

Verified Solution

Question

Programming

You need to combine some small pieces of chocolate (1 ounce) andsome large pieces of chocolate (5 ounces) to make a goal. Assumingyou always use as many large pieces as possible, complete thefunction \"makeChocolate\" which returns the number of small piecesthat you will use. Return -1 if it is not possible. Be sure tocarefully test your code before submitting it. Make sure to answerin python coding for full credit.
For example, makeChocolate(4,1,9) returns 4 because you use 1 largepiece and 4 small pieces to get 9 ounces.
makeChocolate(4,1,10) returns -1 because 1 large and 4 small piecesare only 9 ounces, not enough to make 10 ounces.
makeChocolate(3,2,10) returns 0 because you would use 2 largepieces and 0 small pieces to make 10 ounces.

Answer & Explanation Solved by verified expert
4.2 Ratings (784 Votes)
function accepting small large pieces and total ouncesdef makeChocolatesmalllargeounceinfinite loopwhile1if large itself is sufficient to make    See Answer
Get Answers to Unlimited Questions

Join us to gain access to millions of questions and expert answers. Enjoy exclusive benefits tailored just for you!

Membership Benefits:
  • Unlimited Question Access with detailed Answers
  • Zin AI - 3 Million Words
  • 10 Dall-E 3 Images
  • 20 Plot Generations
  • Conversation with Dialogue Memory
  • No Ads, Ever!
  • Access to Our Best AI Platform: Flex AI - Your personal assistant for all your inquiries!
Become a Member

Other questions asked by students