Games & Quizzes
Don't forget to Sign In to save your points
This is a modal window.
PERFECT HITS | +NaN | |
HITS | +NaN | |
LONGEST STREAK | +NaN | |
TOTAL | + |
>> Let's get greedy.. In greedy, our job is to play the role of a greedy cashier.
The user will tell us how much change we owe them,. and then our job is to calculate the minimum number of coins
that we can use to make that amount of change.. >> Let's start with an example.. Say the user requires $0.32 back.. We could do this by giving them 32 pennies, one cent each.
Or I could also use five coins-- by giving them three dimes, $0.10 each,
and two pennies, $0.02 each.. But could we use even fewer coins to make that?. >> The whole tactic in greedy-- to be a greedy cashier--
is to use the largest coin possible.. So whenever we have quarters we'll use them.. And then once those run out, we'll use dimes, $0.10 each.
Then nickels, 5 cents each, and then down to pennies, one cent each.
By using the largest coin possible whenever we can,
we ensure that we use the fewest number of coins possible to make the change.
>> So let's walk this through.. The user needs $0.32..
/ˈkwôrdər/
each of four equal or corresponding parts into which something is or can be divided. 3-month period of time for businesses, etc.. divide into four equal or corresponding parts.
/(h)wenˈevər/
used for emphasis instead of 'when' in questions. at whatever time.
/əˈnəT͟Hər/
One more, but not this. used to refer to additional person or thing of same type as one. One more (thing).
/ˈminəməm/
smallest or lowest. least or smallest amount or quantity possible or required.