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 commentsGroup

Strings III
- 23 Problems
- 22 Finishers
- Reverse within string
- longest common semi-substring
- Cat, Meowcat and Concatenation
- Flip the bit
- Broken numlock key, oppps !
- Calculate the Damerau-Levenshtein distance between two strings.
- Find the longest match inside two strings
- Convert a vector into numbers
- Cat, Meowcat and Concatenation
- longest common semi-substring
- Genome decoding
- longest common substring : Skipped character version
- Concatenate string with cell array of strings
- Did you say please? - Find one string within another without strfind or regexp/regexpi
- Decrypt the cypher using XOR encryption (for beginners)
- Shorten pathname
- Beauty of Parentheses
- Adding Cells with numbers defined as strings
- From a given cell array of strings, extract the non-unique strings.
- Calculator spelling - Numbers to Letters
- Calculator spelling - Letters to Numbers
- Prime Letters = Removing
- Legend of Zelda - Rupee Count
- Legend of Zelda - Rupee Count (Compact)
- Legend of Zelda - Rupee Count (Item Purchase)
Problem Recent Solvers37
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!