From the course: Fundamentals of Dynamic Programming
Unlock this course with a free trial
Join today to access over 22,600 courses taught by industry experts.
Breaking down the change-making problem into subproblems - Python Tutorial
From the course: Fundamentals of Dynamic Programming
Breaking down the change-making problem into subproblems
- [Instructor] Let's summarize our goal in the change making problem. We have some denominations of coins that we can use, using as many of each denomination as we want. We want to use the fewest total number of coins, to add up to our target. Here, the best option is to use three five cent coins and one one cent coin. In general, the greedy approach of picking the highest denomination doesn't always work. So what do we do instead? As is typical in dynamic programming problems, we have a choice. On one hand, we can say 12 cent coins are still on the table and we'll use a single 12 cent coin. Now, our target is only four cents and we still have all the same denominations available to us. Of course, we can't actually use another 12 cent coin after this, but that's a choice we can face later. On the other hand, we can choose to stop using 12 cent coins altogether. Now, we need to make 16 cents still. But our…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
Planting flowers in a flowerbox1m 56s
-
(Locked)
Breaking down the flowerbox problem into subproblems3m 27s
-
(Locked)
Solving the flowerbox problem in Python1m 19s
-
(Locked)
How many ways can you make change?1m 52s
-
(Locked)
Breaking down the change-making problem into subproblems4m 23s
-
(Locked)
Solving the change-making problem in Python2m 13s
-
-
-
-