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:
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:
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.