{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":3026,"title":"Legend of Zelda - Rupee Count (Compact)","description":"Building off of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count Problem 3025\u003e, suppose that Link's rupee wallet will now provide a compact string with one letter designating each rupee he's picked up. Once again, the rupee denominations are (with abbreviating characters):\r\n\r\n* Green (g) = 1\r\n* Blue (b) = 5\r\n* Yellow (y) = 10\r\n* Red (r) = 20\r\n* Purple (p) = 50\r\n* Orange (o) = 100\r\n* Silver (s) = 200\r\n* Big green (G) = 50\r\n* Big blue (B) = 100\r\n* Big red (R) = 200\r\n* Big gold (*) = 300\r\n\r\nNote that the string will be case-sensitive. Write a function to return the total value of rupees that Link has accumulated provided the compact rupee string.","description_html":"\u003cp\u003eBuilding off of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count\"\u003eProblem 3025\u003c/a\u003e, suppose that Link's rupee wallet will now provide a compact string with one letter designating each rupee he's picked up. Once again, the rupee denominations are (with abbreviating characters):\u003c/p\u003e\u003cul\u003e\u003cli\u003eGreen (g) = 1\u003c/li\u003e\u003cli\u003eBlue (b) = 5\u003c/li\u003e\u003cli\u003eYellow (y) = 10\u003c/li\u003e\u003cli\u003eRed (r) = 20\u003c/li\u003e\u003cli\u003ePurple (p) = 50\u003c/li\u003e\u003cli\u003eOrange (o) = 100\u003c/li\u003e\u003cli\u003eSilver (s) = 200\u003c/li\u003e\u003cli\u003eBig green (G) = 50\u003c/li\u003e\u003cli\u003eBig blue (B) = 100\u003c/li\u003e\u003cli\u003eBig red (R) = 200\u003c/li\u003e\u003cli\u003eBig gold (*) = 300\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eNote that the string will be case-sensitive. Write a function to return the total value of rupees that Link has accumulated provided the compact rupee string.\u003c/p\u003e","function_template":"function [c] = rupee_count_compact(r_str)\r\n\r\nc = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nr_str = 'gbyrposGBR*';\r\nc_corr = 1036;\r\nassert(isequal(rupee_count_compact(r_str),c_corr));\r\n\r\n%%\r\nr_str = 'gggggggggggggggggggggggggggggggggggggggggggg';\r\nc_corr = 44;\r\nassert(isequal(rupee_count_compact(r_str),c_corr));\r\n\r\n%%\r\nr_str = 'gggbgggysgggrggggGygbog*gggyggbggrgggsbggbyGggbBggbgggysgggrggggbggrgggsbggbyGggbBgggGyggbggrgggsbggbyGggbBggrggggGygbog*gggyggbggrgggsbggbyGggbBggbggg';\r\nc_corr = 3196;\r\nassert(isequal(rupee_count_compact(r_str),c_corr));\r\n\r\n%%\r\nr_str = 'b';\r\nn_r = randi(100);\r\nfor i = 2:n_r\r\n\tr_str = strcat(r_str,'g');\r\nend\r\nc_corr = 5 + n_r - 1;\r\nassert(isequal(rupee_count_compact(r_str),c_corr));\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":77,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-18T03:55:06.000Z","updated_at":"2026-03-19T20:00:04.000Z","published_at":"2015-02-18T03:55:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBuilding off of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3025\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, suppose that Link's rupee wallet will now provide a compact string with one letter designating each rupee he's picked up. Once again, the rupee denominations are (with abbreviating characters):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGreen (g) = 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBlue (b) = 5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYellow (y) = 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRed (r) = 20\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePurple (p) = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOrange (o) = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSilver (s) = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig green (G) = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig blue (B) = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig red (R) = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig gold \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e(*\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) = 300\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote that the string will be case-sensitive. Write a function to return the total value of rupees that Link has accumulated provided the compact rupee string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":8045,"title":"Gold Standard","description":"Gold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at \u003chttp://measuringworth.com/gold/ Measuring Worth\u003e.\r\n\r\nFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\r\n\r\nAs an example, with HY = 2000 and HV = 1000:\r\n\r\n* GV(HY=2000) = $280.10\r\n* N = 1000/280.10 = 3.57 (ounces of gold)\r\n* CV = 3.57*1270 (current $/ounce of gold) = $4534.09.\r\n","description_html":"\u003cp\u003eGold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at \u003ca href = \"http://measuringworth.com/gold/\"\u003eMeasuring Worth\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGV(HY=2000) = $280.10\u003c/li\u003e\u003cli\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/li\u003e\u003cli\u003eCV = 3.57*1270 (current $/ounce of gold) = $4534.09.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_standard(HY,HV)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; CV_corr = 1270;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; CV_corr = NaN;\r\nassert(isnan(gold_standard(HY,HV)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; CV_corr = NaN;\r\nassert(isnan(gold_standard(HY,HV)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; CV_corr = 1035.04;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2005; HV = 1000; CV_corr = 2847.53;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2000; HV = 1000; CV_corr = 4534.09;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1995; HV = 1000; CV_corr = 3294.42;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1990; HV = 1000; CV_corr = 3299.3;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1950; HV = 1000; CV_corr = 36285.71;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1900; HV = 1000; CV_corr = 61441.7;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1850; HV = 1000; CV_corr = 61441.7;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1800; HV = 1000; CV_corr = 65497.68;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":"2015-03-30T16:49:21.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T15:58:58.000Z","updated_at":"2026-03-24T03:34:47.000Z","published_at":"2015-03-30T15:58:58.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://measuringworth.com/gold/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMeasuring Worth\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGV(HY=2000) = $280.10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = 3.57*1270 (current $/ounce of gold) = $4534.09.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3027,"title":"Legend of Zelda - Rupee Count (Item Purchase)","description":"Building off of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count Problem 3025\u003e, 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:\r\n\r\n* Green = 1\r\n* Blue = 5\r\n* Yellow = 10\r\n* Red = 20\r\n* Purple = 50\r\n* Orange = 100\r\n* Silver = 200\r\n* Big green = 50\r\n* Big blue = 100\r\n* Big red = 200\r\n* Big gold = 300\r\n\r\nFor 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.\r\n\r\nBased 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:\r\n\r\n* Hookshot - 3000 rupees\r\n* Bow \u0026 Arrows - 1000 rupees\r\n* Shield - 500 rupees\r\n* Magic potion - 200 rupees\r\n* Shovel - 100 rupees\r\n* Bombs - 25 rupees\r\n\r\nFor example, if Link has 1714 rupees, he could purchase the Bow \u0026 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.","description_html":"\u003cp\u003eBuilding off of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count\"\u003eProblem 3025\u003c/a\u003e, 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:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGreen = 1\u003c/li\u003e\u003cli\u003eBlue = 5\u003c/li\u003e\u003cli\u003eYellow = 10\u003c/li\u003e\u003cli\u003eRed = 20\u003c/li\u003e\u003cli\u003ePurple = 50\u003c/li\u003e\u003cli\u003eOrange = 100\u003c/li\u003e\u003cli\u003eSilver = 200\u003c/li\u003e\u003cli\u003eBig green = 50\u003c/li\u003e\u003cli\u003eBig blue = 100\u003c/li\u003e\u003cli\u003eBig red = 200\u003c/li\u003e\u003cli\u003eBig gold = 300\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 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.\u003c/p\u003e\u003cp\u003eBased 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:\u003c/p\u003e\u003cul\u003e\u003cli\u003eHookshot - 3000 rupees\u003c/li\u003e\u003cli\u003eBow \u0026 Arrows - 1000 rupees\u003c/li\u003e\u003cli\u003eShield - 500 rupees\u003c/li\u003e\u003cli\u003eMagic potion - 200 rupees\u003c/li\u003e\u003cli\u003eShovel - 100 rupees\u003c/li\u003e\u003cli\u003eBombs - 25 rupees\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor example, if Link has 1714 rupees, he could purchase the Bow \u0026 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.\u003c/p\u003e","function_template":"function [i_arr,r_rem] = rupee_count_items(r)\r\n\r\nr_ref = [1,5,10,20,50,100,200,50,100,200,300];\r\ni_ref = {'Hookshot','Bow \u0026 Arrows','Shield','Magic potion','Shovel','Bombs'};\r\n\r\ni_arr = {''};\r\nr_rem = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nr = [20,5,3,1,0,1,1,0,0,0,0];\r\ni_arr_corr = {'Magic potion','Shovel','Bombs'};\r\nr_rem_corr = 70;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [4,0,1,0,0,0,0,0,0,1,5];\r\ni_arr_corr = {'Bow \u0026 Arrows','Shield','Magic potion'};\r\nr_rem_corr = 14;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [194,27,13,5,3,2,1,0,1,0,1];\r\ni_arr_corr = {'Bow \u0026 Arrows','Shield'};\r\nr_rem_corr = 9;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [254,94,23,11,15,4,7,3,2,0,1];\r\ni_arr_corr = {'Hookshot','Bow \u0026 Arrows','Magic potion','Shovel','Bombs'};\r\nr_rem_corr = 49;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [255,94,24,13,15,4,7,3,2,2,1];\r\ni_arr_corr = {'Hookshot','Bow \u0026 Arrows','Shield','Magic potion','Shovel','Bombs'};\r\nr_rem_corr = 0;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [27,2,1,0,0,0,0,0,0,0,0];\r\ni_arr_corr = {'Bombs'};\r\nr_rem_corr = 22;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n\r\n%%\r\nr_ind = randi(21);\r\nr = [r_ind,2,2,1,1,0,0,0,0,0,0];\r\ni_arr_corr = {'Shovel'};\r\nr_rem_corr = r_ind;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-18T04:30:11.000Z","updated_at":"2026-03-19T20:01:40.000Z","published_at":"2015-02-18T04:30:11.000Z","restored_at":"2017-09-28T06:14:56.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBuilding off of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3025\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, 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:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGreen = 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBlue = 5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYellow = 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRed = 20\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePurple = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOrange = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSilver = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig green = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig blue = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig red = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig gold = 300\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased 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:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHookshot - 3000 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBow \u0026amp; Arrows - 1000 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eShield - 500 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMagic potion - 200 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eShovel - 100 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBombs - 25 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if Link has 1714 rupees, he could purchase the Bow \u0026amp; 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3025,"title":"Legend of Zelda - Rupee Count","description":"Rupees are the main currency in The Legend of Zelda games. The value of each rupee is determined by its color. Unfortunately, the rupee denomenations are somewhat different across the games. For the purposes of this problem, we'll assume the following values:\r\n\r\n* Green = 1\r\n* Blue = 5\r\n* Yellow = 10\r\n* Red = 20\r\n* Purple = 50\r\n* Orange = 100\r\n* Silver = 200\r\n* Big green = 50\r\n* Big blue = 100\r\n* Big red = 200\r\n* Big gold = 300\r\n\r\nYou'll be provided a cell array of strings indicating the rupees that Link has picked up in his recent adventures. Write a function to return the total value of rupees that he has accumulated in his wallet.\r\n\r\nThis problem is related to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3026-zelda-rupee-count-compact Problem 3026\u003e and \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3027-zelda-rupee-count-item-purchase Problem 3027\u003e.","description_html":"\u003cp\u003eRupees are the main currency in The Legend of Zelda games. The value of each rupee is determined by its color. Unfortunately, the rupee denomenations are somewhat different across the games. For the purposes of this problem, we'll assume the following values:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGreen = 1\u003c/li\u003e\u003cli\u003eBlue = 5\u003c/li\u003e\u003cli\u003eYellow = 10\u003c/li\u003e\u003cli\u003eRed = 20\u003c/li\u003e\u003cli\u003ePurple = 50\u003c/li\u003e\u003cli\u003eOrange = 100\u003c/li\u003e\u003cli\u003eSilver = 200\u003c/li\u003e\u003cli\u003eBig green = 50\u003c/li\u003e\u003cli\u003eBig blue = 100\u003c/li\u003e\u003cli\u003eBig red = 200\u003c/li\u003e\u003cli\u003eBig gold = 300\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou'll be provided a cell array of strings indicating the rupees that Link has picked up in his recent adventures. Write a function to return the total value of rupees that he has accumulated in his wallet.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3026-zelda-rupee-count-compact\"\u003eProblem 3026\u003c/a\u003e and \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3027-zelda-rupee-count-item-purchase\"\u003eProblem 3027\u003c/a\u003e.\u003c/p\u003e","function_template":"function [c] = rupee_count(r_arr)\r\n\r\nc = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nr_arr = {'Green','Blue','Yellow','Red','Purple','Orange','Silver','Big green','Big blue','Big red','Big gold'};\r\nc_corr = 1036;\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n\r\n%%\r\nr_arr = {'Green','Blue','Yellow','Green','Green','Green','Green','Red','Green','Green','Green','Blue','Blue','Yellow','Yellow','Green','Green','Blue','Green','Blue','Yellow','Green','Green','Blue','Green','Blue','Green','Green'};\r\nc_corr = 111;\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n\r\n%%\r\nr_arr = {'Green','Blue','Yellow','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Yellow'};\r\nc_corr = 44;\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n\r\n%%\r\nr_arr = {'Green','Big green','Big blue','Red','Silver'};\r\nc_corr = 371;\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n\r\n%%\r\nr_ref = {'Green','Blue','Yellow','Red','Purple','Orange','Silver','Big green','Big blue','Big red','Big gold'};\r\nr_v = [1,5,10,20,50,100,200,50,100,200,300];\r\nc_corr = 5;\r\nn_r = randi(100);\r\nr_arr{1} = 'Blue';\r\nfor i = 2:n_r\r\n\tind_r = randi(11);\r\n\tr_arr{i} = r_ref{ind_r};\r\n\tc_corr = c_corr + r_v(ind_r);\r\nend\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":72,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-18T03:36:32.000Z","updated_at":"2026-03-19T20:02:15.000Z","published_at":"2015-02-18T03:36:32.000Z","restored_at":"2017-09-28T06:14:47.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRupees are the main currency in The Legend of Zelda games. The value of each rupee is determined by its color. Unfortunately, the rupee denomenations are somewhat different across the games. For the purposes of this problem, we'll assume the following values:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGreen = 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBlue = 5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYellow = 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRed = 20\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePurple = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOrange = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSilver = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig green = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig blue = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig red = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig gold = 300\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou'll be provided a cell array of strings indicating the rupees that Link has picked up in his recent adventures. Write a function to return the total value of rupees that he has accumulated in his wallet.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3026-zelda-rupee-count-compact\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3026\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3027-zelda-rupee-count-item-purchase\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3027\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":8046,"title":"Gold/Silver Standard","description":"Pursuant to the \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard Gold Standard\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from \u003chttp://measuringworth.com/gold/ Measuring Worth\u003e.\r\n\r\nFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\r\n\r\nAs an example, with HY = 2000 and HV = 1000:\r\n\r\n* GV(HY=2000) = $280.10\r\n* N = 1000/280.10 = 3.57 (ounces of gold)\r\n* SR(HY=2000) = 55.96\r\n* NS = 55.96*3.57 = 199.79 (ounces of silver)\r\n* NG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\r\n* CV = 3.01*1270 (current $/ounce of gold) = $3822.36.","description_html":"\u003cp\u003ePursuant to the \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\"\u003eGold Standard\u003c/a\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from \u003ca href = \"http://measuringworth.com/gold/\"\u003eMeasuring Worth\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGV(HY=2000) = $280.10\u003c/li\u003e\u003cli\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/li\u003e\u003cli\u003eSR(HY=2000) = 55.96\u003c/li\u003e\u003cli\u003eNS = 55.96*3.57 = 199.79 (ounces of silver)\u003c/li\u003e\u003cli\u003eNG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\u003c/li\u003e\u003cli\u003eCV = 3.01*1270 (current $/ounce of gold) = $3822.36.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_silver_standard(HY,HV)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\nSR = [15.05, 15.17, 15, 15.37, 15.55, 15.65, 15.41, 15.59, 15.74, 15.68, 15.46, 15.26, 15.41, 15.41, 15.79, 15.52, 15.43, 16.08, 15.96, 15.77, 15.53, 16.11, 16.25, 15.04, 15.26, 15.28, 15.11, 15.35, 15.33, 15.62, 15.95, 15.8, 15.84, 15.82, 15.7, 15.76, 15.74, 15.78, 15.78, 15.82, 15.72, 15.73, 15.93, 15.73, 15.8, 15.72, 15.83, 15.85, 15.62, 15.62, 15.7, 15.87, 15.93, 15.85, 15.92, 15.9, 15.8, 15.85, 15.78, 15.7, 15.46, 15.59, 15.33, 15.33, 15.38, 15.38, 15.27, 15.38, 15.19, 15.29, 15.5, 15.35, 15.37, 15.37, 15.44, 15.43, 15.57, 15.59, 15.6, 15.57, 15.57, 15.63, 15.93, 16.16, 16.64, 17.75, 17.2, 17.92, 18.39, 18.05, 18.25, 18.2, 18.64, 18.61, 19.41, 20.78, 21.1, 22, 22.1, 19.75, 20.92, 23.72, 26.49, 32.56, 31.6, 30.59, 34.2, 35.03, 34.36, 33.33, 34.68, 39.15, 38.1, 35.7, 33.87, 30.54, 31.24, 38.64, 39.74, 38.22, 38.33, 33.62, 34.19, 37.37, 40.48, 30.78, 24.61, 21, 18.44, 20.28, 32.76, 30.43, 31.69, 30.8, 29.78, 33.11, 36.47, 35.34, 38.78, 53.74, 71.25, 73.29, 69.83, 72.36, 54.19, 77.09, 77.44, 80.39, 88.84, 99.76, 99.73, 90.57, 77.67, 77.67, 67.4, 43.67, 48.73, 47.07, 48.61, 47.14, 39.12, 41.16, 41.04, 41.01, 39.24, 38.5, 38.5, 39.27, 38.34, 38.27, 37.82, 32.22, 27.34, 27.04, 27.04, 27.04, 22.56, 18.29, 23.16, 20.54, 26.66, 34.75, 38.21, 33.9, 36.51, 28.76, 32.05, 35.8, 27.69, 29.66, 43.65, 47.24, 37.03, 44.26, 51.68, 67.25, 63.84, 66.95, 69.49, 79.78, 89.83, 87.47, 83.85, 72.79, 74.78, 74.89, 67.91, 53.24, 53.26, 55.96, 61.95, 67.32, 74.22, 61.3, 60.7, 52.2, 51.91, 58.17, 66.27, 60.64, 44.75, 53.58, 59.31, 66.38];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; CV_corr = 1270;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; CV_corr = NaN;\r\nassert(isnan(gold_silver_standard(HY,HV)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; CV_corr = NaN;\r\nassert(isnan(gold_silver_standard(HY,HV)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; CV_corr = 945.54;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2005; HV = 1000; CV_corr = 2603.88;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2000; HV = 1000; CV_corr = 3822.36;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1995; HV = 1000; CV_corr = 3711.31;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1990; HV = 1000; CV_corr = 3965.32;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1950; HV = 1000; CV_corr = 25768.43;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1900; HV = 1000; CV_corr = 30850.44;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1850; HV = 1000; CV_corr = 14532.01;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1800; HV = 1000; CV_corr = 15471.58;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 2000; HV = 1000; CV_corr = 3822.36;\r\n\tcase 2\r\n\t\tHY = 1995; HV = 1000; CV_corr = 3711.31;\r\n\tcase 3\r\n\t\tHY = 2005; HV = 1000; CV_corr = 2603.88;\r\n\tcase 4\r\n\t\tHY = 1800; HV = 1000; CV_corr = 15471.58;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 1995; HV = 1000; CV_corr = 3711.31;\r\n\tcase 2\r\n\t\tHY = 1990; HV = 1000; CV_corr = 3965.32;\r\n\tcase 3\r\n\t\tHY = 2010; HV = 1000; CV_corr = 945.54;\r\n\tcase 4\r\n\t\tHY = 1900; HV = 1000; CV_corr = 30850.44;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 1990; HV = 1000; CV_corr = 3965.32;\r\n\tcase 2\r\n\t\tHY = 1950; HV = 1000; CV_corr = 25768.43;\r\n\tcase 3\r\n\t\tHY = 1900; HV = 1000; CV_corr = 30850.44;\r\n\tcase 4\r\n\t\tHY = 2000; HV = 1000; CV_corr = 3822.36;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2015-03-30T16:51:28.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T16:22:04.000Z","updated_at":"2026-03-27T06:19:08.000Z","published_at":"2015-03-30T16:22:04.000Z","restored_at":"2017-07-28T15:24:51.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePursuant to the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://measuringworth.com/gold/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMeasuring Worth\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGV(HY=2000) = $280.10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSR(HY=2000) = 55.96\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNS = 55.96*3.57 = 199.79 (ounces of silver)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = 3.01*1270 (current $/ounce of gold) = $3822.36.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":8047,"title":"Weighted Gold/Silver Standard","description":"Building off of the \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard Gold Standard\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard Gold/Silver Standard\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\r\n\r\nFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\r\n\r\nAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\r\n\r\n* CVG = $4534.09 (gold standard)\r\n* CVS = $3822.36 (silver standard)\r\n* CV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.","description_html":"\u003cp\u003eBuilding off of the \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\"\u003eGold Standard\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard\"\u003eGold/Silver Standard\u003c/a\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\u003c/p\u003e\u003cp\u003eFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\u003c/p\u003e\u003cul\u003e\u003cli\u003eCVG = $4534.09 (gold standard)\u003c/li\u003e\u003cli\u003eCVS = $3822.36 (silver standard)\u003c/li\u003e\u003cli\u003eCV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_silver_weighted_standard(HY,HV,wt)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\nSR = [15.05, 15.17, 15, 15.37, 15.55, 15.65, 15.41, 15.59, 15.74, 15.68, 15.46, 15.26, 15.41, 15.41, 15.79, 15.52, 15.43, 16.08, 15.96, 15.77, 15.53, 16.11, 16.25, 15.04, 15.26, 15.28, 15.11, 15.35, 15.33, 15.62, 15.95, 15.8, 15.84, 15.82, 15.7, 15.76, 15.74, 15.78, 15.78, 15.82, 15.72, 15.73, 15.93, 15.73, 15.8, 15.72, 15.83, 15.85, 15.62, 15.62, 15.7, 15.87, 15.93, 15.85, 15.92, 15.9, 15.8, 15.85, 15.78, 15.7, 15.46, 15.59, 15.33, 15.33, 15.38, 15.38, 15.27, 15.38, 15.19, 15.29, 15.5, 15.35, 15.37, 15.37, 15.44, 15.43, 15.57, 15.59, 15.6, 15.57, 15.57, 15.63, 15.93, 16.16, 16.64, 17.75, 17.2, 17.92, 18.39, 18.05, 18.25, 18.2, 18.64, 18.61, 19.41, 20.78, 21.1, 22, 22.1, 19.75, 20.92, 23.72, 26.49, 32.56, 31.6, 30.59, 34.2, 35.03, 34.36, 33.33, 34.68, 39.15, 38.1, 35.7, 33.87, 30.54, 31.24, 38.64, 39.74, 38.22, 38.33, 33.62, 34.19, 37.37, 40.48, 30.78, 24.61, 21, 18.44, 20.28, 32.76, 30.43, 31.69, 30.8, 29.78, 33.11, 36.47, 35.34, 38.78, 53.74, 71.25, 73.29, 69.83, 72.36, 54.19, 77.09, 77.44, 80.39, 88.84, 99.76, 99.73, 90.57, 77.67, 77.67, 67.4, 43.67, 48.73, 47.07, 48.61, 47.14, 39.12, 41.16, 41.04, 41.01, 39.24, 38.5, 38.5, 39.27, 38.34, 38.27, 37.82, 32.22, 27.34, 27.04, 27.04, 27.04, 22.56, 18.29, 23.16, 20.54, 26.66, 34.75, 38.21, 33.9, 36.51, 28.76, 32.05, 35.8, 27.69, 29.66, 43.65, 47.24, 37.03, 44.26, 51.68, 67.25, 63.84, 66.95, 69.49, 79.78, 89.83, 87.47, 83.85, 72.79, 74.78, 74.89, 67.91, 53.24, 53.26, 55.96, 61.95, 67.32, 74.22, 61.3, 60.7, 52.2, 51.91, 58.17, 66.27, 60.64, 44.75, 53.58, 59.31, 66.38];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; wt = 0.5; CV_corr = 1270;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; wt = 0.5; CV_corr = NaN;\r\nassert(isnan(gold_silver_weighted_standard(HY,HV,wt)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; wt = 0.5; CV_corr = NaN;\r\nassert(isnan(gold_silver_weighted_standard(HY,HV,wt)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; wt = 0.5; CV_corr = 990.29;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2005; HV = 1000; wt = 0.5; CV_corr = 2725.7;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2000; HV = 1000; wt = 0.5; CV_corr = 4178.23;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1995; HV = 1000; wt = 0.5; CV_corr = 3502.87;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1990; HV = 1000; wt = 0.5; CV_corr = 3632.31;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1950; HV = 1000; wt = 0.5; CV_corr = 31027.07;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1900; HV = 1000; wt = 0.5; CV_corr = 46146.07;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1850; HV = 1000; wt = 0.5; CV_corr = 37986.86;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1800; HV = 1000; wt = 0.5; CV_corr = 40484.63;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2000; HV = 1000;\r\nwt = randi(10)/10;\r\nswitch (wt*10)\r\n\tcase 0\r\n\t\tCV_corr = 4534.09;\r\n\tcase 1\r\n\t\tCV_corr = 4462.92;\r\n\tcase 2\r\n\t\tCV_corr = 4391.75;\r\n\tcase 3\r\n\t\tCV_corr = 4320.57;\r\n\tcase 4\r\n\t\tCV_corr = 4249.4;\r\n\tcase 5\r\n\t\tCV_corr = 4178.23;\r\n\tcase 6\r\n\t\tCV_corr = 4107.05;\r\n\tcase 7\r\n\t\tCV_corr = 4035.88;\r\n\tcase 8\r\n\t\tCV_corr = 3964.7;\r\n\tcase 9\r\n\t\tCV_corr = 3893.53;\r\n\tcase 10\r\n\t\tCV_corr = 3822.36;\r\nend\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1800; HV = 1000;\r\nwt = randi(10)/10;\r\nswitch (wt*10)\r\n\tcase 0\r\n\t\tCV_corr = 65497.68;\r\n\tcase 1\r\n\t\tCV_corr = 60495.07;\r\n\tcase 2\r\n\t\tCV_corr = 55492.46;\r\n\tcase 3\r\n\t\tCV_corr = 50489.85;\r\n\tcase 4\r\n\t\tCV_corr = 45487.24;\r\n\tcase 5\r\n\t\tCV_corr = 40484.63;\r\n\tcase 6\r\n\t\tCV_corr = 35482.02;\r\n\tcase 7\r\n\t\tCV_corr = 30479.41;\r\n\tcase 8\r\n\t\tCV_corr = 25476.8;\r\n\tcase 9\r\n\t\tCV_corr = 20474.19;\r\n\tcase 10\r\n\t\tCV_corr = 15471.58;\r\nend\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":50,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T16:47:31.000Z","updated_at":"2026-03-27T06:22:48.000Z","published_at":"2015-03-30T16:47:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBuilding off of the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold/Silver Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCVG = $4534.09 (gold standard)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCVS = $3822.36 (silver standard)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":48,"title":"Making change","description":"Given an amount of currency, return a vector of this form:\r\n [100 50 20 10 5 2 1 0.5 0.25 0.1 0.05 0.01]\r\nExample:\r\n Input a = 257.68\r\n Output b is [2 1 0 0 1 1 0 1 0 1 1 3]\r\nAlways use bigger bills/coins if possible.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 164.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 82.15px; transform-origin: 407px 82.15px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 180.5px 8px; transform-origin: 180.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven an amount of currency, return a vector of this form:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 176px 8.5px; tab-size: 4; transform-origin: 176px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e [100 50 20 10 5 2 1 0.5 0.25 0.1 0.05 0.01]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 68px 8.5px; tab-size: 4; transform-origin: 68px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 28px 8.5px; transform-origin: 28px 8.5px; \"\u003e Input \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 40px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 40px 8.5px; \"\u003ea = 257.68\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 120px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 120px 8.5px; \"\u003eb is [2 1 0 0 1 1 0 1 0 1 1 3]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 125px 8px; transform-origin: 125px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAlways use bigger bills/coins if possible.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function b = makingChange(a)","test_suite":"%%\r\na = [257.68];  \r\n \r\nb = [2 1 0 0 1 1 0 1 0 1 1 3];\r\nout = makingChange(a);\r\nassert(isequal(out(:), b(:)))\r\n\r\n%%\r\na = [135.01];  \r\n \r\nb = [1 0 1 1 1 0 0 0 0 0 0 1];\r\nout = makingChange(a);\r\nassert(isequal(out(:), b(:)))\r\n\r\n%%\r\na = [10035.99];  \r\n \r\nb = [100 0 1 1 1 0 0 1 1 2 0 4];\r\nout = makingChange(a);\r\nassert(isequal(out(:), b(:)))\r\n\r\n%%\r\na = 420;  \r\n \r\nb = [4 0 1 0 0 0 0 0 0 0 0 0];\r\nout = makingChange(a);\r\nassert(isequal(out(:), b(:)))\r\n\r\n%%\r\na = 0;  \r\n \r\nout = makingChange(a);\r\nassert(isequal(out,zeros(1,12)))\r\n","published":true,"deleted":false,"likes_count":20,"comments_count":9,"created_by":1,"edited_by":223089,"edited_at":"2023-06-24T10:25:06.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3484,"test_suite_updated_at":"2023-06-24T10:25:06.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:24.000Z","updated_at":"2026-02-25T14:05:04.000Z","published_at":"2012-01-18T01:00:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an amount of currency, return a vector of this form:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [100 50 20 10 5 2 1 0.5 0.25 0.1 0.05 0.01]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input a = 257.68\\n Output b is [2 1 0 0 1 1 0 1 0 1 1 3]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAlways use bigger bills/coins if possible.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":3026,"title":"Legend of Zelda - Rupee Count (Compact)","description":"Building off of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count Problem 3025\u003e, suppose that Link's rupee wallet will now provide a compact string with one letter designating each rupee he's picked up. Once again, the rupee denominations are (with abbreviating characters):\r\n\r\n* Green (g) = 1\r\n* Blue (b) = 5\r\n* Yellow (y) = 10\r\n* Red (r) = 20\r\n* Purple (p) = 50\r\n* Orange (o) = 100\r\n* Silver (s) = 200\r\n* Big green (G) = 50\r\n* Big blue (B) = 100\r\n* Big red (R) = 200\r\n* Big gold (*) = 300\r\n\r\nNote that the string will be case-sensitive. Write a function to return the total value of rupees that Link has accumulated provided the compact rupee string.","description_html":"\u003cp\u003eBuilding off of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count\"\u003eProblem 3025\u003c/a\u003e, suppose that Link's rupee wallet will now provide a compact string with one letter designating each rupee he's picked up. Once again, the rupee denominations are (with abbreviating characters):\u003c/p\u003e\u003cul\u003e\u003cli\u003eGreen (g) = 1\u003c/li\u003e\u003cli\u003eBlue (b) = 5\u003c/li\u003e\u003cli\u003eYellow (y) = 10\u003c/li\u003e\u003cli\u003eRed (r) = 20\u003c/li\u003e\u003cli\u003ePurple (p) = 50\u003c/li\u003e\u003cli\u003eOrange (o) = 100\u003c/li\u003e\u003cli\u003eSilver (s) = 200\u003c/li\u003e\u003cli\u003eBig green (G) = 50\u003c/li\u003e\u003cli\u003eBig blue (B) = 100\u003c/li\u003e\u003cli\u003eBig red (R) = 200\u003c/li\u003e\u003cli\u003eBig gold (*) = 300\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eNote that the string will be case-sensitive. Write a function to return the total value of rupees that Link has accumulated provided the compact rupee string.\u003c/p\u003e","function_template":"function [c] = rupee_count_compact(r_str)\r\n\r\nc = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nr_str = 'gbyrposGBR*';\r\nc_corr = 1036;\r\nassert(isequal(rupee_count_compact(r_str),c_corr));\r\n\r\n%%\r\nr_str = 'gggggggggggggggggggggggggggggggggggggggggggg';\r\nc_corr = 44;\r\nassert(isequal(rupee_count_compact(r_str),c_corr));\r\n\r\n%%\r\nr_str = 'gggbgggysgggrggggGygbog*gggyggbggrgggsbggbyGggbBggbgggysgggrggggbggrgggsbggbyGggbBgggGyggbggrgggsbggbyGggbBggrggggGygbog*gggyggbggrgggsbggbyGggbBggbggg';\r\nc_corr = 3196;\r\nassert(isequal(rupee_count_compact(r_str),c_corr));\r\n\r\n%%\r\nr_str = 'b';\r\nn_r = randi(100);\r\nfor i = 2:n_r\r\n\tr_str = strcat(r_str,'g');\r\nend\r\nc_corr = 5 + n_r - 1;\r\nassert(isequal(rupee_count_compact(r_str),c_corr));\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":77,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-18T03:55:06.000Z","updated_at":"2026-03-19T20:00:04.000Z","published_at":"2015-02-18T03:55:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBuilding off of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3025\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, suppose that Link's rupee wallet will now provide a compact string with one letter designating each rupee he's picked up. Once again, the rupee denominations are (with abbreviating characters):\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGreen (g) = 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBlue (b) = 5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYellow (y) = 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRed (r) = 20\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePurple (p) = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOrange (o) = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSilver (s) = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig green (G) = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig blue (B) = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig red (R) = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig gold \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e(*\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) = 300\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNote that the string will be case-sensitive. Write a function to return the total value of rupees that Link has accumulated provided the compact rupee string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":8045,"title":"Gold Standard","description":"Gold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at \u003chttp://measuringworth.com/gold/ Measuring Worth\u003e.\r\n\r\nFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\r\n\r\nAs an example, with HY = 2000 and HV = 1000:\r\n\r\n* GV(HY=2000) = $280.10\r\n* N = 1000/280.10 = 3.57 (ounces of gold)\r\n* CV = 3.57*1270 (current $/ounce of gold) = $4534.09.\r\n","description_html":"\u003cp\u003eGold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at \u003ca href = \"http://measuringworth.com/gold/\"\u003eMeasuring Worth\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGV(HY=2000) = $280.10\u003c/li\u003e\u003cli\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/li\u003e\u003cli\u003eCV = 3.57*1270 (current $/ounce of gold) = $4534.09.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_standard(HY,HV)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; CV_corr = 1270;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; CV_corr = NaN;\r\nassert(isnan(gold_standard(HY,HV)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; CV_corr = NaN;\r\nassert(isnan(gold_standard(HY,HV)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; CV_corr = 1035.04;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2005; HV = 1000; CV_corr = 2847.53;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2000; HV = 1000; CV_corr = 4534.09;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1995; HV = 1000; CV_corr = 3294.42;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1990; HV = 1000; CV_corr = 3299.3;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1950; HV = 1000; CV_corr = 36285.71;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1900; HV = 1000; CV_corr = 61441.7;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1850; HV = 1000; CV_corr = 61441.7;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1800; HV = 1000; CV_corr = 65497.68;\r\nassert(abs(gold_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":63,"test_suite_updated_at":"2015-03-30T16:49:21.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T15:58:58.000Z","updated_at":"2026-03-24T03:34:47.000Z","published_at":"2015-03-30T15:58:58.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGold has long been used as currency and a standard for currency, due to its inherent value and rarity. Historical data for gold is available at\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://measuringworth.com/gold/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMeasuring Worth\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV) from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard can be accurately used to convert between years. Round the result to two decimal places. If HY is outside of the historical-data range, return NaN.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGV(HY=2000) = $280.10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = 3.57*1270 (current $/ounce of gold) = $4534.09.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3027,"title":"Legend of Zelda - Rupee Count (Item Purchase)","description":"Building off of \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count Problem 3025\u003e, 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:\r\n\r\n* Green = 1\r\n* Blue = 5\r\n* Yellow = 10\r\n* Red = 20\r\n* Purple = 50\r\n* Orange = 100\r\n* Silver = 200\r\n* Big green = 50\r\n* Big blue = 100\r\n* Big red = 200\r\n* Big gold = 300\r\n\r\nFor 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.\r\n\r\nBased 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:\r\n\r\n* Hookshot - 3000 rupees\r\n* Bow \u0026 Arrows - 1000 rupees\r\n* Shield - 500 rupees\r\n* Magic potion - 200 rupees\r\n* Shovel - 100 rupees\r\n* Bombs - 25 rupees\r\n\r\nFor example, if Link has 1714 rupees, he could purchase the Bow \u0026 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.","description_html":"\u003cp\u003eBuilding off of \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count\"\u003eProblem 3025\u003c/a\u003e, 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:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGreen = 1\u003c/li\u003e\u003cli\u003eBlue = 5\u003c/li\u003e\u003cli\u003eYellow = 10\u003c/li\u003e\u003cli\u003eRed = 20\u003c/li\u003e\u003cli\u003ePurple = 50\u003c/li\u003e\u003cli\u003eOrange = 100\u003c/li\u003e\u003cli\u003eSilver = 200\u003c/li\u003e\u003cli\u003eBig green = 50\u003c/li\u003e\u003cli\u003eBig blue = 100\u003c/li\u003e\u003cli\u003eBig red = 200\u003c/li\u003e\u003cli\u003eBig gold = 300\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor 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.\u003c/p\u003e\u003cp\u003eBased 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:\u003c/p\u003e\u003cul\u003e\u003cli\u003eHookshot - 3000 rupees\u003c/li\u003e\u003cli\u003eBow \u0026 Arrows - 1000 rupees\u003c/li\u003e\u003cli\u003eShield - 500 rupees\u003c/li\u003e\u003cli\u003eMagic potion - 200 rupees\u003c/li\u003e\u003cli\u003eShovel - 100 rupees\u003c/li\u003e\u003cli\u003eBombs - 25 rupees\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eFor example, if Link has 1714 rupees, he could purchase the Bow \u0026 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.\u003c/p\u003e","function_template":"function [i_arr,r_rem] = rupee_count_items(r)\r\n\r\nr_ref = [1,5,10,20,50,100,200,50,100,200,300];\r\ni_ref = {'Hookshot','Bow \u0026 Arrows','Shield','Magic potion','Shovel','Bombs'};\r\n\r\ni_arr = {''};\r\nr_rem = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nr = [20,5,3,1,0,1,1,0,0,0,0];\r\ni_arr_corr = {'Magic potion','Shovel','Bombs'};\r\nr_rem_corr = 70;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [4,0,1,0,0,0,0,0,0,1,5];\r\ni_arr_corr = {'Bow \u0026 Arrows','Shield','Magic potion'};\r\nr_rem_corr = 14;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [194,27,13,5,3,2,1,0,1,0,1];\r\ni_arr_corr = {'Bow \u0026 Arrows','Shield'};\r\nr_rem_corr = 9;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [254,94,23,11,15,4,7,3,2,0,1];\r\ni_arr_corr = {'Hookshot','Bow \u0026 Arrows','Magic potion','Shovel','Bombs'};\r\nr_rem_corr = 49;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [255,94,24,13,15,4,7,3,2,2,1];\r\ni_arr_corr = {'Hookshot','Bow \u0026 Arrows','Shield','Magic potion','Shovel','Bombs'};\r\nr_rem_corr = 0;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n%%\r\nr = [27,2,1,0,0,0,0,0,0,0,0];\r\ni_arr_corr = {'Bombs'};\r\nr_rem_corr = 22;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n\r\n\r\n%%\r\nr_ind = randi(21);\r\nr = [r_ind,2,2,1,1,0,0,0,0,0,0];\r\ni_arr_corr = {'Shovel'};\r\nr_rem_corr = r_ind;\r\n[i_arr,r_rem] = rupee_count_items(r);\r\nassert(isequal(r_rem,r_rem_corr));\r\nassert(isequal(i_arr,i_arr_corr));\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-18T04:30:11.000Z","updated_at":"2026-03-19T20:01:40.000Z","published_at":"2015-02-18T04:30:11.000Z","restored_at":"2017-09-28T06:14:56.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBuilding off of\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3025-zelda-rupee-count\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3025\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, 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:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGreen = 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBlue = 5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYellow = 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRed = 20\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePurple = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOrange = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSilver = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig green = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig blue = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig red = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig gold = 300\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBased 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:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHookshot - 3000 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBow \u0026amp; Arrows - 1000 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eShield - 500 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMagic potion - 200 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eShovel - 100 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBombs - 25 rupees\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if Link has 1714 rupees, he could purchase the Bow \u0026amp; 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.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":3025,"title":"Legend of Zelda - Rupee Count","description":"Rupees are the main currency in The Legend of Zelda games. The value of each rupee is determined by its color. Unfortunately, the rupee denomenations are somewhat different across the games. For the purposes of this problem, we'll assume the following values:\r\n\r\n* Green = 1\r\n* Blue = 5\r\n* Yellow = 10\r\n* Red = 20\r\n* Purple = 50\r\n* Orange = 100\r\n* Silver = 200\r\n* Big green = 50\r\n* Big blue = 100\r\n* Big red = 200\r\n* Big gold = 300\r\n\r\nYou'll be provided a cell array of strings indicating the rupees that Link has picked up in his recent adventures. Write a function to return the total value of rupees that he has accumulated in his wallet.\r\n\r\nThis problem is related to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3026-zelda-rupee-count-compact Problem 3026\u003e and \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3027-zelda-rupee-count-item-purchase Problem 3027\u003e.","description_html":"\u003cp\u003eRupees are the main currency in The Legend of Zelda games. The value of each rupee is determined by its color. Unfortunately, the rupee denomenations are somewhat different across the games. For the purposes of this problem, we'll assume the following values:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGreen = 1\u003c/li\u003e\u003cli\u003eBlue = 5\u003c/li\u003e\u003cli\u003eYellow = 10\u003c/li\u003e\u003cli\u003eRed = 20\u003c/li\u003e\u003cli\u003ePurple = 50\u003c/li\u003e\u003cli\u003eOrange = 100\u003c/li\u003e\u003cli\u003eSilver = 200\u003c/li\u003e\u003cli\u003eBig green = 50\u003c/li\u003e\u003cli\u003eBig blue = 100\u003c/li\u003e\u003cli\u003eBig red = 200\u003c/li\u003e\u003cli\u003eBig gold = 300\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eYou'll be provided a cell array of strings indicating the rupees that Link has picked up in his recent adventures. Write a function to return the total value of rupees that he has accumulated in his wallet.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3026-zelda-rupee-count-compact\"\u003eProblem 3026\u003c/a\u003e and \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3027-zelda-rupee-count-item-purchase\"\u003eProblem 3027\u003c/a\u003e.\u003c/p\u003e","function_template":"function [c] = rupee_count(r_arr)\r\n\r\nc = 0;\r\n\r\nend\r\n","test_suite":"%%\r\nr_arr = {'Green','Blue','Yellow','Red','Purple','Orange','Silver','Big green','Big blue','Big red','Big gold'};\r\nc_corr = 1036;\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n\r\n%%\r\nr_arr = {'Green','Blue','Yellow','Green','Green','Green','Green','Red','Green','Green','Green','Blue','Blue','Yellow','Yellow','Green','Green','Blue','Green','Blue','Yellow','Green','Green','Blue','Green','Blue','Green','Green'};\r\nc_corr = 111;\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n\r\n%%\r\nr_arr = {'Green','Blue','Yellow','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Green','Yellow'};\r\nc_corr = 44;\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n\r\n%%\r\nr_arr = {'Green','Big green','Big blue','Red','Silver'};\r\nc_corr = 371;\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n\r\n%%\r\nr_ref = {'Green','Blue','Yellow','Red','Purple','Orange','Silver','Big green','Big blue','Big red','Big gold'};\r\nr_v = [1,5,10,20,50,100,200,50,100,200,300];\r\nc_corr = 5;\r\nn_r = randi(100);\r\nr_arr{1} = 'Blue';\r\nfor i = 2:n_r\r\n\tind_r = randi(11);\r\n\tr_arr{i} = r_ref{ind_r};\r\n\tc_corr = c_corr + r_v(ind_r);\r\nend\r\nassert(isequal(rupee_count(r_arr),c_corr));\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":72,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-18T03:36:32.000Z","updated_at":"2026-03-19T20:02:15.000Z","published_at":"2015-02-18T03:36:32.000Z","restored_at":"2017-09-28T06:14:47.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRupees are the main currency in The Legend of Zelda games. The value of each rupee is determined by its color. Unfortunately, the rupee denomenations are somewhat different across the games. For the purposes of this problem, we'll assume the following values:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGreen = 1\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBlue = 5\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYellow = 10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eRed = 20\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePurple = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOrange = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSilver = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig green = 50\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig blue = 100\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig red = 200\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBig gold = 300\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou'll be provided a cell array of strings indicating the rupees that Link has picked up in his recent adventures. Write a function to return the total value of rupees that he has accumulated in his wallet.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3026-zelda-rupee-count-compact\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3026\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/3027-zelda-rupee-count-item-purchase\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3027\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":8046,"title":"Gold/Silver Standard","description":"Pursuant to the \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard Gold Standard\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from \u003chttp://measuringworth.com/gold/ Measuring Worth\u003e.\r\n\r\nFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\r\n\r\nAs an example, with HY = 2000 and HV = 1000:\r\n\r\n* GV(HY=2000) = $280.10\r\n* N = 1000/280.10 = 3.57 (ounces of gold)\r\n* SR(HY=2000) = 55.96\r\n* NS = 55.96*3.57 = 199.79 (ounces of silver)\r\n* NG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\r\n* CV = 3.01*1270 (current $/ounce of gold) = $3822.36.","description_html":"\u003cp\u003ePursuant to the \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\"\u003eGold Standard\u003c/a\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from \u003ca href = \"http://measuringworth.com/gold/\"\u003eMeasuring Worth\u003c/a\u003e.\u003c/p\u003e\u003cp\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/p\u003e\u003cul\u003e\u003cli\u003eGV(HY=2000) = $280.10\u003c/li\u003e\u003cli\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/li\u003e\u003cli\u003eSR(HY=2000) = 55.96\u003c/li\u003e\u003cli\u003eNS = 55.96*3.57 = 199.79 (ounces of silver)\u003c/li\u003e\u003cli\u003eNG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\u003c/li\u003e\u003cli\u003eCV = 3.01*1270 (current $/ounce of gold) = $3822.36.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_silver_standard(HY,HV)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\nSR = [15.05, 15.17, 15, 15.37, 15.55, 15.65, 15.41, 15.59, 15.74, 15.68, 15.46, 15.26, 15.41, 15.41, 15.79, 15.52, 15.43, 16.08, 15.96, 15.77, 15.53, 16.11, 16.25, 15.04, 15.26, 15.28, 15.11, 15.35, 15.33, 15.62, 15.95, 15.8, 15.84, 15.82, 15.7, 15.76, 15.74, 15.78, 15.78, 15.82, 15.72, 15.73, 15.93, 15.73, 15.8, 15.72, 15.83, 15.85, 15.62, 15.62, 15.7, 15.87, 15.93, 15.85, 15.92, 15.9, 15.8, 15.85, 15.78, 15.7, 15.46, 15.59, 15.33, 15.33, 15.38, 15.38, 15.27, 15.38, 15.19, 15.29, 15.5, 15.35, 15.37, 15.37, 15.44, 15.43, 15.57, 15.59, 15.6, 15.57, 15.57, 15.63, 15.93, 16.16, 16.64, 17.75, 17.2, 17.92, 18.39, 18.05, 18.25, 18.2, 18.64, 18.61, 19.41, 20.78, 21.1, 22, 22.1, 19.75, 20.92, 23.72, 26.49, 32.56, 31.6, 30.59, 34.2, 35.03, 34.36, 33.33, 34.68, 39.15, 38.1, 35.7, 33.87, 30.54, 31.24, 38.64, 39.74, 38.22, 38.33, 33.62, 34.19, 37.37, 40.48, 30.78, 24.61, 21, 18.44, 20.28, 32.76, 30.43, 31.69, 30.8, 29.78, 33.11, 36.47, 35.34, 38.78, 53.74, 71.25, 73.29, 69.83, 72.36, 54.19, 77.09, 77.44, 80.39, 88.84, 99.76, 99.73, 90.57, 77.67, 77.67, 67.4, 43.67, 48.73, 47.07, 48.61, 47.14, 39.12, 41.16, 41.04, 41.01, 39.24, 38.5, 38.5, 39.27, 38.34, 38.27, 37.82, 32.22, 27.34, 27.04, 27.04, 27.04, 22.56, 18.29, 23.16, 20.54, 26.66, 34.75, 38.21, 33.9, 36.51, 28.76, 32.05, 35.8, 27.69, 29.66, 43.65, 47.24, 37.03, 44.26, 51.68, 67.25, 63.84, 66.95, 69.49, 79.78, 89.83, 87.47, 83.85, 72.79, 74.78, 74.89, 67.91, 53.24, 53.26, 55.96, 61.95, 67.32, 74.22, 61.3, 60.7, 52.2, 51.91, 58.17, 66.27, 60.64, 44.75, 53.58, 59.31, 66.38];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; CV_corr = 1270;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; CV_corr = NaN;\r\nassert(isnan(gold_silver_standard(HY,HV)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; CV_corr = NaN;\r\nassert(isnan(gold_silver_standard(HY,HV)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; CV_corr = 945.54;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2005; HV = 1000; CV_corr = 2603.88;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 2000; HV = 1000; CV_corr = 3822.36;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1995; HV = 1000; CV_corr = 3711.31;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1990; HV = 1000; CV_corr = 3965.32;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1950; HV = 1000; CV_corr = 25768.43;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1900; HV = 1000; CV_corr = 30850.44;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1850; HV = 1000; CV_corr = 14532.01;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nHY = 1800; HV = 1000; CV_corr = 15471.58;\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 2000; HV = 1000; CV_corr = 3822.36;\r\n\tcase 2\r\n\t\tHY = 1995; HV = 1000; CV_corr = 3711.31;\r\n\tcase 3\r\n\t\tHY = 2005; HV = 1000; CV_corr = 2603.88;\r\n\tcase 4\r\n\t\tHY = 1800; HV = 1000; CV_corr = 15471.58;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 1995; HV = 1000; CV_corr = 3711.31;\r\n\tcase 2\r\n\t\tHY = 1990; HV = 1000; CV_corr = 3965.32;\r\n\tcase 3\r\n\t\tHY = 2010; HV = 1000; CV_corr = 945.54;\r\n\tcase 4\r\n\t\tHY = 1900; HV = 1000; CV_corr = 30850.44;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tHY = 1990; HV = 1000; CV_corr = 3965.32;\r\n\tcase 2\r\n\t\tHY = 1950; HV = 1000; CV_corr = 25768.43;\r\n\tcase 3\r\n\t\tHY = 1900; HV = 1000; CV_corr = 30850.44;\r\n\tcase 4\r\n\t\tHY = 2000; HV = 1000; CV_corr = 3822.36;\r\nend\r\nassert(abs(gold_silver_standard(HY,HV)-CV_corr)\u003c2e-5)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2015-03-30T16:51:28.000Z","rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T16:22:04.000Z","updated_at":"2026-03-27T06:19:08.000Z","published_at":"2015-03-30T16:22:04.000Z","restored_at":"2017-07-28T15:24:51.000Z","restored_by":null,"spam":false,"simulink":false,"admin_reviewed":true,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ePursuant to the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e problem, suppose that you have data for silver rather than gold to make an assessment regarding historical currency values. Historical data for the silver-to-gold ratio is also available from\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://measuringworth.com/gold/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMeasuring Worth\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, you will be provided with a historical year (HY) and a historical value (HV) in dollars. The function template includes data from the previously mentioned site for the value (in dollars) of an ounce of gold (GV), in addition to the silver-to-gold ratio, from 1791 to 2014. Write a function to determine the current value (CV) in dollars assuming that the gold standard must be converted to the silver standard to accurately convert between years. Round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, with HY = 2000 and HV = 1000:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGV(HY=2000) = $280.10\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eN = 1000/280.10 = 3.57 (ounces of gold)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSR(HY=2000) = 55.96\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNS = 55.96*3.57 = 199.79 (ounces of silver)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eNG = 199.79/66.38 = 3.01 (current ounces of gold) [SR(2014) = 66.38]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = 3.01*1270 (current $/ounce of gold) = $3822.36.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":8047,"title":"Weighted Gold/Silver Standard","description":"Building off of the \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard Gold Standard\u003e and \u003chttp://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard Gold/Silver Standard\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\r\n\r\nFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\r\n\r\nAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\r\n\r\n* CVG = $4534.09 (gold standard)\r\n* CVS = $3822.36 (silver standard)\r\n* CV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.","description_html":"\u003cp\u003eBuilding off of the \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\"\u003eGold Standard\u003c/a\u003e and \u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard\"\u003eGold/Silver Standard\u003c/a\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\u003c/p\u003e\u003cp\u003eFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/p\u003e\u003cp\u003eAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\u003c/p\u003e\u003cul\u003e\u003cli\u003eCVG = $4534.09 (gold standard)\u003c/li\u003e\u003cli\u003eCVS = $3822.36 (silver standard)\u003c/li\u003e\u003cli\u003eCV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.\u003c/li\u003e\u003c/ul\u003e","function_template":"function [CV] = gold_silver_weighted_standard(HY,HV,wt)\r\n\r\nY = 1791:2014;\r\nGV = [19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 20.1, 21.64, 20.95, 19.46, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.39, 19.94, 20.69, 20.69, 21.64, 20.86, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.7, 20.67, 20.67, 20.67, 20.67, 23.42, 30.02, 42.03, 32.52, 29.13, 28.57, 28.88, 27.49, 23.75, 23.09, 23.24, 23.52, 22.99, 23.75, 23.05, 21.66, 20.84, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 20.67, 24.44, 34.94, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 35, 39.26, 41.51, 36.41, 41.25, 58.6, 97.81, 159.74, 161.49, 125.32, 148.31, 193.55, 307.5, 612.56, 459.64, 375.91, 424, 360.66, 317.66, 368.24, 447.95, 438.31, 382.58, 384.93, 363.29, 344.97, 360.91, 385.42, 385.5, 389.09, 332.39, 295.24, 279.91, 280.1, 272.22, 311.33, 364.8, 410.52, 446, 606, 699, 874, 975, 1227, 1572, 1700, 1415, 1270];\r\nSR = [15.05, 15.17, 15, 15.37, 15.55, 15.65, 15.41, 15.59, 15.74, 15.68, 15.46, 15.26, 15.41, 15.41, 15.79, 15.52, 15.43, 16.08, 15.96, 15.77, 15.53, 16.11, 16.25, 15.04, 15.26, 15.28, 15.11, 15.35, 15.33, 15.62, 15.95, 15.8, 15.84, 15.82, 15.7, 15.76, 15.74, 15.78, 15.78, 15.82, 15.72, 15.73, 15.93, 15.73, 15.8, 15.72, 15.83, 15.85, 15.62, 15.62, 15.7, 15.87, 15.93, 15.85, 15.92, 15.9, 15.8, 15.85, 15.78, 15.7, 15.46, 15.59, 15.33, 15.33, 15.38, 15.38, 15.27, 15.38, 15.19, 15.29, 15.5, 15.35, 15.37, 15.37, 15.44, 15.43, 15.57, 15.59, 15.6, 15.57, 15.57, 15.63, 15.93, 16.16, 16.64, 17.75, 17.2, 17.92, 18.39, 18.05, 18.25, 18.2, 18.64, 18.61, 19.41, 20.78, 21.1, 22, 22.1, 19.75, 20.92, 23.72, 26.49, 32.56, 31.6, 30.59, 34.2, 35.03, 34.36, 33.33, 34.68, 39.15, 38.1, 35.7, 33.87, 30.54, 31.24, 38.64, 39.74, 38.22, 38.33, 33.62, 34.19, 37.37, 40.48, 30.78, 24.61, 21, 18.44, 20.28, 32.76, 30.43, 31.69, 30.8, 29.78, 33.11, 36.47, 35.34, 38.78, 53.74, 71.25, 73.29, 69.83, 72.36, 54.19, 77.09, 77.44, 80.39, 88.84, 99.76, 99.73, 90.57, 77.67, 77.67, 67.4, 43.67, 48.73, 47.07, 48.61, 47.14, 39.12, 41.16, 41.04, 41.01, 39.24, 38.5, 38.5, 39.27, 38.34, 38.27, 37.82, 32.22, 27.34, 27.04, 27.04, 27.04, 22.56, 18.29, 23.16, 20.54, 26.66, 34.75, 38.21, 33.9, 36.51, 28.76, 32.05, 35.8, 27.69, 29.66, 43.65, 47.24, 37.03, 44.26, 51.68, 67.25, 63.84, 66.95, 69.49, 79.78, 89.83, 87.47, 83.85, 72.79, 74.78, 74.89, 67.91, 53.24, 53.26, 55.96, 61.95, 67.32, 74.22, 61.3, 60.7, 52.2, 51.91, 58.17, 66.27, 60.64, 44.75, 53.58, 59.31, 66.38];\r\n\r\nCV = 1;\r\n\r\nend\r\n","test_suite":"%% current check\r\nHY = 2014; HV = 1270; wt = 0.5; CV_corr = 1270;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%% out-of-range check 1\r\nHY = 500; HV = 50; wt = 0.5; CV_corr = NaN;\r\nassert(isnan(gold_silver_weighted_standard(HY,HV,wt)))\r\n\r\n%% out-of-range check 2\r\nHY = 2500; HV = 5000; wt = 0.5; CV_corr = NaN;\r\nassert(isnan(gold_silver_weighted_standard(HY,HV,wt)))\r\n\r\n%%\r\nHY = 2010; HV = 1000; wt = 0.5; CV_corr = 990.29;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2005; HV = 1000; wt = 0.5; CV_corr = 2725.7;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2000; HV = 1000; wt = 0.5; CV_corr = 4178.23;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1995; HV = 1000; wt = 0.5; CV_corr = 3502.87;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1990; HV = 1000; wt = 0.5; CV_corr = 3632.31;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1950; HV = 1000; wt = 0.5; CV_corr = 31027.07;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1900; HV = 1000; wt = 0.5; CV_corr = 46146.07;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1850; HV = 1000; wt = 0.5; CV_corr = 37986.86;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1800; HV = 1000; wt = 0.5; CV_corr = 40484.63;\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 2000; HV = 1000;\r\nwt = randi(10)/10;\r\nswitch (wt*10)\r\n\tcase 0\r\n\t\tCV_corr = 4534.09;\r\n\tcase 1\r\n\t\tCV_corr = 4462.92;\r\n\tcase 2\r\n\t\tCV_corr = 4391.75;\r\n\tcase 3\r\n\t\tCV_corr = 4320.57;\r\n\tcase 4\r\n\t\tCV_corr = 4249.4;\r\n\tcase 5\r\n\t\tCV_corr = 4178.23;\r\n\tcase 6\r\n\t\tCV_corr = 4107.05;\r\n\tcase 7\r\n\t\tCV_corr = 4035.88;\r\n\tcase 8\r\n\t\tCV_corr = 3964.7;\r\n\tcase 9\r\n\t\tCV_corr = 3893.53;\r\n\tcase 10\r\n\t\tCV_corr = 3822.36;\r\nend\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n\r\n%%\r\nHY = 1800; HV = 1000;\r\nwt = randi(10)/10;\r\nswitch (wt*10)\r\n\tcase 0\r\n\t\tCV_corr = 65497.68;\r\n\tcase 1\r\n\t\tCV_corr = 60495.07;\r\n\tcase 2\r\n\t\tCV_corr = 55492.46;\r\n\tcase 3\r\n\t\tCV_corr = 50489.85;\r\n\tcase 4\r\n\t\tCV_corr = 45487.24;\r\n\tcase 5\r\n\t\tCV_corr = 40484.63;\r\n\tcase 6\r\n\t\tCV_corr = 35482.02;\r\n\tcase 7\r\n\t\tCV_corr = 30479.41;\r\n\tcase 8\r\n\t\tCV_corr = 25476.8;\r\n\tcase 9\r\n\t\tCV_corr = 20474.19;\r\n\tcase 10\r\n\t\tCV_corr = 15471.58;\r\nend\r\nassert(abs(gold_silver_weighted_standard(HY,HV,wt)-CV_corr)\u003c5e-2)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":26769,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":50,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":30,"created_at":"2015-03-30T16:47:31.000Z","updated_at":"2026-03-27T06:22:48.000Z","published_at":"2015-03-30T16:47:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBuilding off of the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8045-gold-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/8046-gold-silver-standard\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eGold/Silver Standard\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e problems, let's make a weighted currency convertor. The same data for gold value and silver-to-gold ratio will be provided in the function template.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor this problem, based on a historical year (HY) and a historical value (HV) in dollars, calculate the current value using the gold (CVG) and silver (CVS) references; see the referenced problems for details and examples of those individual problems. In this case, you will be provided a weighting that will range from 0 to 1, where 0 indicates complete weighting by gold and 1 indicates complete weighting by silver. Remember to round the result to two decimal places. If HY is outside of the historical data range, return NaN.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAs an example, with HY = 2000, HV = 1000, and wt = 0.4:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCVG = $4534.09 (gold standard)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCVS = $3822.36 (silver standard)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCV = (1-0.4)*4534.09 + 0.4*3822.36 = $4249.40.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":48,"title":"Making change","description":"Given an amount of currency, return a vector of this form:\r\n [100 50 20 10 5 2 1 0.5 0.25 0.1 0.05 0.01]\r\nExample:\r\n Input a = 257.68\r\n Output b is [2 1 0 0 1 1 0 1 0 1 1 3]\r\nAlways use bigger bills/coins if possible.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 164.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 82.15px; transform-origin: 407px 82.15px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 180.5px 8px; transform-origin: 180.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven an amount of currency, return a vector of this form:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 176px 8.5px; tab-size: 4; transform-origin: 176px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e [100 50 20 10 5 2 1 0.5 0.25 0.1 0.05 0.01]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 68px 8.5px; tab-size: 4; transform-origin: 68px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 28px 8.5px; transform-origin: 28px 8.5px; \"\u003e Input \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 40px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 40px 8.5px; \"\u003ea = 257.68\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 120px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 120px 8.5px; \"\u003eb is [2 1 0 0 1 1 0 1 0 1 1 3]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 125px 8px; transform-origin: 125px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAlways use bigger bills/coins if possible.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function b = makingChange(a)","test_suite":"%%\r\na = [257.68];  \r\n \r\nb = [2 1 0 0 1 1 0 1 0 1 1 3];\r\nout = makingChange(a);\r\nassert(isequal(out(:), b(:)))\r\n\r\n%%\r\na = [135.01];  \r\n \r\nb = [1 0 1 1 1 0 0 0 0 0 0 1];\r\nout = makingChange(a);\r\nassert(isequal(out(:), b(:)))\r\n\r\n%%\r\na = [10035.99];  \r\n \r\nb = [100 0 1 1 1 0 0 1 1 2 0 4];\r\nout = makingChange(a);\r\nassert(isequal(out(:), b(:)))\r\n\r\n%%\r\na = 420;  \r\n \r\nb = [4 0 1 0 0 0 0 0 0 0 0 0];\r\nout = makingChange(a);\r\nassert(isequal(out(:), b(:)))\r\n\r\n%%\r\na = 0;  \r\n \r\nout = makingChange(a);\r\nassert(isequal(out,zeros(1,12)))\r\n","published":true,"deleted":false,"likes_count":20,"comments_count":9,"created_by":1,"edited_by":223089,"edited_at":"2023-06-24T10:25:06.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3484,"test_suite_updated_at":"2023-06-24T10:25:06.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:24.000Z","updated_at":"2026-02-25T14:05:04.000Z","published_at":"2012-01-18T01:00:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an amount of currency, return a vector of this form:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ [100 50 20 10 5 2 1 0.5 0.25 0.1 0.05 0.01]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input a = 257.68\\n Output b is [2 1 0 0 1 1 0 1 0 1 1 3]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eAlways use bigger bills/coins if possible.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"term":"tag:\"money\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"money\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"money\"","","\"","money","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fa2bda71ae0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fa2bda71a40\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fa2bda70fa0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fa2bda71d60\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fa2bda71cc0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fa2bda71c20\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fa2bda71b80\u003e":"tag:\"money\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fa2bda71b80\u003e":"tag:\"money\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"money\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"money\"","","\"","money","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007fa2bda71ae0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007fa2bda71a40\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007fa2bda70fa0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007fa2bda71d60\u003e":1,"#\u003cMathWorks::Search::Field:0x00007fa2bda71cc0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007fa2bda71c20\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007fa2bda71b80\u003e":"tag:\"money\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007fa2bda71b80\u003e":"tag:\"money\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":3026,"difficulty_rating":"easy"},{"id":8045,"difficulty_rating":"easy-medium"},{"id":3027,"difficulty_rating":"easy-medium"},{"id":3025,"difficulty_rating":"easy-medium"},{"id":8046,"difficulty_rating":"easy-medium"},{"id":8047,"difficulty_rating":"easy-medium"},{"id":48,"difficulty_rating":"medium"}]}}