{"group":{"group":{"id":286,"name":"Basics - Cell Arrays","lockable":false,"created_at":"2019-02-22T19:28:18.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Cell Arrays can contain data of varying types and sizes. Questions in this group will challenge your understanding about Cell Arrays.","is_default":false,"created_by":232412,"badge_id":62,"featured":false,"trending":false,"solution_count_in_trending_period":600,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":5649,"published":true,"community_created":true,"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\u003eCell Arrays can contain data of varying types and sizes. Questions in this group will challenge your understanding about Cell Arrays.\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 21px; transform-origin: 289.5px 21px; \"\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 21px; transform-origin: 266.5px 21px; 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=\"\"\u003eCell Arrays can contain data of varying types and sizes. Questions in this group will challenge your understanding about Cell Arrays.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2019-05-08T20:20:35.000Z"},"current_player":null},"problems":[{"id":41,"title":"Cell joiner","description":"You are given a cell array of strings and a string delimiter. You need to produce one string which is composed of each string from the cell array separated by the delimiter. \n\nFor example, this input\n\n in_cell = {'Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur'};\n delim = ' ';\n\nshould produce this output:\n\n out_str = 'Lorem ipsum dolor sit amet consectetur';\n\n","description_html":"\u003cp\u003eYou are given a cell array of strings and a string delimiter. You need to produce one string which is composed of each string from the cell array separated by the delimiter.\u003c/p\u003e\u003cp\u003eFor example, this input\u003c/p\u003e\u003cpre\u003e in_cell = {'Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur'};\n delim = ' ';\u003c/pre\u003e\u003cp\u003eshould produce this output:\u003c/p\u003e\u003cpre\u003e out_str = 'Lorem ipsum dolor sit amet consectetur';\u003c/pre\u003e","function_template":"function out_str = cellstr_joiner(in_cell, delim)\n  out_str = '';\nend","test_suite":"%%\nx = {'hello', 'basic', 'test', 'case'};\ny_correct = 'hello basic test case';\nassert(isequal(cellstr_joiner(x, ' '),y_correct))\n\n%%\nx = {'this', 'one', '', 'has', ' ', 'some tricky', 'stuff'};\ny_correct = 'this one  has   some tricky stuff';\nassert(isequal(cellstr_joiner(x, ' '),y_correct))\n\n%%\nx = {'delimiters', 'are', 'not', 'always', 'spaces'};\ny_correct = 'delimiters?are?not?always?spaces';\nassert(isequal(cellstr_joiner(x, '?'),y_correct))","published":true,"deleted":false,"likes_count":46,"comments_count":16,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":7290,"test_suite_updated_at":"2012-01-18T01:00:23.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:23.000Z","updated_at":"2026-04-03T07:26:11.000Z","published_at":"2012-01-18T01:00:23.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\u003eYou are given a cell array of strings and a string delimiter. You need to produce one string which is composed of each string from the cell array separated by the delimiter.\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, this input\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_cell = {'Lorem', 'ipsum', 'dolor', 'sit', 'amet', 'consectetur'};\\n delim = ' ';]]\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\u003eshould produce this output:\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[ out_str = 'Lorem ipsum dolor sit amet consectetur';]]\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":152,"title":"Create a cell array out of a struct","description":"Create a cell array out of a (single) struct with the fieldname in the first column and the value in the second column:\r\n\r\nin:\r\n\r\n  S.foo = 'hello';\r\n  S.bar = 3.14;\r\n\r\nout:\r\n\r\n {'foo', 'hello';\r\n  'bar', 3.14}\r\n","description_html":"\u003cp\u003eCreate a cell array out of a (single) struct with the fieldname in the first column and the value in the second column:\u003c/p\u003e\u003cp\u003ein:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eS.foo = 'hello';\r\nS.bar = 3.14;\r\n\u003c/pre\u003e\u003cp\u003eout:\u003c/p\u003e\u003cpre\u003e {'foo', 'hello';\r\n  'bar', 3.14}\u003c/pre\u003e","function_template":"function c = struct2namedCell(S)\r\n  c = {S};\r\nend","test_suite":"%%\r\nS.foobar = 1.23;\r\nS_correct = {'foobar', 1.23};\r\nassert(isequal(struct2namedCell(S), S_correct))\r\n%%\r\nS2.foo = 'hello';\r\nS2.bar = 3.14;\r\nS2_correct = {'foo', 'hello'; 'bar', 3.14};\r\nassert(isequal(struct2namedCell(S2), S2_correct))\r\n%%\r\nS3.A = {1,2,3};\r\nS3_correct = {'A', {1,2,3}};\r\nassert(isequal(struct2namedCell(S3), S3_correct))","published":true,"deleted":false,"likes_count":20,"comments_count":3,"created_by":20,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2432,"test_suite_updated_at":"2012-01-28T21:46:57.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-01-28T21:46:57.000Z","updated_at":"2026-04-03T16:28:12.000Z","published_at":"2012-01-28T21:47:23.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\u003eCreate a cell array out of a (single) struct with the fieldname in the first column and the value in the second column:\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\u003ein:\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[S.foo = 'hello';\\nS.bar = 3.14;]]\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\u003eout:\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[ {'foo', 'hello';\\n  'bar', 3.14}]]\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":380,"title":"Convert a numerical matrix into a cell array of strings ","description":"Given a numerical matrix, output a *cell array of string*.\r\n\r\nFor example:\r\n\r\nif input = 1:3\r\n\r\noutput is  {'1','2','3'}\r\n\r\nwhich is a cell 1x3  ","description_html":"\u003cp\u003eGiven a numerical matrix, output a \u003cb\u003ecell array of string\u003c/b\u003e.\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cp\u003eif input = 1:3\u003c/p\u003e\u003cp\u003eoutput is  {'1','2','3'}\u003c/p\u003e\u003cp\u003ewhich is a cell 1x3\u003c/p\u003e","function_template":"function output = matrix2cell(input)\r\n  output = 0;\r\nend","test_suite":"%% Example tested\r\ninput = 1:3;\r\noutput = {'1'    '2'    '3'};\r\nassert(isequal(matrix2cell(input ),output))\r\nassert(iscell(output),'output must be a cell')\r\n\r\n%% \r\ninput  = 0:5:8\r\noutput =  {'0'    '5'};\r\nassert(isequal(matrix2cell(input ),output))\r\nassert(iscell(output),'output must be a cell')\r\n\r\n\r\n\r\n%% Matrix input\r\ninput =magic(3);\r\noutput =  {'8'    '1'    '6'\r\n    '3'    '5'    '7'\r\n    '4'    '9'    '2'}\r\nassert(isequal(matrix2cell(input ),output))","published":true,"deleted":false,"likes_count":11,"comments_count":1,"created_by":639,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2393,"test_suite_updated_at":"2012-02-22T08:00:05.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-22T07:38:43.000Z","updated_at":"2026-04-02T15:20:29.000Z","published_at":"2012-02-22T08:21:53.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 numerical matrix, output a\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:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ecell array of string\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif input = 1:3\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\u003eoutput is {'1','2','3'}\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\u003ewhich is a cell 1x3\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":967,"title":"Split a string into chunks of specified length","description":"Given a string and a vector of integers, break the string into chunks whose lengths are given by the elements of the vector.  Extra characters leftover at the end should be dropped.  Example:\r\n\r\n  break_string('I seem to be having tremendous difficulty with my lifestyle',[4 1 5 22])\r\n\r\nshould return a 4x1 cell array:\r\n\r\n  ans = \r\n    'I se'    'e'    'm to '    'be having tremendous d'\r\n  \r\n\r\n","description_html":"\u003cp\u003eGiven a string and a vector of integers, break the string into chunks whose lengths are given by the elements of the vector.  Extra characters leftover at the end should be dropped.  Example:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ebreak_string('I seem to be having tremendous difficulty with my lifestyle',[4 1 5 22])\r\n\u003c/pre\u003e\u003cp\u003eshould return a 4x1 cell array:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eans = \r\n  'I se'    'e'    'm to '    'be having tremendous d'\r\n\u003c/pre\u003e","function_template":"function y = break_string(s,b)\r\n  y = s;\r\nend","test_suite":"%%\r\ns = 'Easy';\r\nb = ones(1,4);\r\ny_correct = {'E','a','s','y'};\r\nassert(isequal(break_string(s,b),y_correct))\r\n\r\n%%\r\ns = 'I seem to be having tremendous difficulty with my lifestyle';\r\nb = [4 1 5 22];\r\ny_correct = {'I se','e','m to ','be having tremendous d'};\r\nassert(isequal(break_string(s,b),y_correct))\r\n\r\n%%\r\ns = 'The answer is 42';\r\nb = [4 7 3];\r\ny_correct = {'The ','answer ','is '};\r\nassert(isequal(break_string(s,b),y_correct))\r\n\r\n%%\r\ns = 'Did I do that?';\r\nb = [2 3 3];\r\ny_correct = {'Di','d I',' do'};\r\nassert(isequal(break_string(s,b),y_correct))\r\n\r\n%%\r\ns = 'Yes no when?';\r\nb = [2 6 3];\r\ny_correct = {'Ye','s no w','hen'};\r\nassert(isequal(break_string(s,b),y_correct))\r\n\r\n%%\r\ns = 'Hello there';\r\nb = [3 4 4];\r\ny_correct = {'Hel','lo t','here'};\r\nassert(isequal(break_string(s,b),y_correct))\r\n\r\n%%\r\ns = 'One is not enough!';\r\nb = [3 1 1];\r\ny_correct = {'One',' ','i'};\r\nassert(isequal(break_string(s,b),y_correct))","published":true,"deleted":false,"likes_count":8,"comments_count":3,"created_by":4609,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2063,"test_suite_updated_at":"2016-12-12T18:31:20.000Z","rescore_all_solutions":false,"group_id":14,"created_at":"2012-10-02T06:48:21.000Z","updated_at":"2026-04-02T15:23:20.000Z","published_at":"2012-10-02T06:49:10.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 and a vector of integers, break the string into chunks whose lengths are given by the elements of the vector. Extra characters leftover at the end should be dropped. 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[break_string('I seem to be having tremendous difficulty with my lifestyle',[4 1 5 22])]]\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\u003eshould return a 4x1 cell array:\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[ans = \\n  'I se'    'e'    'm to '    'be having tremendous d']]\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":1899,"title":"Convert a Cell Array into an Array","description":"Given a square cell array:\r\n\r\n x = {'01', '56'; '234', '789'};\r\n\r\nreturn a single character array: \r\n\r\n y = '0123456789'\r\n","description_html":"\u003cp\u003eGiven a square cell array:\u003c/p\u003e\u003cpre\u003e x = {'01', '56'; '234', '789'};\u003c/pre\u003e\u003cp\u003ereturn a single character array:\u003c/p\u003e\u003cpre\u003e y = '0123456789'\u003c/pre\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx={'01', '56'; '234', '789'};\r\ny_correct = '0123456789';\r\nassert(isequal(your_fcn_name(x),y_correct));\r\n\r\n%%\r\nx={'' 'a' '1'; 'AA' 'BB' 'CC'; 'dog' 'cat' 'car'};\r\ny_correct='AAdogaBBcat1CCcar';\r\nassert(isequal(your_fcn_name(x),y_correct));\r\n\r\n%%\r\nx={'We' 'do' ;'ll ' 'ne.'};\r\ny_correct='Well done.';\r\nassert(isequal(your_fcn_name(x),y_correct));\r\n","published":true,"deleted":false,"likes_count":9,"comments_count":1,"created_by":17471,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2201,"test_suite_updated_at":"2013-09-27T18:48:54.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-27T18:42:17.000Z","updated_at":"2026-04-01T18:18:30.000Z","published_at":"2013-09-27T18:48:54.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 square cell array:\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 = {'01', '56'; '234', '789'};]]\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\u003ereturn a single character array:\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[ y = '0123456789']]\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":1971,"title":"Remove element(s) from cell array","description":"You can easily remove an element (or a column in any dimension) from a normal matrix, but assigning that value (or range) empty. For example\r\nA = 1:10\r\nA(5) = []\r\nresults in\r\n1 2 3 4 6 7 8 9 10\r\nYou task is to find the shortest, elegant, way in Matlab to do the same for cell arrays. Regexp, eval, and other workarounds that trick mtree are considered stupid, and will not be appreciated.","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: 206.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.5px 103.15px; transform-origin: 406.5px 103.15px; 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: 383.5px 21px; text-align: left; transform-origin: 383.5px 21px; white-space-collapse: preserve; 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: 374.083px 7.81667px; transform-origin: 374.083px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYou can easily remove an element (or a column in any dimension) from a normal matrix, but assigning that value (or range) empty. For example\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: 403.5px 20.4333px; transform-origin: 403.5px 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: 1.11667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11667px; 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: 403.5px 10.2167px; text-wrap-mode: nowrap; transform-origin: 403.5px 10.2167px; \"\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: 31.2667px 8.375px; tab-size: 4; transform-origin: 31.2667px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eA = 1:10\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: 1.11667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11667px; 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: 403.5px 10.2167px; text-wrap-mode: nowrap; transform-origin: 403.5px 10.2167px; \"\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: 35.175px 8.375px; tab-size: 4; transform-origin: 35.175px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eA(5) = []\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: 383.5px 10.5px; text-align: left; transform-origin: 383.5px 10.5px; white-space-collapse: preserve; 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: 29.5917px 7.81667px; transform-origin: 29.5917px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eresults in\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 403.5px 10.2167px; transform-origin: 403.5px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1.11667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11667px; 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; text-wrap-mode: 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: 70.35px 8.375px; tab-size: 4; transform-origin: 70.35px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e1 2 3 4 6 7 8 9 10\u003c/span\u003e\u003c/span\u003e\u003c/div\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: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 383.5px 21px; text-align: left; transform-origin: 383.5px 21px; white-space-collapse: preserve; 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: 355.1px 7.81667px; transform-origin: 355.1px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYou task is to find the shortest, elegant, way in Matlab to do the same for cell arrays. Regexp, eval, and other workarounds that trick mtree are considered stupid, and will not be appreciated.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = remove_from_cell_array(x,to_remove)\r\n  y = x(to_remove);\r\nend","test_suite":"%%\r\nfiletext = fileread('remove_from_cell_array.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp'); \r\nassert(~illegal)\r\n\r\n\r\n%%\r\nx = num2cell(1:10);\r\nto_remove = 3;\r\ny_correct = {1 2 4 5 6 7 8 9 10};\r\nassert(isequal(remove_from_cell_array(x,to_remove),y_correct))\r\n\r\n%%\r\nx = num2cell(1:5)';\r\nto_remove = 1:2:5;\r\ny_correct = {2 4}';\r\nassert(isequal(remove_from_cell_array(x,to_remove),y_correct))\r\n","published":true,"deleted":false,"likes_count":17,"comments_count":2,"created_by":6556,"edited_by":223089,"edited_at":"2024-06-28T16:21:03.000Z","deleted_by":null,"deleted_at":null,"solvers_count":1991,"test_suite_updated_at":"2024-06-28T16:21:03.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-11-05T16:37:15.000Z","updated_at":"2026-04-01T18:19:25.000Z","published_at":"2013-11-05T16:45:29.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou can easily remove an element (or a column in any dimension) from a normal matrix, but assigning that value (or range) empty. For 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[A = 1:10\\nA(5) = []]]\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\u003eresults in\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[1 2 3 4 6 7 8 9 10]]\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\u003eYou task is to find the shortest, elegant, way in Matlab to do the same for cell arrays. Regexp, eval, and other workarounds that trick mtree are considered stupid, and will not be appreciated.\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":1036,"title":"Cell Counting: How Many Draws? ","description":"You are given a cell array containing information about a number of soccer games. Each cell contains one of the following:\r\n\r\n* 'H', meaning the home team won\r\n* 'A', meaning the away team won\r\n* 'D', meaning a draw, or tie game\r\n\r\nSo if \r\n\r\n games = {'D','D','A','H','D','H'}\r\n\r\nthen \r\n\r\n draws = 3","description_html":"\u003cp\u003eYou are given a cell array containing information about a number of soccer games. Each cell contains one of the following:\u003c/p\u003e\u003cul\u003e\u003cli\u003e'H', meaning the home team won\u003c/li\u003e\u003cli\u003e'A', meaning the away team won\u003c/li\u003e\u003cli\u003e'D', meaning a draw, or tie game\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eSo if\u003c/p\u003e\u003cpre\u003e games = {'D','D','A','H','D','H'}\u003c/pre\u003e\u003cp\u003ethen\u003c/p\u003e\u003cpre\u003e draws = 3\u003c/pre\u003e","function_template":"function draws = how_many_draws(games)\r\n  draws = 17;\r\nend","test_suite":"%%\r\ngames = {'D','D','A','H','D','H'};\r\ndraws = 3;\r\nassert(isequal(how_many_draws(games),draws))\r\n\r\n%%\r\ngames = {'D','D'};\r\ndraws = 2;\r\nassert(isequal(how_many_draws(games),draws))\r\n\r\n%%\r\ngames = {'H','H','A'};\r\ndraws = 0;\r\nassert(isequal(how_many_draws(games),draws))\r\n\r\n%%\r\ngames = {'D','H','H','A','D','H','H','A','D','H','H','A','D','D'};\r\ndraws = 5;\r\nassert(isequal(how_many_draws(games),draws))","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2393,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":14,"created_at":"2012-11-15T23:03:18.000Z","updated_at":"2026-04-01T18:23:35.000Z","published_at":"2012-11-15T23:08:29.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\u003eYou are given a cell array containing information about a number of soccer games. Each cell contains one of the following:\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\u003e'H', meaning the home team won\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\u003e'A', meaning the away team won\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\u003e'D', meaning a draw, or tie game\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\u003eSo if\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[ games = {'D','D','A','H','D','H'}]]\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[ draws = 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":43677,"title":"String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values","description":"\u003chttp://www.mathworks.com/help/matlab/characters-and-strings.html String array\u003e and cell array are two types of containers for storing pieces of data. In this problem, you will be given a cell array of character vectors. Your job is to convert the cell array to a string array, which stores the same pieces of text data. \r\n\r\nTo begin with, let's assume that there are no missing type values in the input cell array. \r\n\r\n\r\nExample: \r\n \r\n\r\n  Input:\r\n  \u003e\u003e x = {'I','Love','MATLAB'}\r\n  x =\r\n    1×3 cell array\r\n      'I'    'Love'    'MATLAB'\r\n\r\n  Output:\r\n  \u003e\u003e y = strings(size(x));\r\n  \u003e\u003e [y{:}] = x{:}\r\n  y = \r\n    1×3 string array\r\n      \"I\"    \"Love\"    \"MATLAB\"\r\n\r\nNote that the example shown above is not the best way to solve this problem. Try other approaches in order to achieve a leading score. \r\n\r\nRelated Problems in this series:\r\n\r\n* String Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values\r\n* \u003chttp://www.mathworks.com/matlabcentral/cody/problems/43672-string-array-basics-part-2-convert-string-array-to-cell-array-no-missing-values   String Array Basics, Part 2: Convert String Array to Cell Array; No Missing Values\u003e \r\n* \u003chttp://www.mathworks.com/matlabcentral/cody/problems/43674-string-array-basics-part-3-convert-cell-array-to-string-array-with-missing-values   String Array Basics, Part 3: Convert Cell Array with Missing Values to String Array\u003e\r\n* \u003chttp://www.mathworks.com/matlabcentral/cody/problems/43673-string-array-basics-part-4-convert-string-array-to-cell-array-with-missing-values   String Array Basics, Part 4: Convert String Array with Missing Values to Cell Array\u003e\r\n","description_html":"\u003cp\u003e\u003ca href = \"http://www.mathworks.com/help/matlab/characters-and-strings.html\"\u003eString array\u003c/a\u003e and cell array are two types of containers for storing pieces of data. In this problem, you will be given a cell array of character vectors. Your job is to convert the cell array to a string array, which stores the same pieces of text data.\u003c/p\u003e\u003cp\u003eTo begin with, let's assume that there are no missing type values in the input cell array.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eInput:\r\n\u0026gt;\u0026gt; x = {'I','Love','MATLAB'}\r\nx =\r\n  1×3 cell array\r\n    'I'    'Love'    'MATLAB'\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eOutput:\r\n\u0026gt;\u0026gt; y = strings(size(x));\r\n\u0026gt;\u0026gt; [y{:}] = x{:}\r\ny = \r\n  1×3 string array\r\n    \"I\"    \"Love\"    \"MATLAB\"\r\n\u003c/pre\u003e\u003cp\u003eNote that the example shown above is not the best way to solve this problem. Try other approaches in order to achieve a leading score.\u003c/p\u003e\u003cp\u003eRelated Problems in this series:\u003c/p\u003e\u003cul\u003e\u003cli\u003eString Array Basics, Part 1: Convert Cell Array to String Array; No Missing Values\u003c/li\u003e\u003cli\u003e\u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/43672-string-array-basics-part-2-convert-string-array-to-cell-array-no-missing-values\"\u003eString Array Basics, Part 2: Convert String Array to Cell Array; No Missing Values\u003c/a\u003e\u003c/li\u003e\u003cli\u003e\u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/43674-string-array-basics-part-3-convert-cell-array-to-string-array-with-missing-values\"\u003eString Array Basics, Part 3: Convert Cell Array with Missing Values to String Array\u003c/a\u003e\u003c/li\u003e\u003cli\u003e\u003ca href = \"http://www.mathworks.com/matlabcentral/cody/problems/43673-string-array-basics-part-4-convert-string-array-to-cell-array-with-missing-values\"\u003eString Array Basics, Part 4: Convert String Array with Missing Values to Cell Array\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e","function_template":"function y = cell2str(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = {'I','love','MATLAB'};\r\ny_correct = strings(size(x));\r\n[y_correct{:}] = x{:};\r\nassert(isequal(cell2str(x),y_correct))\r\n\r\n%%\r\nx = {'I',   'love',  'MATLAB'\r\n     'I',   'love',  'Cody'};\r\ny_correct = strings(size(x));\r\n[y_correct{:}] = x{:};\r\nassert(isequal(cell2str(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":1,"created_by":12569,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1969,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":16,"created_at":"2016-11-22T21:03:53.000Z","updated_at":"2026-04-01T18:24:18.000Z","published_at":"2016-11-22T21:05: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:hyperlink w:docLocation=\\\"http://www.mathworks.com/help/matlab/characters-and-strings.html\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eString array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e and cell array are two types of containers for storing pieces of data. In this problem, you will be given a cell array of character vectors. Your job is to convert the cell array to a string array, which stores the same pieces of text data.\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\u003eTo begin with, let's assume that there are no missing type values in the input cell array.\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:\\n\u003e\u003e x = {'I','Love','MATLAB'}\\nx =\\n  1×3 cell array\\n    'I'    'Love'    'MATLAB'\\n\\nOutput:\\n\u003e\u003e y = strings(size(x));\\n\u003e\u003e [y{:}] = x{:}\\ny = \\n  1×3 string array\\n    \\\"I\\\"    \\\"Love\\\"    \\\"MATLAB\\\"]]\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\u003eNote that the example shown above is not the best way to solve this problem. Try other approaches in order to achieve a leading score.\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\u003eRelated Problems in this series:\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\u003eString Array Basics, Part 1: Convert Cell Array to String Array; No Missing 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:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/43672-string-array-basics-part-2-convert-string-array-to-cell-array-no-missing-values\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eString Array Basics, Part 2: Convert String Array to Cell Array; No Missing Values\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/43674-string-array-basics-part-3-convert-cell-array-to-string-array-with-missing-values\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eString Array Basics, Part 3: Convert Cell Array with Missing Values to String Array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/43673-string-array-basics-part-4-convert-string-array-to-cell-array-with-missing-values\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eString Array Basics, Part 4: Convert String Array with Missing Values to Cell Array\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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":1755,"title":"Fix the last element of a cell array","description":"Note: this is lifted directly from \u003chttp://www.mathworks.com/matlabcentral/answers/82825-puzzler-for-a-monday Puzzler for a Monday\u003e (on \u003chttp://www.mathworks.com/matlabcentral/answers/ MATLAB Answers\u003e) by \u003chttp://www.mathworks.com/matlabcentral/answers/contributors/1841757-the-cyclist the cyclist\u003e.\r\n \r\n----\r\n\r\nGiven a cell array of strings\r\n\r\n A = {'MATLAB','HURRAY','SPARKLY','KITTENS','FUN'};\r\n\r\nand a particular string value\r\n\r\n B = 'KITTENS';\r\n\r\nensure that B is the last element of the cell array. If it isn't, move it to the end of A.\r\n\r\nYou cannot assume that B appears at all (in which case return A unchanged), but you can assume B does not appear more than once.\r\n\r\nSo in the example,\r\n\r\n C = {'MATLAB','HURRAY','SPARKLY','FUN','KITTENS'};\r\n","description_html":"\u003cp\u003eNote: this is lifted directly from \u003ca href = \"http://www.mathworks.com/matlabcentral/answers/82825-puzzler-for-a-monday\"\u003ePuzzler for a Monday\u003c/a\u003e (on \u003ca href = \"http://www.mathworks.com/matlabcentral/answers/\"\u003eMATLAB Answers\u003c/a\u003e) by \u003ca href = \"http://www.mathworks.com/matlabcentral/answers/contributors/1841757-the-cyclist\"\u003ethe cyclist\u003c/a\u003e.\u003c/p\u003e\u003cp\u003e----\u003c/p\u003e\u003cp\u003eGiven a cell array of strings\u003c/p\u003e\u003cpre\u003e A = {'MATLAB','HURRAY','SPARKLY','KITTENS','FUN'};\u003c/pre\u003e\u003cp\u003eand a particular string value\u003c/p\u003e\u003cpre\u003e B = 'KITTENS';\u003c/pre\u003e\u003cp\u003eensure that B is the last element of the cell array. If it isn't, move it to the end of A.\u003c/p\u003e\u003cp\u003eYou cannot assume that B appears at all (in which case return A unchanged), but you can assume B does not appear more than once.\u003c/p\u003e\u003cp\u003eSo in the example,\u003c/p\u003e\u003cpre\u003e C = {'MATLAB','HURRAY','SPARKLY','FUN','KITTENS'};\u003c/pre\u003e","function_template":"function C = puzzler(A,B)\r\n  C = A;\r\nend","test_suite":"%%\r\nA = {'MATLAB','HURRAY','SPARKLY','KITTENS','FUN'};\r\nB = 'KITTENS';\r\nC = {'MATLAB','HURRAY','SPARKLY','FUN','KITTENS'};\r\nassert(isequal(puzzler(A,B),C))\r\n\r\n%%\r\nA = {'HELP!','I''VE','FALLEN','ON THE','CAPS LOCK','KEY'};\r\nB = 'stop shouting';\r\nC = {'HELP!','I''VE','FALLEN','ON THE','CAPS LOCK','KEY'};\r\nassert(isequal(puzzler(A,B),C))\r\n\r\n%%\r\nA = {'When','in the','human events','course','of'};\r\nB = 'human events';\r\nC = {'When','in the','course','of','human events'};\r\nassert(isequal(puzzler(A,B),C))\r\n\r\n%%\r\nA = {'Soulwise','these','times','are','trying'};\r\nB = 'times';\r\nC = {'Soulwise','these','are','trying','times'};\r\nassert(isequal(puzzler(A,B),C))\r\n\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":10,"comments_count":1,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":1764,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-26T22:02:35.000Z","updated_at":"2026-04-01T18:25:00.000Z","published_at":"2013-07-26T22:02:35.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\u003eNote: this is lifted directly from\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/answers/82825-puzzler-for-a-monday\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePuzzler for a Monday\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e (on\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/answers/\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eMATLAB Answers\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e) by\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/answers/contributors/1841757-the-cyclist\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ethe cyclist\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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\u003eGiven a cell array of strings\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 = {'MATLAB','HURRAY','SPARKLY','KITTENS','FUN'};]]\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\u003eand a particular string value\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[ B = 'KITTENS';]]\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\u003eensure that B is the last element of the cell array. If it isn't, move it to the end of A.\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 cannot assume that B appears at all (in which case return A unchanged), but you can assume B does not appear more than once.\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\u003eSo in the 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[ C = {'MATLAB','HURRAY','SPARKLY','FUN','KITTENS'};]]\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":2300,"title":"Natural numbers in string form","description":"Create a cell array of strings containing the first n natural numbers.  Slightly harder than it seems like it should be.\r\nExample\r\n \u003e\u003e y = naturalnumbers(4)\r\n y =\r\n   '1'   '2'   '3'   '4'","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.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.5px 61.15px; transform-origin: 406.5px 61.15px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 383.5px 10.5px; text-align: left; transform-origin: 383.5px 10.5px; white-space-collapse: preserve; 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: 217.192px 7.81667px; transform-origin: 217.192px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCreate a cell array of strings containing the first n natural numbers. \u003c/span\u003e\u003c/span\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: 2.23333px 7.81667px; transform-origin: 2.23333px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\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: 23.45px 7.81667px; transform-origin: 23.45px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eSlightly\u003c/span\u003e\u003c/span\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: 123.95px 7.81667px; transform-origin: 123.95px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e harder than it seems like it should be.\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: 383.5px 10.5px; text-align: left; transform-origin: 383.5px 10.5px; white-space-collapse: preserve; 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.475px 7.81667px; transform-origin: 28.475px 7.81667px; 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: 61.3px; 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: 403.5px 30.65px; transform-origin: 403.5px 30.65px; 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: 1.11667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11667px; 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: 403.5px 10.2167px; text-wrap-mode: nowrap; transform-origin: 403.5px 10.2167px; \"\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: 97.7083px 8.375px; tab-size: 4; transform-origin: 97.7083px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e \u0026gt;\u0026gt; y = naturalnumbers(4)\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: 1.11667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11667px; 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: 403.5px 10.2167px; text-wrap-mode: nowrap; transform-origin: 403.5px 10.2167px; \"\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: 15.6333px 8.375px; tab-size: 4; transform-origin: 15.6333px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e y =\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: 1.11667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1.11667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1.11667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1.11667px; 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: 403.5px 10.2167px; text-wrap-mode: nowrap; transform-origin: 403.5px 10.2167px; \"\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: 93.8px 8.375px; tab-size: 4; transform-origin: 93.8px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 11.725px 8.375px; transform-origin: 11.725px 8.375px; \"\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: 11.725px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 11.725px 8.375px; \"\u003e'1'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 11.725px 8.375px; transform-origin: 11.725px 8.375px; \"\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: 11.725px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 11.725px 8.375px; \"\u003e'2'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 11.725px 8.375px; transform-origin: 11.725px 8.375px; \"\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: 11.725px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 11.725px 8.375px; \"\u003e'3'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 11.725px 8.375px; transform-origin: 11.725px 8.375px; \"\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: 11.725px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 11.725px 8.375px; \"\u003e'4'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = naturalnumbers(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('naturalnumbers.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp')\r\nassert(~illegal)\r\n\r\n%%\r\nx = 1;\r\ny_correct = {'1'};\r\nassert(isequal(naturalnumbers(x),y_correct))\r\n\r\n%%\r\nx = 11;\r\ny_correct = {'1','2','3','4','5','6','7','8','9','10','11'};\r\nassert(isequal(naturalnumbers(x),y_correct))\r\n\r\n%%\r\nx = randi(20);\r\ny = {'1','2','3','4','5','6','7','8','9','10',...\r\n    '11','12','13','14','15','16','17','18','19','20'};\r\ny_correct = y(1:x);\r\nassert(isequal(naturalnumbers(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":9,"comments_count":3,"created_by":4609,"edited_by":223089,"edited_at":"2024-07-04T14:45:50.000Z","deleted_by":null,"deleted_at":null,"solvers_count":1860,"test_suite_updated_at":"2024-07-04T14:45:50.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-04-29T23:13:42.000Z","updated_at":"2026-04-01T18:25:35.000Z","published_at":"2014-04-29T23:13:42.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate a cell array of strings containing the first n natural numbers. \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\u003eSlightly\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e harder than it seems like it 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\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[ \u003e\u003e y = naturalnumbers(4)\\n y =\\n   '1'   '2'   '3'   '4']]\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\"}]}"}],"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}}