Algorithms & EmergenceAlgorithms
Greedy Change
Always giving the biggest coin usually works, until it doesn't
A cashier counts out your change biggest coin first. Does that always give you the fewest coins?
You'll find out
- Coins that fool the cashier's rule
- A coin trap from real money
- The way that can't be fooled
Why it matters
Grabbing the best-looking option is a shortcut many programs take: knowing when it fails is what keeps them right.
Play this lesson
Free to play in your browser or on iPhone