{"group":{"group":{"id":32,"name":"Strings III","lockable":false,"created_at":"2017-09-27T15:38:35.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Let's test your string-manipulation savviness.","is_default":false,"created_by":26769,"badge_id":46,"featured":false,"trending":false,"solution_count_in_trending_period":8,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":411,"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":"{\"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\u003eLet's test your string-manipulation savviness.\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\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; 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: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 10.5px; transform-origin: 289.5px 10.5px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; perspective-origin: 266.5px 10.5px; transform-origin: 266.5px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eLet's test your string-manipulation savviness.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2019-05-08T19:57:14.000Z"},"current_player":null},"problems":[{"id":2151,"title":"Reverse within string ","description":"If input is a string 'yellow' the output should be 'leywol'. Locate the middle of the string and reverse the first (yel) and second (low)parts of the string.\r\n\r\nIf the length of the string is odd, leave the middle letter unchanged.\r\n\r\nInput 'letter' output 'telret'\r\n\r\nInput 'apple' output 'papel'","description_html":"\u003cp\u003eIf input is a string 'yellow' the output should be 'leywol'. Locate the middle of the string and reverse the first (yel) and second (low)parts of the string.\u003c/p\u003e\u003cp\u003eIf the length of the string is odd, leave the middle letter unchanged.\u003c/p\u003e\u003cp\u003eInput 'letter' output 'telret'\u003c/p\u003e\u003cp\u003eInput 'apple' output 'papel'\u003c/p\u003e","function_template":"function y = reverse_within_string(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'Help';\r\ny_correct = 'eHpl';\r\nassert(isequal(reverse_within_string(x),y_correct))\r\n\r\n%%\r\nx = 'between';\r\ny_correct = 'tebwnee';\r\nassert(isequal(reverse_within_string(x),y_correct))\r\n\r\n%%\r\nx = 'yellow';\r\ny_correct = 'leywol';\r\nassert(isequal(reverse_within_string(x),y_correct))\r\n\r\n%%\r\nx = 'apple';\r\ny_correct = 'papel';\r\nassert(isequal(reverse_within_string(x),y_correct))\r\n\r\n%%\r\nx = 'one, two, three';\r\ny_correct = 'wt ,enooeerht ,';\r\nassert(isequal(reverse_within_string(x),y_correct))\r\n\r\n%%\r\nx = 'red green blue';\r\ny_correct = 'erg dereulb ne';\r\nassert(isequal(reverse_within_string(x),y_correct))\r\n\r\n%%\r\nx = 'a';\r\ny_correct = 'a';\r\nassert(isequal(reverse_within_string(x),y_correct))\r\n\r\n%%\r\nx = '1234567890';\r\ny_correct = '5432109876';\r\nassert(isequal(reverse_within_string(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":22585,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":153,"test_suite_updated_at":"2017-09-27T15:43:07.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-02-05T10:25:53.000Z","updated_at":"2026-03-19T20:05:48.000Z","published_at":"2014-02-05T10:27:40.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eIf input is a string 'yellow' the output should be 'leywol'. Locate the middle of the string and reverse the first (yel) and second (low)parts of the string.\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\u003eIf the length of the string is odd, leave the middle letter unchanged.\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\u003eInput 'letter' output 'telret'\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\u003eInput 'apple' output 'papel'\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":2512,"title":"longest common semi-substring","description":"Finding longest common substring is a common problem in string processing. This problem is a variant of that.\r\nTwo strings are given. Find the length of longest common substring between these two that start and end with the same characters. Characters in the middle may not be same. Length of the two sub-strings should be equal.\r\nExample:\r\nstr1 = 'party';\r\nsrt2 = 'pure';\r\nHere, 'par' and 'pur' are two substrings from str1 and str2 that start and end with same characters. Here, length is 3.","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: 183.867px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 91.9333px; transform-origin: 407px 91.9333px; 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: 346px 8px; transform-origin: 346px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFinding longest common substring is a common problem in string processing. This problem is a variant of that.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; 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 21px; text-align: left; transform-origin: 384px 21px; 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: 376.5px 8px; transform-origin: 376.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eTwo strings are given. Find the length of longest common substring between these two that start and end with the same characters. Characters in the middle may not be same. Length of the two sub-strings should be equal.\u003c/span\u003e\u003c/span\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: 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: 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: 60px 8.5px; tab-size: 4; transform-origin: 60px 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; \"\u003estr1 = \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: 28px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 28px 8.5px; \"\u003e'party'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e;\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: 56px 8.5px; tab-size: 4; transform-origin: 56px 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; \"\u003esrt2 = \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: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'pure'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e;\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: 363.5px 8px; transform-origin: 363.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHere, 'par' and 'pur' are two substrings from str1 and str2 that start and end with same characters. Here, length is 3.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = str(x)\r\n  y = x;\r\nend","test_suite":"%%\r\na = 'cat';\r\nb = 'cat'\r\ny_correct = 3;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n%%\r\na = 'cat';\r\nb = 'cut'\r\ny_correct = 3;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'president';\r\nb = 'precedent'\r\ny_correct = 9;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n%%\r\na =  'katy perry';\r\nb = 'qqa^%^%rrrrRR'\r\ny_correct = 8;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'cody was down for a while';\r\nb = '12w123456789o88888888899'\r\ny_correct = 11;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'cat';\r\nb = 'dog and other pets'\r\ny_correct = 1;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n%%\r\na = 'cat';\r\nb = 'aca'\r\ny_correct = 2;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n\r\n%%\r\na = 'apparently nothing in common';\r\nb = 'zzzz zz zzzz'\r\ny_correct = 4;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'nothing in common';\r\nb = 'zzzz'\r\ny_correct = 0;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'empty string testing';\r\nb = '';\r\ny_correct = 0;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n%%\r\na = '';\r\nb = '';\r\ny_correct = 0;\r\nassert(isequal(str(a,b),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":17203,"edited_by":223089,"edited_at":"2022-04-30T19:20:34.000Z","deleted_by":null,"deleted_at":null,"solvers_count":50,"test_suite_updated_at":"2014-08-16T04:00:53.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-08-15T08:09:29.000Z","updated_at":"2026-03-19T20:11:28.000Z","published_at":"2014-08-15T08:09:29.000Z","restored_at":null,"restored_by":null,"spam":null,"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\u003eFinding longest common substring is a common problem in string processing. This problem is a variant of that.\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\u003eTwo strings are given. Find the length of longest common substring between these two that start and end with the same characters. Characters in the middle may not be same. Length of the two sub-strings should be equal.\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[str1 = 'party';\\nsrt2 = 'pure';]]\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\u003eHere, 'par' and 'pur' are two substrings from str1 and str2 that start and end with same characters. Here, length is 3.\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\"}]}"},{"id":2469,"title":"Cat, Meowcat and Concatenation","description":"Input is a cell array containing several strings. Find the largest continuous sub-string common to all strings. All strings are in lower case and unique answer exists.\r\nExample:\r\nin = {'cat','meowcat','concatenation'};\r\nout = 'cat';","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: 122.867px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 61.4333px; transform-origin: 407px 61.4333px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; 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 21px; text-align: left; transform-origin: 384px 21px; 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: 383px 8px; transform-origin: 383px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInput is a cell array containing several strings. Find the largest continuous sub-string common to all strings. All strings are in lower case and unique answer exists.\u003c/span\u003e\u003c/span\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: 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: 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: 156px 8.5px; tab-size: 4; transform-origin: 156px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 24px 8.5px; transform-origin: 24px 8.5px; \"\u003ein = {\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: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003e'cat'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e,\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: 36px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003e'meowcat'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e,\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: 60px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 60px 8.5px; \"\u003e'concatenation'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 8px 8.5px; transform-origin: 8px 8.5px; \"\u003e};\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: 48px 8.5px; tab-size: 4; transform-origin: 48px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 24px 8.5px; transform-origin: 24px 8.5px; \"\u003eout = \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: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003e'cat'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = commonS(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = {'cat','meowcat','concatenation'};\r\ny_correct = 'cat';\r\nassert(isequal(commonS(x),y_correct))\r\n\r\n%%\r\nx = {'zzzyyyzzz','meowcat','concatenation'};\r\ny_correct = '';\r\nassert(isequal(commonS(x),y_correct))\r\n\r\n%%\r\nx = {'pur','purr'};\r\ny_correct = 'pur';\r\nassert(isequal(commonS(x),y_correct))\r\n\r\n%%\r\nx = {'meowcat','owl','bowl'};\r\ny_correct = 'ow';\r\nassert(isequal(commonS(x),y_correct))\r\n\r\n%%\r\nx = {'adoga','ssdogss','ppdogppp'};\r\ny_correct = 'dog';\r\nassert(isequal(commonS(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":3,"created_by":17203,"edited_by":223089,"edited_at":"2022-05-02T06:01:18.000Z","deleted_by":null,"deleted_at":null,"solvers_count":60,"test_suite_updated_at":"2022-05-02T06:01:18.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-07-29T08:09:10.000Z","updated_at":"2026-03-25T21:06:04.000Z","published_at":"2014-07-29T08:09:10.000Z","restored_at":null,"restored_by":null,"spam":null,"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\u003eInput is a cell array containing several strings. Find the largest continuous sub-string common to all strings. All strings are in lower case and unique answer exists.\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[in = {'cat','meowcat','concatenation'};\\nout = 'cat';]]\u003e\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\"}]}"},{"id":2202,"title":"Flip the bit","description":"Given an input character string (e.g. '1001'), return a character string with the bits flipped ('0110').","description_html":"\u003cp\u003eGiven an input character string (e.g. '1001'), return a character string with the bits flipped ('0110').\u003c/p\u003e","function_template":"function y = flipbit(s)\r\n  y = '010101';\r\nend","test_suite":"%%\r\ns = '1001';\r\ny_correct = '0110';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '11';\r\ny_correct = '00';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '1';\r\ny_correct = '0';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '100000001';\r\ny_correct = '011111110';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n%%\r\ns = '00001';\r\ny_correct = '11110';\r\nassert(all(isequal(flipbit(s),y_correct)\u0026ischar(flipbit(s))))\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":2,"created_by":39,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":535,"test_suite_updated_at":"2014-02-20T18:44:05.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-02-20T15:53:55.000Z","updated_at":"2026-03-19T20:08:33.000Z","published_at":"2014-02-20T15:56:43.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eGiven an input character string (e.g. '1001'), return a character string with the bits flipped ('0110').\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":2227,"title":"Broken numlock key, oppps ! ","description":"The numlock key on my computer is pressed and is now broken, so I cant press it to switch off the numlock mode. And hence I am not able to read whatever I am typing. Can you help me decode what I am typing?\r\n\r\nExample\r\n\r\n Input:  \"0y n4036c2 2ey 5s br62en!\"\r\n Output: \"my numlock key is broken!\"\r\n\r\nHappy decoding!","description_html":"\u003cp\u003eThe numlock key on my computer is pressed and is now broken, so I cant press it to switch off the numlock mode. And hence I am not able to read whatever I am typing. Can you help me decode what I am typing?\u003c/p\u003e\u003cp\u003eExample\u003c/p\u003e\u003cpre\u003e Input:  \"0y n4036c2 2ey 5s br62en!\"\r\n Output: \"my numlock key is broken!\"\u003c/pre\u003e\u003cp\u003eHappy decoding!\u003c/p\u003e","function_template":"function y = DecodeNumlk(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = '0y n4036c2 2ey 5s br62en!';\r\ny_correct = 'my numlock key is broken!';\r\nassert(isequal(DecodeNumlk(x),y_correct));\r\n\r\n%%\r\nx = 'Can y64 *3ease he3* 0e+';\r\ny_correct = 'Can you please help me?';\r\nassert(isequal(DecodeNumlk(x),y_correct));\r\n\r\n%%\r\nx = 'Th5s 5s g65ng t6 be b5g f4n w5th n40ber 2eys 123456789/';\r\ny_correct = 'This is going to be big fun with number keys 1234567890';\r\nassert(isequal(DecodeNumlk(x),y_correct));\r\n\r\n%%\r\nx = 'Why these 2eys brea2 and 0a2e a b5g 0ess 6***s -/';\r\ny_correct = 'Why these keys break and make a big mess oppps :)';\r\nassert(isequal(DecodeNumlk(x),y_correct));\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":7,"created_by":16381,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":58,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2014-03-02T03:23:21.000Z","updated_at":"2026-03-29T03:18:37.000Z","published_at":"2014-03-02T03:24:59.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\u003eThe numlock key on my computer is pressed and is now broken, so I cant press it to switch off the numlock mode. And hence I am not able to read whatever I am typing. Can you help me decode what I am typing?\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\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:  \\\"0y n4036c2 2ey 5s br62en!\\\"\\n Output: \\\"my numlock key is broken!\\\"]]\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\u003eHappy decoding!\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":2309,"title":"Calculate the Damerau-Levenshtein distance between two strings.","description":"\u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/2303-compute-hamming-distances-between-each-pair-of-rows-from-two-input-matrices Problem 2303\u003e reminded me a few older ones dealing with metrics between strings, problems \u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/93-calculate-the-levenshtein-distance-between-two-strings 93\u003e,\r\n\u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/846-calculate-the-hamming-distance-between-two-strings 846\u003e or\r\n\u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/848-calculate-a-modified-levenshtein-distance-between-two-strings 848\u003e\r\n about Hamming and Levenshtein distances.\r\n\r\n\u003chttp://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance Damerau-Levenshtein distance\u003e is an extension to Levenshtein distance. It is also defined as minimum number of simple edit operations on string to change it into another, but the list of allowed operations is extended.\r\n\r\nAs it is written on Wikipedia there are 4 allowed edits: deletion, insertion and substitution of an single character and an transposition of two adjacent characters.\r\n\r\nExample. Such defined distance between words _gifts_ and _profit_ is 5:\r\n\r\n  gifts   =\u003e pgifts    (insertion of 'p')\r\n  pgifts  =\u003e prgifts   (insertion of 'r')\r\n  prgifts =\u003e proifts   (substitution of 'g' to 'o')\r\n  proifts =\u003e profits   (transposition of 'if' to 'fi')\r\n  profits =\u003e profit    (deletion of 's')\r\n  \r\n\r\n","description_html":"\u003cp\u003e\u003ca href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/2303-compute-hamming-distances-between-each-pair-of-rows-from-two-input-matrices\"\u003eProblem 2303\u003c/a\u003e reminded me a few older ones dealing with metrics between strings, problems \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/93-calculate-the-levenshtein-distance-between-two-strings\"\u003e93\u003c/a\u003e, \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/846-calculate-the-hamming-distance-between-two-strings\"\u003e846\u003c/a\u003e or \u003ca href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/848-calculate-a-modified-levenshtein-distance-between-two-strings\"\u003e848\u003c/a\u003e\r\n about Hamming and Levenshtein distances.\u003c/p\u003e\u003cp\u003e\u003ca href = \"http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance\"\u003eDamerau-Levenshtein distance\u003c/a\u003e is an extension to Levenshtein distance. It is also defined as minimum number of simple edit operations on string to change it into another, but the list of allowed operations is extended.\u003c/p\u003e\u003cp\u003eAs it is written on Wikipedia there are 4 allowed edits: deletion, insertion and substitution of an single character and an transposition of two adjacent characters.\u003c/p\u003e\u003cp\u003eExample. Such defined distance between words \u003ci\u003egifts\u003c/i\u003e and \u003ci\u003eprofit\u003c/i\u003e is 5:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003egifts   =\u0026gt; pgifts    (insertion of 'p')\r\npgifts  =\u0026gt; prgifts   (insertion of 'r')\r\nprgifts =\u0026gt; proifts   (substitution of 'g' to 'o')\r\nproifts =\u0026gt; profits   (transposition of 'if' to 'fi')\r\nprofits =\u0026gt; profit    (deletion of 's')\r\n\u003c/pre\u003e","function_template":"function distance = Damerau_Levenshtein(str1,str2)\r\n  distance = 0;\r\nend","test_suite":"%%\r\nassert(isequal(Damerau_Levenshtein('mom','dad'),3));\r\n% 3 substitutions\r\n%%\r\nassert(isequal(Damerau_Levenshtein('dogs','dog'),1));\r\n% 1 deletion\r\n%%\r\nassert(isequal(Damerau_Levenshtein('true','true'),0));\r\n% identity\r\n%%\r\nassert(isequal(Damerau_Levenshtein('true','false'),4));\r\n% 1 insertion, 3 substitutions\r\n%%\r\nassert(isequal(Damerau_Levenshtein('abc','ca'),2));\r\n% 1 deletion, 1 transposition\r\n%%\r\nassert(isequal(Damerau_Levenshtein('tee','tree'),1));\r\n%%\r\nassert(isequal(Damerau_Levenshtein('email','mails'),2));\r\n%%\r\nassert(isequal(Damerau_Levenshtein('profit','gifts'),5));\r\n%%\r\n% symmetry\r\nrnd=@()char(randi([97 122],1,randi([4 10])));\r\nfor k=1:10\r\n  str1=rnd();\r\n  str2=rnd();\r\n  a=Damerau_Levenshtein(str1,str2);\r\n  b=Damerau_Levenshtein(str2,str1);\r\n  assert(isequal(a,b))\r\nend\r\n%%\r\n% trinagle inequality\r\nrnd=@()char(randi([97 122],1,randi([4 10])));\r\nfor k=1:50\r\n  str1=rnd();\r\n  str2=rnd();\r\n  str3=rnd();\r\n  a=Damerau_Levenshtein(str2,str3);\r\n  b=Damerau_Levenshtein(str3,str1);\r\n  c=Damerau_Levenshtein(str1,str2);\r\n  assert(a+b\u003e=c)\r\nend","published":true,"deleted":false,"likes_count":1,"comments_count":8,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":45,"test_suite_updated_at":"2014-05-07T12:40:15.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-05-07T12:34:17.000Z","updated_at":"2026-03-26T02:24:43.000Z","published_at":"2014-05-07T12:40:15.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:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/cody/problems/2303-compute-hamming-distances-between-each-pair-of-rows-from-two-input-matrices\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 2303\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e reminded me a few older ones dealing with metrics between strings, problems\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.co.uk/matlabcentral/cody/problems/93-calculate-the-levenshtein-distance-between-two-strings\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e93\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\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/cody/problems/846-calculate-the-hamming-distance-between-two-strings\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e846\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e or\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.co.uk/matlabcentral/cody/problems/848-calculate-a-modified-levenshtein-distance-between-two-strings\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e848\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e about Hamming and Levenshtein distances.\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:hyperlink w:docLocation=\\\"http://en.wikipedia.org/wiki/Damerau%E2%80%93Levenshtein_distance\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eDamerau-Levenshtein distance\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e is an extension to Levenshtein distance. It is also defined as minimum number of simple edit operations on string to change it into another, but the list of allowed operations is extended.\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 it is written on Wikipedia there are 4 allowed edits: deletion, insertion and substitution of an single character and an transposition of two adjacent characters.\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\u003eExample. Such defined distance between words\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003egifts\u003c/w:t\u003e\u003c/w:r\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:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eprofit\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is 5:\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[gifts   =\u003e pgifts    (insertion of 'p')\\npgifts  =\u003e prgifts   (insertion of 'r')\\nprgifts =\u003e proifts   (substitution of 'g' to 'o')\\nproifts =\u003e profits   (transposition of 'if' to 'fi')\\nprofits =\u003e profit    (deletion of 's')]]\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":2361,"title":"Find the longest match inside two strings","description":"Given two strings, find the longest string which is contained within both strings.\r\n\r\ne.g. the longest string that is contained in the words 'banana' and 'anagram' is 'ana'\r\n\r\nIf there is no match, return an empty string.","description_html":"\u003cp\u003eGiven two strings, find the longest string which is contained within both strings.\u003c/p\u003e\u003cp\u003ee.g. the longest string that is contained in the words 'banana' and 'anagram' is 'ana'\u003c/p\u003e\u003cp\u003eIf there is no match, return an empty string.\u003c/p\u003e","function_template":"function y = substrmatch(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfirst = 'minimum';\r\nsecond = 'maximum';\r\nmatch = substrmatch( first, second );\r\nassert( strcmp( match, 'imum' ) )\r\n%%\r\nfirst = 'aabbcc';\r\nsecond = 'abc';\r\nmatch = substrmatch( first, second );\r\nassert( strcmp( match, 'ab' ) || strcmp( match, 'bc' ) )\r\n%%\r\nfirst = 'MATLAB';\r\nsecond = 'LAPACK';\r\nmatch = substrmatch( first, second );\r\nassert( strcmp( match, 'LA' ) )\r\n%%\r\nfirst = 'abc';\r\nsecond = 'def';\r\nmatch = substrmatch( first, second );\r\nassert( strcmp( match, '' ) )\r\n%%\r\nfirst = 'banana';\r\nsecond = 'anagram';\r\nmatch = substrmatch( first, second );\r\nassert( strcmp( match, 'ana' ) )\r\n%%\r\nfirst = 'string within a string';\r\nsecond = 'within';\r\nmatch = substrmatch( first, second );\r\nassert( strcmp( match, 'within' ) )\r\n%%\r\nfirst = 'yes and no';\r\nsecond = 'ankles and noses';\r\nmatch = substrmatch( first, second );\r\nassert( strcmp( match, 'es and no' ) )\r\n%%\r\nfirst = 'three apples';\r\nsecond = 'one apple';\r\nmatch = substrmatch( first, second );\r\nassert( strcmp( match, 'e apple' ) )\r\n%%\r\nfirst = 'hello there';\r\nsecond = 'jello that';\r\nmatch = substrmatch( first, second );\r\nassert( strcmp( match, 'ello th' ) )","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":450,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":62,"test_suite_updated_at":"2017-09-27T15:53:47.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-06-12T19:25:50.000Z","updated_at":"2026-03-19T20:09:13.000Z","published_at":"2014-06-12T19:26:02.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eGiven two strings, find the longest string which is contained within both strings.\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\u003ee.g. the longest string that is contained in the words 'banana' and 'anagram' is 'ana'\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\u003eIf there is no match, return an empty 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":2364,"title":"Convert a vector into numbers","description":"Suppose a vector x = [ 1 2 4 7] is given. You have to convert this vector into string number y = '1247'.\r\n\r\nExamples\r\n\r\n x = [ 1 3 5 6 ] \r\n y = '1356'\r\n \r\n x = [ 2 5 7 23] \r\n y = '25723'","description_html":"\u003cp\u003eSuppose a vector x = [ 1 2 4 7] is given. You have to convert this vector into string number y = '1247'.\u003c/p\u003e\u003cp\u003eExamples\u003c/p\u003e\u003cpre\u003e x = [ 1 3 5 6 ] \r\n y = '1356'\u003c/pre\u003e\u003cpre\u003e x = [ 2 5 7 23] \r\n y = '25723'\u003c/pre\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\n\r\nx = [1 2 3];\r\ny_correct = '123';\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\n \r\nx = [7 8 8 0 3];\r\ny_correct = '78803';\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = [8 4];\r\ny_correct = '84';\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = [1 2 1 1 8 5];\r\ny_correct = '121185';\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = [1 8 6 3];\r\ny_correct = '1863';\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = [4 0 2 1];\r\ny_correct = '4021';\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = [2 4];\r\ny_correct = '24';\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = 9;\r\ny_correct = '9';\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n ","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":27280,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":216,"test_suite_updated_at":"2014-06-17T15:44:20.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-06-16T05:32:55.000Z","updated_at":"2026-03-23T20:32:34.000Z","published_at":"2014-06-16T05:36:43.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\u003eSuppose a vector x = [ 1 2 4 7] is given. You have to convert this vector into string number y = '1247'.\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\u003eExamples\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[ x = [ 1 3 5 6 ] \\n y = '1356'\\n\\n x = [ 2 5 7 23] \\n y = '25723']]\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":2469,"title":"Cat, Meowcat and Concatenation","description":"Input is a cell array containing several strings. Find the largest continuous sub-string common to all strings. All strings are in lower case and unique answer exists.\r\nExample:\r\nin = {'cat','meowcat','concatenation'};\r\nout = 'cat';","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: 122.867px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 61.4333px; transform-origin: 407px 61.4333px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; 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 21px; text-align: left; transform-origin: 384px 21px; 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: 383px 8px; transform-origin: 383px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInput is a cell array containing several strings. Find the largest continuous sub-string common to all strings. All strings are in lower case and unique answer exists.\u003c/span\u003e\u003c/span\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: 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: 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: 156px 8.5px; tab-size: 4; transform-origin: 156px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 24px 8.5px; transform-origin: 24px 8.5px; \"\u003ein = {\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: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003e'cat'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e,\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: 36px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 36px 8.5px; \"\u003e'meowcat'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e,\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: 60px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 60px 8.5px; \"\u003e'concatenation'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 8px 8.5px; transform-origin: 8px 8.5px; \"\u003e};\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: 48px 8.5px; tab-size: 4; transform-origin: 48px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 24px 8.5px; transform-origin: 24px 8.5px; \"\u003eout = \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: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003e'cat'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = commonS(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = {'cat','meowcat','concatenation'};\r\ny_correct = 'cat';\r\nassert(isequal(commonS(x),y_correct))\r\n\r\n%%\r\nx = {'zzzyyyzzz','meowcat','concatenation'};\r\ny_correct = '';\r\nassert(isequal(commonS(x),y_correct))\r\n\r\n%%\r\nx = {'pur','purr'};\r\ny_correct = 'pur';\r\nassert(isequal(commonS(x),y_correct))\r\n\r\n%%\r\nx = {'meowcat','owl','bowl'};\r\ny_correct = 'ow';\r\nassert(isequal(commonS(x),y_correct))\r\n\r\n%%\r\nx = {'adoga','ssdogss','ppdogppp'};\r\ny_correct = 'dog';\r\nassert(isequal(commonS(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":3,"created_by":17203,"edited_by":223089,"edited_at":"2022-05-02T06:01:18.000Z","deleted_by":null,"deleted_at":null,"solvers_count":60,"test_suite_updated_at":"2022-05-02T06:01:18.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-07-29T08:09:10.000Z","updated_at":"2026-03-25T21:06:04.000Z","published_at":"2014-07-29T08:09:10.000Z","restored_at":null,"restored_by":null,"spam":null,"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\u003eInput is a cell array containing several strings. Find the largest continuous sub-string common to all strings. All strings are in lower case and unique answer exists.\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[in = {'cat','meowcat','concatenation'};\\nout = 'cat';]]\u003e\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\"}]}"},{"id":2512,"title":"longest common semi-substring","description":"Finding longest common substring is a common problem in string processing. This problem is a variant of that.\r\nTwo strings are given. Find the length of longest common substring between these two that start and end with the same characters. Characters in the middle may not be same. Length of the two sub-strings should be equal.\r\nExample:\r\nstr1 = 'party';\r\nsrt2 = 'pure';\r\nHere, 'par' and 'pur' are two substrings from str1 and str2 that start and end with same characters. Here, length is 3.","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: 183.867px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 91.9333px; transform-origin: 407px 91.9333px; 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: 346px 8px; transform-origin: 346px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFinding longest common substring is a common problem in string processing. This problem is a variant of that.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; 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 21px; text-align: left; transform-origin: 384px 21px; 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: 376.5px 8px; transform-origin: 376.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eTwo strings are given. Find the length of longest common substring between these two that start and end with the same characters. Characters in the middle may not be same. Length of the two sub-strings should be equal.\u003c/span\u003e\u003c/span\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: 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: 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: 60px 8.5px; tab-size: 4; transform-origin: 60px 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; \"\u003estr1 = \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: 28px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 28px 8.5px; \"\u003e'party'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e;\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: 56px 8.5px; tab-size: 4; transform-origin: 56px 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; \"\u003esrt2 = \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: 24px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 24px 8.5px; \"\u003e'pure'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 4px 8.5px; transform-origin: 4px 8.5px; \"\u003e;\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: 363.5px 8px; transform-origin: 363.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHere, 'par' and 'pur' are two substrings from str1 and str2 that start and end with same characters. Here, length is 3.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = str(x)\r\n  y = x;\r\nend","test_suite":"%%\r\na = 'cat';\r\nb = 'cat'\r\ny_correct = 3;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n%%\r\na = 'cat';\r\nb = 'cut'\r\ny_correct = 3;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'president';\r\nb = 'precedent'\r\ny_correct = 9;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n%%\r\na =  'katy perry';\r\nb = 'qqa^%^%rrrrRR'\r\ny_correct = 8;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'cody was down for a while';\r\nb = '12w123456789o88888888899'\r\ny_correct = 11;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'cat';\r\nb = 'dog and other pets'\r\ny_correct = 1;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n%%\r\na = 'cat';\r\nb = 'aca'\r\ny_correct = 2;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n\r\n%%\r\na = 'apparently nothing in common';\r\nb = 'zzzz zz zzzz'\r\ny_correct = 4;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'nothing in common';\r\nb = 'zzzz'\r\ny_correct = 0;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n\r\n%%\r\na = 'empty string testing';\r\nb = '';\r\ny_correct = 0;\r\nassert(isequal(str(a,b),y_correct))\r\n\r\n%%\r\na = '';\r\nb = '';\r\ny_correct = 0;\r\nassert(isequal(str(a,b),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":17203,"edited_by":223089,"edited_at":"2022-04-30T19:20:34.000Z","deleted_by":null,"deleted_at":null,"solvers_count":50,"test_suite_updated_at":"2014-08-16T04:00:53.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-08-15T08:09:29.000Z","updated_at":"2026-03-19T20:11:28.000Z","published_at":"2014-08-15T08:09:29.000Z","restored_at":null,"restored_by":null,"spam":null,"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\u003eFinding longest common substring is a common problem in string processing. This problem is a variant of that.\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\u003eTwo strings are given. Find the length of longest common substring between these two that start and end with the same characters. Characters in the middle may not be same. Length of the two sub-strings should be equal.\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[str1 = 'party';\\nsrt2 = 'pure';]]\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\u003eHere, 'par' and 'pur' are two substrings from str1 and str2 that start and end with same characters. Here, length is 3.\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\"}]}"},{"id":2513,"title":"Genome decoding","description":"Inspired by a question on the answer forum:\r\n\r\nYou are given a matrix of 8-bit integers which encodes a genome. Each integer can be converted into a sequence by converting it first to binary and then converting bit pairs using the rule A = 00, C = 01, T = 10, G = 11. \r\nFor example, 177 -\u003e 10110001 -\u003e TGAC. \r\n\r\nConvert the matrix into a cell array of sequences.\r\n\r\nstr2num and regexp not allowed.","description_html":"\u003cp\u003eInspired by a question on the answer forum:\u003c/p\u003e\u003cp\u003eYou are given a matrix of 8-bit integers which encodes a genome. Each integer can be converted into a sequence by converting it first to binary and then converting bit pairs using the rule A = 00, C = 01, T = 10, G = 11. \r\nFor example, 177 -\u0026gt; 10110001 -\u0026gt; TGAC.\u003c/p\u003e\u003cp\u003eConvert the matrix into a cell array of sequences.\u003c/p\u003e\u003cp\u003estr2num and regexp not allowed.\u003c/p\u003e","function_template":"function [sequences] = decode_genome(genome)\r\n    sequences = 'ACTG';\r\nend","test_suite":"%%\r\nuser_solution = fileread('decode_genome.m');\r\nassert(isempty(strfind(user_solution,'regexp')));\r\nassert(isempty(strfind(user_solution,'str2num')));\r\n\r\n%%\r\ngenome = [\r\n   228    24    40    36   167\r\n   231    71   248   107     9\r\n    32   140   245   234   217\r\n   233     0   124   202   239\r\n   161   247   204   255   173];\r\nsequences = {\r\n    'GTCA'    'ACTA'    'ATTA'    'ATCA'    'TTCG'\r\n    'GTCG'    'CACG'    'GGTA'    'CTTG'    'AATC'\r\n    'ATAA'    'TAGA'    'GGCC'    'GTTT'    'GCTC'\r\n    'GTTC'    'AAAA'    'CGGA'    'GATT'    'GTGG'\r\n    'TTAC'    'GGCG'    'GAGA'    'GGGG'    'TTGC'};\r\nassert(isequal(sequences, decode_genome(genome)));\r\n\r\n%%\r\ngenome = [1 4 16 64; 234 186 174 171];\r\nsequences = {'AAAC' 'AACA' 'ACAA' 'CAAA'; 'GTTT' 'TGTT' 'TTGT' 'TTTG'};\r\nassert(isequal(sequences, decode_genome(genome)));\r\n\r\n%%\r\ngenome = [228 225 216 210 198 201 180 177 156 147 135 141 108 99 120 114 78 75 39 45 27 30 54 57]';\r\nsequences = {'GTCA' 'GTAC' 'GCTA' 'GCAT' 'GACT' 'GATC' 'TGCA' 'TGAC' 'TCGA' 'TCAG' 'TACG' 'TAGC' 'CTGA' 'CTAG' 'CGTA' 'CGAT' 'CAGT' 'CATG' 'ATCG' 'ATGC' 'ACTG' 'ACGT' 'AGCT' 'AGTC'}';\r\nassert(isequal(sequences, decode_genome(genome)));","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":999,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2014-08-17T10:20:31.000Z","updated_at":"2026-03-19T20:07:27.000Z","published_at":"2014-08-17T10:20: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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eInspired by a question on the answer forum:\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\u003eYou are given a matrix of 8-bit integers which encodes a genome. Each integer can be converted into a sequence by converting it first to binary and then converting bit pairs using the rule A = 00, C = 01, T = 10, G = 11. For example, 177 -\u0026gt; 10110001 -\u0026gt; TGAC.\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\u003eConvert the matrix into a cell array of sequences.\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\u003estr2num and regexp not allowed.\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":2523,"title":"longest common substring : Skipped character version","description":"Two strings are given. Find the longest common substring between them. The substring characters need not be adjacent. They, however, must appear in same order in both input strings.\r\n\r\nExample:\r\n\r\n  str1 = 'abcdefghi';\r\n  str2 = 'zazbzczd';\r\n  \r\n  output = 'abcd'","description_html":"\u003cp\u003eTwo strings are given. Find the longest common substring between them. The substring characters need not be adjacent. They, however, must appear in same order in both input strings.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003estr1 = 'abcdefghi';\r\nstr2 = 'zazbzczd';\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eoutput = 'abcd'\r\n\u003c/pre\u003e","function_template":"function y = skipped(str1,str2)\r\n  y = x;\r\nend","test_suite":"%%\r\nstr1 = 'abcdefghi';\r\nstr2 = 'zazbzczd';\r\ny_correct = 'abcd';\r\nassert(isequal(skipped(str1,str2),y_correct))\r\n\r\n%%\r\nstr1 = 'abcdefghi';\r\nstr2 = 'zzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzzz';\r\ny_correct = '';\r\nassert(isequal(skipped(str1,str2),y_correct))\r\n\r\n\r\n\r\n%%\r\nstr1 = 'catcatcat';\r\nstr2 = 'catcatcat';\r\ny_correct = str1;\r\nassert(isequal(skipped(str1,str2),y_correct))\r\n\r\n\r\n%%\r\nstr1 = 'an example of a string';\r\nstr2 = 'the example z a s t r i i i n ssss';\r\ny_correct = ' example  a strin';\r\nassert(isequal(skipped(str1,str2),y_correct))\r\n\r\n\r\n%%\r\nstr1 = 'a string with many characters';\r\nstr2 = 'zzz zzz zzz zzz zzz';\r\ny_correct = '    ';\r\nassert(isequal(skipped(str1,str2),y_correct))\r\n\r\n\r\n%%\r\nstr1 = 'lets!not!use!spaces';\r\nstr2 = 'z!zzzzzzzzZZZzZzZ!zzzzz!zzzzzzzzz!!!!!!!!!zzz';\r\ny_correct = '!!!';\r\nassert(isequal(skipped(str1,str2),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":4,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":52,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2014-08-20T10:44:21.000Z","updated_at":"2026-03-26T03:20:58.000Z","published_at":"2014-08-20T10:44:21.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\u003eTwo strings are given. Find the longest common substring between them. The substring characters need not be adjacent. They, however, must appear in same order in both input strings.\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\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[str1 = 'abcdefghi';\\nstr2 = 'zazbzczd';\\n\\noutput = 'abcd']]\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":2601,"title":"Concatenate string with cell array of strings","description":"Given a cell array of strings (a), a target string (b), and a target position (ind), return a cell array of strings (c) in which the target string has been inserted starting at the target position in each of the cells.\r\n\r\n*Assumptions*\r\n\r\n* _ind_ is a scalar\r\n* _ind_ \u003e 0\r\n* _ind_ \u003c= (minimum length of a string in _a_) + 1\r\n\r\n*Example*\r\n\r\nIf\r\n\r\n  a = {'filename1';\r\n       'filename2';\r\n       'filename3'};\r\n  b = '_';\r\n  ind = 9;\r\n\r\nThen\r\n\r\n  c = {'filename_1';\r\n       'filename_2';\r\n       'filename_3'};\r\n","description_html":"\u003cp\u003eGiven a cell array of strings (a), a target string (b), and a target position (ind), return a cell array of strings (c) in which the target string has been inserted starting at the target position in each of the cells.\u003c/p\u003e\u003cp\u003e\u003cb\u003eAssumptions\u003c/b\u003e\u003c/p\u003e\u003cul\u003e\u003cli\u003e\u003ci\u003eind\u003c/i\u003e is a scalar\u003c/li\u003e\u003cli\u003e\u003ci\u003eind\u003c/i\u003e \u0026gt; 0\u003c/li\u003e\u003cli\u003e\u003ci\u003eind\u003c/i\u003e \u0026lt;= (minimum length of a string in \u003ci\u003ea\u003c/i\u003e) + 1\u003c/li\u003e\u003c/ul\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cp\u003eIf\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ea = {'filename1';\r\n     'filename2';\r\n     'filename3'};\r\nb = '_';\r\nind = 9;\r\n\u003c/pre\u003e\u003cp\u003eThen\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ec = {'filename_1';\r\n     'filename_2';\r\n     'filename_3'};\r\n\u003c/pre\u003e","function_template":"function c = cellstrcat(a,b,ind)\r\n  c = a;\r\nend","test_suite":"%%\r\na = {'filename1';'filename2';'filename3'};\r\nb = '_';\r\nind = 9;\r\nc = {'filename_1';'filename_2';'filename_3'};\r\nassert(isequal(cellstrcat(a,b,ind),c))\r\n\r\n%%\r\na = {'1';'2';'3';'4';'5'};\r\nb = 'filename_';\r\nind = 1;\r\nc = {'filename_1';'filename_2';'filename_3';'filename_4';'filename_5'};\r\nassert(isequal(cellstrcat(a,b,ind),c))\r\n\r\n%%\r\na = {'foo';'bar';'baz';'qux'};\r\nb = '.mat';\r\nind = 4;\r\nc = {'foo.mat';'bar.mat';'baz.mat';'qux.mat'};\r\nassert(isequal(cellstrcat(a,b,ind),c))\r\n\r\n%%\r\na = {'data1','data23','data456','data7890'};\r\nd = datestr(now,'yyyymmdd');\r\nb = strcat('_',d,'_');\r\nind = 5;\r\nc{1} = ['data_',d,'_1'];\r\nc{2} = ['data_',d,'_23'];\r\nc{3} = ['data_',d,'_456'];\r\nc{4} = ['data_',d,'_7890'];\r\nassert(isequal(cellstrcat(a,b,ind),c))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":4793,"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":"2014-09-23T19:58:43.000Z","updated_at":"2026-03-28T02:38:37.000Z","published_at":"2014-09-23T20:35:20.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\u003eGiven a cell array of strings (a), a target string (b), and a target position (ind), return a cell array of strings (c) in which the target string has been inserted starting at the target position in each of the cells.\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eAssumptions\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is a scalar\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u0026gt; 0\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eind\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u0026lt;= (minimum length of a string in\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ea\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e) + 1\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf\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[a = {'filename1';\\n     'filename2';\\n     'filename3'};\\nb = '_';\\nind = 9;]]\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\u003eThen\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[c = {'filename_1';\\n     'filename_2';\\n     'filename_3'};]]\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":2602,"title":"Did you say please? - Find one string within another without strfind or regexp/regexpi","description":"For a given string sentence, determine if the string word 'please' is present or not. If so, return the string 'OK', else return '...'. The function should not be case sensitive. Please do not use the strfind or regexp/regexpi functions in your solution.\r\n\r\nExample:\r\n\r\n  reply = please('Help me with my homework!')\r\n  reply = '...'\r\n              \r\n  reply = please('Please help me with my homework')\r\n  reply = 'OK'","description_html":"\u003cp\u003eFor a given string sentence, determine if the string word 'please' is present or not. If so, return the string 'OK', else return '...'. The function should not be case sensitive. Please do not use the strfind or regexp/regexpi functions in your solution.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ereply = please('Help me with my homework!')\r\nreply = '...'\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003ereply = please('Please help me with my homework')\r\nreply = 'OK'\r\n\u003c/pre\u003e","function_template":"function reply = please(question)\r\n  reply = '...';\r\nend","test_suite":"%%\r\nuser_solution = fileread('please.m');\r\nassert(isempty(strfind(user_solution,'strfind')));\r\nassert(isempty(strfind(user_solution,'regexp')));\r\nassert(isempty(strfind(user_solution,'regexpi')));\r\n\r\n%%\r\nx = 'Can you do my homework for me?';\r\ny_correct = '...';\r\nassert(isequal(please(x),y_correct))\r\n\r\n%%\r\nx = 'Please, can you do my homework for me?';\r\ny_correct = 'OK';\r\nassert(isequal(please(x),y_correct))\r\n\r\n%%\r\nx = 'Come on Tuesday morning, please!';\r\ny_correct = 'OK';\r\nassert(isequal(please(x),y_correct))\r\n\r\n%%\r\nx = 'PLEASE, HELP ME!!!';\r\ny_correct = 'OK';\r\nassert(isequal(please(x),y_correct))\r\n\r\n%%\r\nx = 'Pleased to see you again, could you give me a hand?';\r\ny_correct = '...';\r\nassert(isequal(please(x),y_correct))\r\n\r\n%%\r\nx = 'Pleased to see you again, could you please give me a hand?';\r\ny_correct = 'OK';\r\nassert(isequal(please(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":10900,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":71,"test_suite_updated_at":"2014-09-26T01:43:39.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-09-24T12:48:03.000Z","updated_at":"2026-03-25T22:06:44.000Z","published_at":"2014-09-24T13:38:41.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\u003eFor a given string sentence, determine if the string word 'please' is present or not. If so, return the string 'OK', else return '...'. The function should not be case sensitive. Please do not use the strfind or regexp/regexpi functions in your solution.\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\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[reply = please('Help me with my homework!')\\nreply = '...'\\n\\nreply = please('Please help me with my homework')\\nreply = 'OK']]\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":2606,"title":"Decrypt the  cypher using XOR encryption (for beginners)","description":"Inspired by Project Euler n°59\r\n\r\nEach character on a computer is assigned a unique code and the preferred standard is ASCII \r\n(American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, \r\nand lowercase k = 107.\r\nA basic encryption method is to take a text file or a sentence, convert the bytes to ASCII, then XOR each byte with a given \r\nvalue, taken from a secret key. The advantage with the XOR function is that using the same encryption key on the \r\ncipher text, restores the plain text; for example, 65 XOR 42 = 107, then 107 XOR 42 = 65.\r\n    \r\nYour task has been made easy, as the encryption key consists only of a upper case character (different in every tests). \r\nYou must know that the original text contains common FRENCH words about MATLAB.\r\n\r\nDecrypt the message and find the sum of the ASCII values in the original text.","description_html":"\u003cp\u003eInspired by Project Euler n°59\u003c/p\u003e\u003cp\u003eEach character on a computer is assigned a unique code and the preferred standard is ASCII \r\n(American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, \r\nand lowercase k = 107.\r\nA basic encryption method is to take a text file or a sentence, convert the bytes to ASCII, then XOR each byte with a given \r\nvalue, taken from a secret key. The advantage with the XOR function is that using the same encryption key on the \r\ncipher text, restores the plain text; for example, 65 XOR 42 = 107, then 107 XOR 42 = 65.\u003c/p\u003e\u003cp\u003eYour task has been made easy, as the encryption key consists only of a upper case character (different in every tests). \r\nYou must know that the original text contains common FRENCH words about MATLAB.\u003c/p\u003e\u003cp\u003eDecrypt the message and find the sum of the ASCII values in the original text.\u003c/p\u003e","function_template":"function y = XOR_cypher(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx=[15 3 22 14 3 0 236 98 39 49 54 98 55 44 98 46 35 44 37 35 37 39 98 38 39 98 42 35 55 54 98 44 43 52 39 35 55];\r\ny_correct=3360;\r\nassert(isequal(XOR_cypher(x),y_correct))\r\n%%\r\nx=[29 40 184 57 63 122 186 122 23 27 14 22 27 24 118 122 44 53 47 41 122 42 53 47 44 63 32 122 59 52 59 54 35 41 63 40 122 62 63 41 122 62 53 52 52 179 63 41 116];\r\ny_correct=4783;\r\nassert(isequal(XOR_cypher(x),y_correct))\r\n%%\r\nx=[28 33 41 53 54 43 60 35 117 121 47 48 42 44 56 53 48 42 60 35 121 60 45 121 52 54 61 176 53 48 42 60 35 121 47 54 42 121 61 54 55 55 176 60 42 121 56 47 60 58 121 20 24 13 21 24 27 119];\r\ny_correct=5667;\r\nassert(isequal(XOR_cypher(x),y_correct))\r\n%%\r\nx=[11 39 50 42 39 36 124 102 42 35 102 42 39 40 33 39 33 35 102 34 51 102 37 39 42 37 51 42 102 53 37 47 35 40 50 47 55 51 35];\r\ny_correct=3666;\r\nassert(isequal(XOR_cypher(x),y_correct))\r\n%%\r\nx=[27 36 62 57 58 62 36 34 107 40 35 36 56 34 57 107 6 42 63 39 42 41 107 46 63 107 59 42 56 107 27 50 63 35 36 37 107 116];\r\ny_correct=3547;\r\nassert(isequal(XOR_cypher(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":5390,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2014-09-27T10:32:11.000Z","updated_at":"2026-03-19T21:22:18.000Z","published_at":"2014-09-27T10:33:19.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eInspired by Project Euler n°59\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\u003eEach character on a computer is assigned a unique code and the preferred standard is ASCII (American Standard Code for Information Interchange). For example, uppercase A = 65, asterisk (*) = 42, and lowercase k = 107. A basic encryption method is to take a text file or a sentence, convert the bytes to ASCII, then XOR each byte with a given value, taken from a secret key. The advantage with the XOR function is that using the same encryption key on the cipher text, restores the plain text; for example, 65 XOR 42 = 107, then 107 XOR 42 = 65.\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\u003eYour task has been made easy, as the encryption key consists only of a upper case character (different in every tests). You must know that the original text contains common FRENCH words about MATLAB.\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\u003eDecrypt the message and find the sum of the ASCII values in the original text.\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":2625,"title":"Shorten pathname","description":"Given a pathname string, return a condensed version by replacing intermediate folders with '..'.\r\n\r\n*Example*\r\n\r\nIf\r\n\r\n  fullpath = 'C:\\foo\\bar\\baz\\qux';\r\n\r\nthen\r\n\r\n  shortpath = 'C:\\..\\qux';","description_html":"\u003cp\u003eGiven a pathname string, return a condensed version by replacing intermediate folders with '..'.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e\u003c/p\u003e\u003cp\u003eIf\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003efullpath = 'C:\\foo\\bar\\baz\\qux';\r\n\u003c/pre\u003e\u003cp\u003ethen\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eshortpath = 'C:\\..\\qux';\r\n\u003c/pre\u003e","function_template":"function y = shorten(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'C:\\foo\\bar\\baz\\qux';\r\nassert(isequal(shorten(x),'C:\\..\\qux'))\r\n\r\n%%\r\nx = 'this\\is\\just\\a\\test';\r\nassert(isequal(shorten(x),'this\\..\\test'))\r\n\r\n%%\r\nx = 'testing\\testing\\123.mat';\r\nassert(isequal(shorten(x),'testing\\..\\123.mat'))\r\n\r\n%%\r\nx = 'testing\\t1\\t2\\t3\\t4\\t5\\t6\\t7\\t8\\t9\\t10\\123.mat';\r\nassert(isequal(shorten(x),'testing\\..\\123.mat'))\r\n\r\n%%\r\nx = 'corp.company_name.com\\dir1\\dir2\\dir3\\dir4\\file';\r\nassert(isequal(shorten(x),'corp.company_name.com\\..\\file'))\r\n\r\n%%\r\nx = 'dir1\\dir2\\dir3\\d.txt';\r\nassert(isequal(shorten(x),'dir1\\..\\d.txt'))\r\n\r\n%%\r\nx = 'dir1\\dir#2\\dir_3\\dir%4\\dir(5)\\dir+6\\d.txt';\r\nassert(isequal(shorten(x),'dir1\\..\\d.txt'))","published":true,"deleted":false,"likes_count":5,"comments_count":1,"created_by":4793,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":92,"test_suite_updated_at":"2017-09-27T16:08:09.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-10-11T04:40:47.000Z","updated_at":"2026-03-19T19:57:55.000Z","published_at":"2014-10-11T04:40:47.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\u003eGiven a pathname string, return a condensed version by replacing intermediate folders with '..'.\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\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=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf\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[fullpath = 'C:\\\\foo\\\\bar\\\\baz\\\\qux';]]\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\u003ethen\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[shortpath = 'C:\\\\..\\\\qux';]]\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":2653,"title":"Beauty of Parentheses","description":"Given a string consisting of closed parentheses, form a string array in the following way so that the orders of these parentheses are visually apparent.\r\n\r\nExample: \r\n\r\n  str = '(()(()(()(()))))';\r\n  \r\n  out =  {'(              )';\r\n          ' ()(          ) ';\r\n          '    ()(      )  ';\r\n          '       ()(  )   ';\r\n          '          ()    '}\r\n\r\nFor more information, please check the test suite.","description_html":"\u003cp\u003eGiven a string consisting of closed parentheses, form a string array in the following way so that the orders of these parentheses are visually apparent.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003estr = '(()(()(()(()))))';\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eout =  {'(              )';\r\n        ' ()(          ) ';\r\n        '    ()(      )  ';\r\n        '       ()(  )   ';\r\n        '          ()    '}\r\n\u003c/pre\u003e\u003cp\u003eFor more information, please check the test suite.\u003c/p\u003e","function_template":"function out = braces(str)\r\n\r\nend","test_suite":"%%\r\nstr = '(()(()(()(()))))';\r\n\r\nout =  {'(              )';\r\n        ' ()(          ) ';\r\n        '    ()(      )  ';\r\n        '       ()(  )   ';\r\n        '          ()    '}\r\n\r\nassert(isequal(braces(str),out))\r\n\r\n\r\n%%\r\nstr = '()';  % trivial test\r\n\r\nout =  {'()'};\r\n\r\nassert(isequal(braces(str),out))\r\n\r\n\r\n\r\n%%\r\nstr = '((((()))))';\r\n\r\nout =  {'(        )';\r\n        ' (      ) ';\r\n        '  (    )  ';\r\n        '   (  )   ';\r\n        '    ()    '}\r\n\r\nassert(isequal(braces(str),out))\r\n\r\n\r\n%%\r\na = randi(10);\r\nstr = '';\r\nfor i = 1:a\r\n    str = [str '()'];\r\nend\r\nout = {str};\r\nassert(isequal(braces(str),out))\r\n\r\n%%\r\nstr = '()(((())))()';\r\n\r\nout =  {'()(      )()';\r\n        '   (    )   ';\r\n        '    (  )    ';\r\n        '     ()     '}\r\n\r\nassert(isequal(braces(str),out))\r\n\r\n\r\n%%\r\na = randi(10);\r\n\r\nstr = '';\r\nfor i = 1:a\r\n    str = ['(' str ')'];\r\nend\r\n\r\nout = {};\r\nfor i = 1:a\r\n    s = [32*ones(1,i-1) '(' 32*ones(1,2*a-2*i) ')' 32*ones(1,i-1)];\r\n    out = [out; s];\r\nend\r\n\r\nassert(isequal(braces(str),out))\r\n","published":true,"deleted":false,"likes_count":5,"comments_count":2,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":52,"test_suite_updated_at":"2014-11-02T14:35:13.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2014-11-02T08:33:53.000Z","updated_at":"2026-03-29T04:24:55.000Z","published_at":"2014-11-02T08:34:34.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\u003eGiven a string consisting of closed parentheses, form a string array in the following way so that the orders of these parentheses are visually apparent.\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\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[str = '(()(()(()(()))))';\\n\\nout =  {'(              )';\\n        ' ()(          ) ';\\n        '    ()(      )  ';\\n        '       ()(  )   ';\\n        '          ()    '}]]\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 more information, please check the test suite.\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":2683,"title":"Adding Cells with numbers defined as strings","description":"Given a cell, with strings representing numbers, add each value.\r\n\r\nFor example:\r\n\r\na = {'9','33'};\r\n\r\nthe output should be:\r\n\r\ny = 42\r\n\r\n","description_html":"\u003cp\u003eGiven a cell, with strings representing numbers, add each value.\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cp\u003ea = {'9','33'};\u003c/p\u003e\u003cp\u003ethe output should be:\u003c/p\u003e\u003cp\u003ey = 42\u003c/p\u003e","function_template":"function y = addingcells(a)\r\n  y = cellfun(@(x) x,a);\r\nend","test_suite":"%%\r\nx = {'9','33'};\r\ny_correct = 42;\r\nassert(isequal(addingcells(x),y_correct))\r\n\r\n\r\n%%\r\nx = {'9','33'};\r\ny_correct = 42;\r\nassert(isequal(addingcells(x),y_correct))\r\n\r\n%%\r\nx = {'9','33','-12'};\r\ny_correct = 30;\r\nassert(isequal(addingcells(x),y_correct))\r\n\r\n%%\r\nx = {'9','33','122'};\r\ny_correct = 164;\r\nassert(isequal(addingcells(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":4690,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":102,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2014-11-22T17:45:52.000Z","updated_at":"2026-03-19T19:57:12.000Z","published_at":"2014-11-22T17:45:59.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eGiven a cell, with strings representing numbers, add each value.\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\u003eFor example:\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\u003ea = {'9','33'};\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\u003ethe output should be:\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\u003ey = 42\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":2699,"title":"From a given cell array of strings, extract the non-unique strings.","description":"We are given a cell array of strings C. From this cell array we require to extract the subset of non-unique strings, returning the results as a column vector. \r\n\r\nFor example, if C = {'A', 'B', 'C', 'A', 'B'}, then the strings 'A' and 'B' are repeated, so the result should be {'A'; 'B'}. The order of occurrence of the strings should be preserved, so {'B'; 'A'} would not be an acceptable solution. The order of appearance of the strings is defined using the column-major format. For example, if C = {'Jack', 'Bob'; 'Dave', 'Amanda'} then the order of the strings is 'Jack', 'Dave', 'Bob', 'Amanda'.","description_html":"\u003cp\u003eWe are given a cell array of strings C. From this cell array we require to extract the subset of non-unique strings, returning the results as a column vector.\u003c/p\u003e\u003cp\u003eFor example, if C = {'A', 'B', 'C', 'A', 'B'}, then the strings 'A' and 'B' are repeated, so the result should be {'A'; 'B'}. The order of occurrence of the strings should be preserved, so {'B'; 'A'} would not be an acceptable solution. The order of appearance of the strings is defined using the column-major format. For example, if C = {'Jack', 'Bob'; 'Dave', 'Amanda'} then the order of the strings is 'Jack', 'Dave', 'Bob', 'Amanda'.\u003c/p\u003e","function_template":"function repeatedStrings = extractRepeatedStrings(C)\r\n  \r\n\r\n\r\nend","test_suite":"%%\r\nC = {'Ken'; 'GianCarlo'; 'Ken'; 'GianCarlo'; 'Bob'; 'Ken'; 'Sonia'};\r\nrepeatedStrings = {'Ken'; 'GianCarlo'};\r\nassert(isequal(extractRepeatedStrings(C), repeatedStrings))\r\n\r\n%%\r\nC = {'A', 'B', 'C', 'A', 'B'};\r\nrepeatedStrings = {'A'; 'B'};\r\nassert(isequal(extractRepeatedStrings(C), repeatedStrings))\r\n\r\n%%\r\nC = {'B', 'A', 'C', 'B', 'A'};\r\nrepeatedStrings = {'B'; 'A'};\r\nassert(isequal(extractRepeatedStrings(C), repeatedStrings))\r\n\r\n%%\r\nC = {'A', 'B', 'C'};\r\nrepeatedStrings = cell.empty(0, 1);\r\nassert(isequal(extractRepeatedStrings(C), repeatedStrings))\r\n\r\n%%\r\nC = {'A', 'B'; 'C', 'A'; 'B', 'A'};\r\nrepeatedStrings = {'A'; 'B'};\r\nassert(isequal(extractRepeatedStrings(C), repeatedStrings))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":2328,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2014-12-01T16:49:18.000Z","updated_at":"2026-03-19T20:10:22.000Z","published_at":"2014-12-01T16:49:55.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\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"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\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\u003eWe are given a cell array of strings C. From this cell array we require to extract the subset of non-unique strings, returning the results as a column vector.\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\u003eFor example, if C = {'A', 'B', 'C', 'A', 'B'}, then the strings 'A' and 'B' are repeated, so the result should be {'A'; 'B'}. The order of occurrence of the strings should be preserved, so {'B'; 'A'} would not be an acceptable solution. The order of appearance of the strings is defined using the column-major format. For example, if C = {'Jack', 'Bob'; 'Dave', 'Amanda'} then the order of the strings is 'Jack', 'Dave', 'Bob', 'Amanda'.\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":3018,"title":"Calculator spelling - Numbers to Letters","description":"Using the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\r\n\r\n* 0 = O\r\n* 1 = I\r\n* 2 = Z\r\n* 3 = E\r\n* 4 = h\r\n* 5 = S\r\n* 6 = g\r\n* 7 = L\r\n* 8 = B\r\n\r\nThere are a few other options, but we'll stick with these. The number may be a have a decimal with a leading zero, to produce a trailing O. If this is the case, ignore the decimal point. Write a function that takes a number as input and returns the word spelled (upside down) by the calculator. Make sure to get the case (capital vs. lowercase) right for each number/letter.\r\n\r\nThis problem is related to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3019-calculator-spelling-letters-to-numbers Problem 3019\u003e.","description_html":"\u003cp\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/p\u003e\u003cul\u003e\u003cli\u003e0 = O\u003c/li\u003e\u003cli\u003e1 = I\u003c/li\u003e\u003cli\u003e2 = Z\u003c/li\u003e\u003cli\u003e3 = E\u003c/li\u003e\u003cli\u003e4 = h\u003c/li\u003e\u003cli\u003e5 = S\u003c/li\u003e\u003cli\u003e6 = g\u003c/li\u003e\u003cli\u003e7 = L\u003c/li\u003e\u003cli\u003e8 = B\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThere are a few other options, but we'll stick with these. The number may be a have a decimal with a leading zero, to produce a trailing O. If this is the case, ignore the decimal point. Write a function that takes a number as input and returns the word spelled (upside down) by the calculator. Make sure to get the case (capital vs. lowercase) right for each number/letter.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3019-calculator-spelling-letters-to-numbers\"\u003eProblem 3019\u003c/a\u003e.\u003c/p\u003e","function_template":"function [word] = calc_spell_word(n)\r\n\r\nword = num2str(n);\r\n\r\nend\r\n","test_suite":"%%\r\nn = 35007;\r\ntxt = 'LOOSE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 77345;\r\ntxt = 'ShELL';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 36138;\r\ntxt = 'BEIgE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 378806;\r\ntxt = 'gOBBLE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 376006;\r\ntxt = 'gOOgLE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 57738461375;\r\ntxt = 'SLEIghBELLS';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 0.7734;\r\ntxt = 'hELLO';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 53045;\r\ntxt = 'ShOES';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 771;\r\ntxt = 'ILL';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 345;\r\ntxt = 'ShE';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nn = 7735;\r\ntxt = 'SELL';\r\nassert(isequal(calc_spell_word(n),txt))\r\n\r\n%%\r\nind = randi(4);\r\nn_arr = [36138 707 7714 57738];\r\nn = n_arr(ind);\r\ntxt_arr = {'BEIgE','LOL','hILL','BELLS'};\r\ntxt = txt_arr{ind};\r\nassert(isequal(calc_spell_word(n),txt))\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-14T22:05:44.000Z","updated_at":"2026-03-19T20:03:05.000Z","published_at":"2015-02-14T22:05:44.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\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\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\u003e0 = O\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\u003e1 = I\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\u003e2 = Z\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\u003e3 = E\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\u003e4 = h\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\u003e5 = S\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\u003e6 = g\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\u003e7 = L\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\u003e8 = B\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\u003eThere are a few other options, but we'll stick with these. The number may be a have a decimal with a leading zero, to produce a trailing O. If this is the case, ignore the decimal point. Write a function that takes a number as input and returns the word spelled (upside down) by the calculator. Make sure to get the case (capital vs. lowercase) right for each number/letter.\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/3019-calculator-spelling-letters-to-numbers\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3019\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":3019,"title":"Calculator spelling - Letters to Numbers","description":"Using the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\r\n\r\n* 0 = O\r\n* 1 = I\r\n* 2 = Z\r\n* 3 = E\r\n* 4 = h\r\n* 5 = S\r\n* 6 = g\r\n* 7 = L\r\n* 8 = B\r\n\r\nThere are a few other options, but we'll stick with these. If the word has a trailing O, the number will need a decimal point to produce a leading zero. Write a function that takes a word (upside down) as input and returns the number entered into the calculator.\r\n\r\nThis problem is related to \u003chttps://www.mathworks.com/matlabcentral/cody/problems/3018-calculator-spelling-numbers-to-letters Problem 3018\u003e.","description_html":"\u003cp\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\u003c/p\u003e\u003cul\u003e\u003cli\u003e0 = O\u003c/li\u003e\u003cli\u003e1 = I\u003c/li\u003e\u003cli\u003e2 = Z\u003c/li\u003e\u003cli\u003e3 = E\u003c/li\u003e\u003cli\u003e4 = h\u003c/li\u003e\u003cli\u003e5 = S\u003c/li\u003e\u003cli\u003e6 = g\u003c/li\u003e\u003cli\u003e7 = L\u003c/li\u003e\u003cli\u003e8 = B\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eThere are a few other options, but we'll stick with these. If the word has a trailing O, the number will need a decimal point to produce a leading zero. Write a function that takes a word (upside down) as input and returns the number entered into the calculator.\u003c/p\u003e\u003cp\u003eThis problem is related to \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/3018-calculator-spelling-numbers-to-letters\"\u003eProblem 3018\u003c/a\u003e.\u003c/p\u003e","function_template":"function [n] = calc_spell_num(word)\r\n\r\nn = str2num(word);\r\n\r\nend\r\n","test_suite":"%%\r\nn = 35007;\r\nword = 'LOOSE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 77345;\r\nword = 'ShELL';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 36138;\r\nword = 'BEIgE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 378806;\r\nword = 'gOBBLE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 376006;\r\nword = 'gOOgLE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 57738461375;\r\nword = 'SLEIghBELLS';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 0.7734;\r\nword = 'hELLO';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 53045;\r\nword = 'ShOES';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 771;\r\nword = 'ILL';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 345;\r\nword = 'ShE';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nn = 7735;\r\nword = 'SELL';\r\nassert(isequal(calc_spell_num(word),n))\r\n\r\n%%\r\nind = randi(4);\r\nn_arr = [36138 707 7714 57738];\r\nn = n_arr(ind);\r\nword_arr = {'BEIgE','LOL','hILL','BELLS'};\r\nword = word_arr{ind};\r\nassert(isequal(calc_spell_num(word),n))\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":68,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-14T22:18:14.000Z","updated_at":"2026-03-23T20:41:48.000Z","published_at":"2015-02-14T22:18:14.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\u003eUsing the numbers on a calculator, and rotating the display 180 degrees, many words can be spelled. In particular, the following numbers can characterize the following letters:\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\u003e0 = O\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\u003e1 = I\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\u003e2 = Z\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\u003e3 = E\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\u003e4 = h\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\u003e5 = S\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\u003e6 = g\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\u003e7 = L\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\u003e8 = B\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\u003eThere are a few other options, but we'll stick with these. If the word has a trailing O, the number will need a decimal point to produce a leading zero. Write a function that takes a word (upside down) as input and returns the number entered into the calculator.\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/3018-calculator-spelling-numbers-to-letters\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eProblem 3018\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":3020,"title":"Prime Letters = Removing","description":"Given a string, remove all the letters which in ASCII Code are prime numbers.\r\n\r\nFor Example:\r\n\r\n  s1 = 'Determine which array elements are prime'\r\n\r\nBecomes:\r\n\r\n  s2 = 'Dtrin which rry lnts r pri'","description_html":"\u003cp\u003eGiven a string, remove all the letters which in ASCII Code are prime numbers.\u003c/p\u003e\u003cp\u003eFor Example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es1 = 'Determine which array elements are prime'\r\n\u003c/pre\u003e\u003cp\u003eBecomes:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003es2 = 'Dtrin which rry lnts r pri'\r\n\u003c/pre\u003e","function_template":"function y = primeLetters(x)\r\n  y = x;\r\nend","test_suite":"%%\r\ns1 = 'Determine which array elements are prime'\r\ns2 = 'Dtrin which rry lnts r pri'\r\nassert(isequal(primeLetters(s1),s2))\r\n\r\n%%\r\ns1 = 'YeS, I SaY, make me SOme egg, aCe'\r\ns2 = ',  ,    , '\r\nassert(isequal(primeLetters(s1),s2))\r\n\r\n%%\r\ns1 = 'qwertyuiopasdfghjklzxcvbnmQWERTYUIOPASDFGHJKLZXCVBNM'\r\ns2 = 'wrtyuiopsdfhjlzxcvbnQWERTUPADFHJKLZXVBNM'\r\nassert(isequal(primeLetters(s1),s2))\r\n\r\n%%\r\ns1 = 'DISSappearIng'\r\ns2 = 'Dpprn'\r\nassert(isequal(primeLetters(s1),s2))\r\n\r\n%%\r\ns1 = 'One, twO, three'\r\ns2 = 'n, tw, thr'\r\nassert(isequal(primeLetters(s1),s2))\r\n\r\n%%\r\ns1 = 'GaSSeS GO'\r\ns2 = ' '\r\nassert(isequal(primeLetters(s1),s2))\r\n\r\n%%\r\ns1 = 'SageS Must SaY See'\r\ns2 = ' Must  '\r\nassert(isequal(primeLetters(s1),s2))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":4690,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":114,"test_suite_updated_at":"2017-09-27T16:27:47.000Z","rescore_all_solutions":false,"group_id":32,"created_at":"2015-02-15T21:22:59.000Z","updated_at":"2026-03-19T20:01:04.000Z","published_at":"2015-02-15T21:24:43.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\u003eGiven a string, remove all the letters which in ASCII Code are prime numbers.\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:\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[s1 = 'Determine which array elements are prime']]\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\u003eBecomes:\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[s2 = 'Dtrin which rry lnts r pri']]\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":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":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":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\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}