Problem 3027. Legend of Zelda - Rupee Count (Item Purchase)
Building off of Problem 3025, suppose that an array tracks counts for each type of rupee that Link gathers. Using the following rupee values, the total amount he has collected can be easily calculated:
- Green = 1
- Blue = 5
- Yellow = 10
- Red = 20
- Purple = 50
- Orange = 100
- Silver = 200
- Big green = 50
- Big blue = 100
- Big red = 200
- Big gold = 300
For example, [20,5,3,1,0,1,1,0,0,0,0] indicates that Link has gathered 20 green rupees (20*1 = 20), 5 blue rupees (5*5 = 25), 3 yellow rupees (3*10 = 30), and one each of red, orange, and silver (20, 100, and 200), for a total of 395.
Based on the total that he has collected, write a function to determine which item(s) he can purchase from the store. The correct answer should include the most expensive item he can purchase, followed by the next least expensive, etc., until he can't purchase anymore. The function should return a cell array of the items that Link purchased in addition to the number of rupees remaining after his shopping spree. The following items are available for purchase at the local Hyrule market:
- Hookshot - 3000 rupees
- Bow & Arrows - 1000 rupees
- Shield - 500 rupees
- Magic potion - 200 rupees
- Shovel - 100 rupees
- Bombs - 25 rupees
For example, if Link has 1714 rupees, he could purchase the Bow & Arrows, Shield, and Magic Potion, with 14 rupees to spare. Make sure to return the items in descending cost order in the cell array. Also, assume that he can only purchase one of each item.
Solution Stats
Problem Comments
Solution Comments
Show commentsProblem Recent Solvers36
Suggested Problems
-
1428 Solvers
-
550 Solvers
-
Return elements unique to either input
773 Solvers
-
1333 Solvers
-
Calculator spelling - Numbers to Letters
52 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!