Python Forum
Factoring input into listed frequencies
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Factoring input into listed frequencies
#3
You need a loop, starting with the amount and the coin counts (a list like [0, 0, 0, ..., 0]). Make it a while loop (while amount:). Each time through the loop, use the if clauses to figure out the largest coin that can still be used (the coin value is less than amount). Once you find that value, add one to the count for that coin, and subtract that coin value from amount.

There's a simpler way to do this without the if clauses, but let's see if you can get the if clauses working first.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply


Messages In This Thread
RE: Factoring input into listed frequencies - by ichabod801 - Nov-14-2018, 03:30 AM

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020