{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems submitted by members of the MATLAB Central community.","is_default":true,"created_by":161519,"badge_id":null,"featured":false,"trending":false,"solution_count_in_trending_period":0,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":null,"published":true,"community_created":false,"status_id":2,"is_default_group_for_player":false,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"description_opc":null,"description_html":null,"published_at":null},"problems":[{"id":43114,"title":"Add the odd numbers","description":"Add only the odd numbers of x\r\n\r\nexample:\r\n\r\n x = [1 2 3 4 5]\r\n\r\nthe positive numbers are: 1 3 5, so their sum is 9","description_html":"\u003cp\u003eAdd only the odd numbers of x\u003c/p\u003e\u003cp\u003eexample:\u003c/p\u003e\u003cpre\u003e x = [1 2 3 4 5]\u003c/pre\u003e\u003cp\u003ethe positive numbers are: 1 3 5, so their sum is 9\u003c/p\u003e","function_template":"function y = addOdd(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 2 3 4 5];\r\ny_correct = 9;\r\nassert(isequal(addOdd(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5 7];\r\ny_correct = 16;\r\nassert(isequal(addOdd(x),y_correct))\r\n%%\r\nx = [1 2 4 5 7];\r\ny_correct = 13;\r\nassert(isequal(addOdd(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":94929,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":85,"test_suite_updated_at":"2016-10-19T11:36:43.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-06T08:49:13.000Z","updated_at":"2026-02-13T18:24:27.000Z","published_at":"2016-10-06T08:49:13.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\u003eAdd only the odd numbers of x\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[ x = [1 2 3 4 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethe positive numbers are: 1 3 5, so their sum is 9\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":43140,"title":"Odd times even numbers in a matrix","description":"First count the number of odd numbers in x, then the number of even. Return their product.\r\n\r\nexample:\r\n\r\n x = [1 2]\r\n\r\nOne odd and one even. The product is thus 1.","description_html":"\u003cp\u003eFirst count the number of odd numbers in x, then the number of even. Return their product.\u003c/p\u003e\u003cp\u003eexample:\u003c/p\u003e\u003cpre\u003e x = [1 2]\u003c/pre\u003e\u003cp\u003eOne odd and one even. The product is thus 1.\u003c/p\u003e","function_template":"function y = oddXeven(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(oddXeven(x),y_correct))\r\n%%\r\nx = [1 2];\r\ny_correct = 1;\r\nassert(isequal(oddXeven(x),y_correct))\r\n%%\r\nx = [1 2 3];\r\ny_correct = 2;\r\nassert(isequal(oddXeven(x),y_correct))\r\n%%\r\nx = [1 2 3 4];\r\ny_correct = 4;\r\nassert(isequal(oddXeven(x),y_correct))\r\n%%\r\nx = [1 2 4];\r\ny_correct = 2;\r\nassert(isequal(oddXeven(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":94929,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":"2016-10-19T11:32:53.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-10-07T08:43:50.000Z","updated_at":"2026-02-17T17:52:19.000Z","published_at":"2016-10-07T08:43:50.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\u003eFirst count the number of odd numbers in x, then the number of even. Return their product.\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[ x = [1 2]]]\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\u003eOne odd and one even. The product is thus 1.\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":43141,"title":"All odd - all even","description":"All odd numbers in x are added, while all even numers are subtracted from this.\r\n\r\nexample:\r\n\r\n x = [1 2 3 4 5];\r\n y = +(1+3+5)-(2+4) = 3","description_html":"\u003cp\u003eAll odd numbers in x are added, while all even numers are subtracted from this.\u003c/p\u003e\u003cp\u003eexample:\u003c/p\u003e\u003cpre\u003e x = [1 2 3 4 5];\r\n y = +(1+3+5)-(2+4) = 3\u003c/pre\u003e","function_template":"function y = oddMinusEven(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1];\r\ny_correct = 1;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2];\r\ny_correct = -1;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3];\r\ny_correct = 2;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3 4];\r\ny_correct = -2;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5];\r\ny_correct = 3;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5 6];\r\ny_correct = -3;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5 6 7];\r\ny_correct = 4;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":94929,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":74,"test_suite_updated_at":"2016-10-19T11:31:58.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-10-07T08:48:53.000Z","updated_at":"2026-02-10T11:35:19.000Z","published_at":"2016-10-07T08:48: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\u003eAll odd numbers in x are added, while all even numers are subtracted from this.\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[ x = [1 2 3 4 5];\\n y = +(1+3+5)-(2+4) = 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":44158,"title":"Even or Odd","description":"Write a function which can tell us if the given value x is odd or even. So if x is even return true and if x is odd return false.\r\n\r\nExamples:\r\n\r\n Input:  x = 9;\r\n Output: y = false;\r\n","description_html":"\u003cp\u003eWrite a function which can tell us if the given value x is odd or even. So if x is even return true and if x is odd return false.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e Input:  x = 9;\r\n Output: y = false;\u003c/pre\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = false;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = false;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = true;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 11;\r\ny_correct = false;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 22;\r\ny_correct = true;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 13;\r\ny_correct = false;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = [56 117 8 24 44 33 15];\r\ny_correct = [true false true true true false false];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = [99 558 100; 101 6 4; 44 31 39];\r\ny_correct = [false true true; false true true; true false false];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nfiletext = fileread('your_fcn_name.m');\r\nassert(isempty(strfind(filetext, 'for')),'for command is forbidden')\r\nassert(isempty(strfind(filetext, 'repelem')),'repelem command is forbidden')\r\nassert(isempty(strfind(filetext, 'discretize')),'discretize command is forbidden')\r\nassert(isempty(strfind(filetext, 'while')),'while command is forbidden')\r\nassert(isempty(strfind(filetext, 'if')),'if command is forbidden')\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":37163,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":"2017-05-13T10:06:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-05-12T19:40:58.000Z","updated_at":"2026-03-15T04:04:38.000Z","published_at":"2017-05-12T20:01:56.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\u003eWrite a function which can tell us if the given value x is odd or even. So if x is even return true and if x is odd return false.\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[ Input:  x = 9;\\n Output: y = false;]]\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":43006,"title":"Odd row","description":"Create a row 'y' with odd numbers where the potential maximum number is given by 'x' and the space between them by 'm'. The first number of the row is 1.","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: 42px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 21px; transform-origin: 407px 21px; vertical-align: baseline; \"\u003e\u003cdiv style=\"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: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCreate a row 'y' with odd numbers where the potential maximum number is given by 'x' and the space between them by 'm'. The first number of the row is 1.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = OddRow(x)\r\n  y = 1;\r\nend","test_suite":"%%\r\nr = 15;\r\nm = 4;\r\ny_correct = [1 5 9 13];\r\nassert(isequal(OddRow(r,m),y_correct))\r\n\r\n\r\n%%\r\nr = 21;\r\nm = 6;\r\ny_correct = [1 7 13 19];\r\nassert(isequal(OddRow(r,m),y_correct))\r\n\r\n\r\n%%\r\nr = 31;\r\nm = 8;\r\ny_correct = [1 9 17 25];\r\nassert(isequal(OddRow(r,m),y_correct))\r\n\r\n%%\r\nr = 27;\r\nm = 4;\r\ny_correct = [1 5 9 13 17 21 25];\r\nassert(isequal(OddRow(r,m),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":3,"created_by":94418,"edited_by":223089,"edited_at":"2022-10-22T09:41:38.000Z","deleted_by":null,"deleted_at":null,"solvers_count":84,"test_suite_updated_at":"2022-10-22T09:41:38.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-02T12:01:30.000Z","updated_at":"2026-02-28T13:13:45.000Z","published_at":"2016-10-02T12:01:30.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\u003eCreate a row 'y' with odd numbers where the potential maximum number is given by 'x' and the space between them by 'm'. The first number of the row is 1.\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":44397,"title":"Determine whether the input is odd, even, or neither.","description":"Make a function that returns ‘odd’ if the input is odd, ‘even’ if the input if even or ‘error’ if the input  is neither odd nor even. Where the input could be a number, letter or symbol.","description_html":"\u003cp\u003eMake a function that returns ‘odd’ if the input is odd, ‘even’ if the input if even or ‘error’ if the input  is neither odd nor even. Where the input could be a number, letter or symbol.\u003c/p\u003e","function_template":"function n=oddornot(x);\r\n\r\nend","test_suite":"%%\r\nx = 1;\r\nn_correct = 'odd';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 12;\r\nn_correct = 'even';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 467.3;\r\nn_correct = 'error';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = -911;\r\nn_correct = 'odd';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 8230749726348;\r\nn_correct = 'even';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = pi;\r\nn_correct = 'error';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 'a';\r\nn_correct = 'error';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 'donald';\r\nn_correct = 'error';\r\nassert(isequal(oddornot(x),n_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":157578,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":52,"test_suite_updated_at":"2017-11-07T16:19:21.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-11-03T15:22:49.000Z","updated_at":"2026-04-01T11:19:18.000Z","published_at":"2017-11-03T15:22:49.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\u003eMake a function that returns ‘odd’ if the input is odd, ‘even’ if the input if even or ‘error’ if the input is neither odd nor even. Where the input could be a number, letter or symbol.\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":42318,"title":"Evened up (or not)","description":"You will be provided with an array or matrix that contains various numbers, in addition to an evening variable, e, set to 1 or 0. If e==1, then you should return an evened version of the matrix, wherein all odd numbers have one added to them to make them even. For example, \r\n\r\n* if M = 1:10, \r\n* then the evened array is [2,2,4,4,6,6,8,8,10,10].\r\n\r\nOn the other hand, if e==0, then you should return the same matrix with only odd numbers, wherein one has been added to every even number. For example,\r\n\r\n* if M = 1:10, \r\n* then the odd array is [1,3,3,5,5,7,7,9,9,11].","description_html":"\u003cp\u003eYou will be provided with an array or matrix that contains various numbers, in addition to an evening variable, e, set to 1 or 0. If e==1, then you should return an evened version of the matrix, wherein all odd numbers have one added to them to make them even. For example,\u003c/p\u003e\u003cul\u003e\u003cli\u003eif M = 1:10,\u003c/li\u003e\u003cli\u003ethen the evened array is [2,2,4,4,6,6,8,8,10,10].\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eOn the other hand, if e==0, then you should return the same matrix with only odd numbers, wherein one has been added to every even number. For example,\u003c/p\u003e\u003cul\u003e\u003cli\u003eif M = 1:10,\u003c/li\u003e\u003cli\u003ethen the odd array is [1,3,3,5,5,7,7,9,9,11].\u003c/li\u003e\u003c/ul\u003e","function_template":"function [M] = evened_up(M,e)\r\n\r\nM = M;\r\n\r\nend\r\n","test_suite":"%%\r\nM = 1:10;\r\ne = 1;\r\nM_corr = [2,2,4,4,6,6,8,8,10,10];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 1:10;\r\ne = 0;\r\nM_corr = [1,3,3,5,5,7,7,9,9,11];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 20:3:50;\r\ne = 1;\r\nM_corr = [20,24,26,30,32,36,38,42,44,48,50];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 20:3:50;\r\ne = 0;\r\nM_corr = [21,23,27,29,33,35,39,41,45,47,51];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 2:2:100;\r\ne = 1;\r\nM_corr = M;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 2:2:100;\r\ne = 0;\r\nM_corr = M+1;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = ones(3);\r\ne = 1;\r\nM_corr = M*2;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = magic(3);\r\ne = 0;\r\nM_corr = [9,1,7;3,5,7;5,9,3];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = magic(3);\r\ne = 1;\r\nM_corr = [8,2,6;4,6,8;4,10,2];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = eye(4);\r\ne = 1;\r\nM_corr = M*2;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = eye(4);\r\ne = 0;\r\nM_corr = ones(4);\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 1:10;\r\n\t\te = 1;\r\n\t\tM_corr = [2,2,4,4,6,6,8,8,10,10];\r\n\tcase 2\r\n\t\tM = 20:3:50;\r\n\t\te = 1;\r\n\t\tM_corr = [20,24,26,30,32,36,38,42,44,48,50];\r\n\tcase 3\r\n\t\tM = ones(3);\r\n\t\te = 1;\r\n\t\tM_corr = M*2;\r\n\tcase 4\r\n\t\tM = eye(4);\r\n\t\te = 0;\r\n\t\tM_corr = ones(4);\r\nend\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 2:2:100;\r\n\t\te = 0;\r\n\t\tM_corr = M+1;\r\n\tcase 2\r\n\t\tM = 1:10;\r\n\t\te = 0;\r\n\t\tM_corr = [1,3,3,5,5,7,7,9,9,11];\r\n\tcase 3\r\n\t\tM = 1:10;\r\n\t\te = 1;\r\n\t\tM_corr = [2,2,4,4,6,6,8,8,10,10];\r\n\tcase 4\r\n\t\tM = magic(3);\r\n\t\te = 0;\r\n\t\tM_corr = [9,1,7;3,5,7;5,9,3];\r\nend\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = eye(4);\r\n\t\te = 0;\r\n\t\tM_corr = ones(4);\r\n\tcase 2\r\n\t\tM = ones(3);\r\n\t\te = 1;\r\n\t\tM_corr = M*2;\r\n\tcase 3\r\n\t\tM = 20:3:50;\r\n\t\te = 1;\r\n\t\tM_corr = [20,24,26,30,32,36,38,42,44,48,50];\r\n\tcase 4\r\n\t\tM = 2:2:100;\r\n\t\te = 1;\r\n\t\tM_corr = M;\r\nend\r\nassert(isequal(evened_up(M,e),M_corr))\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":175,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-05-17T02:32:54.000Z","updated_at":"2026-04-02T10:10:53.000Z","published_at":"2015-05-17T02:32: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\u003eYou will be provided with an array or matrix that contains various numbers, in addition to an evening variable, e, set to 1 or 0. If e==1, then you should return an evened version of the matrix, wherein all odd numbers have one added to them to make them even. For example,\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\u003eif M = 1: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\u003ethen the evened array is [2,2,4,4,6,6,8,8,10,10].\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\u003eOn the other hand, if e==0, then you should return the same matrix with only odd numbers, wherein one has been added to every even number. For example,\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\u003eif M = 1: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\u003ethen the odd array is [1,3,3,5,5,7,7,9,9,11].\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":44721,"title":"Seperate array to small section according to its index position","description":"Given a integer n, we can generate a sequence [0,1,2,3,4,..., 2^n-1], then we separate it to two sequence according to their index position which is odd or even. We repeat this action until the number of sequence equal 2.\r\n\r\nfor example:\r\n\r\nn = 3;\r\n\r\n\r\nv = [0, 1, 2, 3, 4, 5 , 6, 7]\r\n\r\nstep 1:\r\n\r\nO = [0, 2, 4, 6]\r\n\r\nE = [1, 3, 5, 7]\r\n\r\nso v1 = {[0, 2, 4, 6], [1, 3, 5, 7]}\r\n\r\nstep 2:\r\n\r\nfor every element of this cell, wo separate, we can get\r\n\r\nv2 = {[0, 4], [2, 6], [1, 5], [3, 7]}\r\n\r\nthis is the solution, because the number of every element is two.\r\n\r\nhave fun! \r\n\r\n\r\n","description_html":"\u003cp\u003eGiven a integer n, we can generate a sequence [0,1,2,3,4,..., 2^n-1], then we separate it to two sequence according to their index position which is odd or even. We repeat this action until the number of sequence equal 2.\u003c/p\u003e\u003cp\u003efor example:\u003c/p\u003e\u003cp\u003en = 3;\u003c/p\u003e\u003cp\u003ev = [0, 1, 2, 3, 4, 5 , 6, 7]\u003c/p\u003e\u003cp\u003estep 1:\u003c/p\u003e\u003cp\u003eO = [0, 2, 4, 6]\u003c/p\u003e\u003cp\u003eE = [1, 3, 5, 7]\u003c/p\u003e\u003cp\u003eso v1 = {[0, 2, 4, 6], [1, 3, 5, 7]}\u003c/p\u003e\u003cp\u003estep 2:\u003c/p\u003e\u003cp\u003efor every element of this cell, wo separate, we can get\u003c/p\u003e\u003cp\u003ev2 = {[0, 4], [2, 6], [1, 5], [3, 7]}\u003c/p\u003e\u003cp\u003ethis is the solution, because the number of every element is two.\u003c/p\u003e\u003cp\u003ehave fun!\u003c/p\u003e","function_template":"function y = odd_and_even_fun(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nfor n = 3 : 12\r\n    y = odd_and_even_fun(n);\r\n    while length(y) ~= 1\r\n        y = cellfun(@(x)x(:)',mat2cell(cell2mat(reshape(y,2,'')),2,repelem(numel(y{1}),length(y)/2)),'uni',0);\r\n    end\r\n    assert(isequal(y{1},0:2^n-1))\r\nend\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":3668,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":20,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-07T04:29:13.000Z","updated_at":"2026-01-23T14:29:34.000Z","published_at":"2018-08-07T04:29: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\u003eGiven a integer n, we can generate a sequence [0,1,2,3,4,..., 2^n-1], then we separate it to two sequence according to their index position which is odd or even. We repeat this action until the number of sequence equal 2.\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\u003en = 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ev = [0, 1, 2, 3, 4, 5 , 6, 7]\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\u003estep 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eO = [0, 2, 4, 6]\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 = [1, 3, 5, 7]\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\u003eso v1 = {[0, 2, 4, 6], [1, 3, 5, 7]}\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\u003estep 2:\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 every element of this cell, wo separate, we can get\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\u003ev2 = {[0, 4], [2, 6], [1, 5], [3, 7]}\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\u003ethis is the solution, because the number of every element is two.\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\u003ehave fun!\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":42083,"title":"Ring Matrix","description":"Given n (only odd), return output matrix a that has concentric rings of the numbers 1 through (n+1)/2 around the center point.\r\n\r\nFor n = 3,\r\n\r\n  a = [2 2 2;\r\n       2 1 2;\r\n       2 2 2;]\r\n\r\nFor n = 5,\r\n\r\n  a = [3 3 3 3 3;\r\n       3 2 2 2 3;\r\n       3 2 1 2 3;\r\n       3 2 2 2 3;\r\n       3 3 3 3 3;]\r\n","description_html":"\u003cp\u003eGiven n (only odd), return output matrix a that has concentric rings of the numbers 1 through (n+1)/2 around the center point.\u003c/p\u003e\u003cp\u003eFor n = 3,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ea = [2 2 2;\r\n     2 1 2;\r\n     2 2 2;]\r\n\u003c/pre\u003e\u003cp\u003eFor n = 5,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ea = [3 3 3 3 3;\r\n     3 2 2 2 3;\r\n     3 2 1 2 3;\r\n     3 2 2 2 3;\r\n     3 3 3 3 3;]\r\n\u003c/pre\u003e","function_template":"function a = concentric_array(n)\r\n a = n;\r\nend","test_suite":"%%\r\nn = 1;\r\na = 1;\r\nassert(isequal(concentric_array(n),a))\r\n\r\n%%\r\nn = 3;\r\na = [2 2 2;\r\n     2 1 2;\r\n     2 2 2];\r\nassert(isequal(concentric_array(n),a))\r\n\r\n%%\r\nn = 5;\r\na = [3 3 3 3 3;\r\n     3 2 2 2 3;\r\n     3 2 1 2 3;\r\n     3 2 2 2 3;\r\n     3 3 3 3 3];\r\nassert(isequal(concentric_array(n),a))\r\n\r\n%%\r\nn = 7;\r\na = [4 4 4 4 4 4 4;\r\n     4 3 3 3 3 3 4;\r\n     4 3 2 2 2 3 4;\r\n     4 3 2 1 2 3 4;\r\n     4 3 2 2 2 3 4;\r\n     4 3 3 3 3 3 4;\r\n     4 4 4 4 4 4 4];\r\nassert(isequal(concentric_array(n),a))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":15348,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":"2016-09-30T20:59:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-04-21T05:24:21.000Z","updated_at":"2026-02-18T16:42:50.000Z","published_at":"2015-04-21T05:24:28.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 n (only odd), return output matrix a that has concentric rings of the numbers 1 through (n+1)/2 around the center point.\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 n = 3,\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 = [2 2 2;\\n     2 1 2;\\n     2 2 2;]]]\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 n = 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[a = [3 3 3 3 3;\\n     3 2 2 2 3;\\n     3 2 1 2 3;\\n     3 2 2 2 3;\\n     3 3 3 3 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\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":43114,"title":"Add the odd numbers","description":"Add only the odd numbers of x\r\n\r\nexample:\r\n\r\n x = [1 2 3 4 5]\r\n\r\nthe positive numbers are: 1 3 5, so their sum is 9","description_html":"\u003cp\u003eAdd only the odd numbers of x\u003c/p\u003e\u003cp\u003eexample:\u003c/p\u003e\u003cpre\u003e x = [1 2 3 4 5]\u003c/pre\u003e\u003cp\u003ethe positive numbers are: 1 3 5, so their sum is 9\u003c/p\u003e","function_template":"function y = addOdd(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 2 3 4 5];\r\ny_correct = 9;\r\nassert(isequal(addOdd(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5 7];\r\ny_correct = 16;\r\nassert(isequal(addOdd(x),y_correct))\r\n%%\r\nx = [1 2 4 5 7];\r\ny_correct = 13;\r\nassert(isequal(addOdd(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":94929,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":85,"test_suite_updated_at":"2016-10-19T11:36:43.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-06T08:49:13.000Z","updated_at":"2026-02-13T18:24:27.000Z","published_at":"2016-10-06T08:49:13.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\u003eAdd only the odd numbers of x\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[ x = [1 2 3 4 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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethe positive numbers are: 1 3 5, so their sum is 9\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":43140,"title":"Odd times even numbers in a matrix","description":"First count the number of odd numbers in x, then the number of even. Return their product.\r\n\r\nexample:\r\n\r\n x = [1 2]\r\n\r\nOne odd and one even. The product is thus 1.","description_html":"\u003cp\u003eFirst count the number of odd numbers in x, then the number of even. Return their product.\u003c/p\u003e\u003cp\u003eexample:\u003c/p\u003e\u003cpre\u003e x = [1 2]\u003c/pre\u003e\u003cp\u003eOne odd and one even. The product is thus 1.\u003c/p\u003e","function_template":"function y = oddXeven(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(oddXeven(x),y_correct))\r\n%%\r\nx = [1 2];\r\ny_correct = 1;\r\nassert(isequal(oddXeven(x),y_correct))\r\n%%\r\nx = [1 2 3];\r\ny_correct = 2;\r\nassert(isequal(oddXeven(x),y_correct))\r\n%%\r\nx = [1 2 3 4];\r\ny_correct = 4;\r\nassert(isequal(oddXeven(x),y_correct))\r\n%%\r\nx = [1 2 4];\r\ny_correct = 2;\r\nassert(isequal(oddXeven(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":94929,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":68,"test_suite_updated_at":"2016-10-19T11:32:53.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-10-07T08:43:50.000Z","updated_at":"2026-02-17T17:52:19.000Z","published_at":"2016-10-07T08:43:50.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\u003eFirst count the number of odd numbers in x, then the number of even. Return their product.\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[ x = [1 2]]]\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\u003eOne odd and one even. The product is thus 1.\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":43141,"title":"All odd - all even","description":"All odd numbers in x are added, while all even numers are subtracted from this.\r\n\r\nexample:\r\n\r\n x = [1 2 3 4 5];\r\n y = +(1+3+5)-(2+4) = 3","description_html":"\u003cp\u003eAll odd numbers in x are added, while all even numers are subtracted from this.\u003c/p\u003e\u003cp\u003eexample:\u003c/p\u003e\u003cpre\u003e x = [1 2 3 4 5];\r\n y = +(1+3+5)-(2+4) = 3\u003c/pre\u003e","function_template":"function y = oddMinusEven(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1];\r\ny_correct = 1;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2];\r\ny_correct = -1;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3];\r\ny_correct = 2;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3 4];\r\ny_correct = -2;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5];\r\ny_correct = 3;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5 6];\r\ny_correct = -3;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5 6 7];\r\ny_correct = 4;\r\nassert(isequal(oddMinusEven(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":94929,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":74,"test_suite_updated_at":"2016-10-19T11:31:58.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-10-07T08:48:53.000Z","updated_at":"2026-02-10T11:35:19.000Z","published_at":"2016-10-07T08:48: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\u003eAll odd numbers in x are added, while all even numers are subtracted from this.\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[ x = [1 2 3 4 5];\\n y = +(1+3+5)-(2+4) = 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":44158,"title":"Even or Odd","description":"Write a function which can tell us if the given value x is odd or even. So if x is even return true and if x is odd return false.\r\n\r\nExamples:\r\n\r\n Input:  x = 9;\r\n Output: y = false;\r\n","description_html":"\u003cp\u003eWrite a function which can tell us if the given value x is odd or even. So if x is even return true and if x is odd return false.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e Input:  x = 9;\r\n Output: y = false;\u003c/pre\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = false;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = false;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = true;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 11;\r\ny_correct = false;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 22;\r\ny_correct = true;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 13;\r\ny_correct = false;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = [56 117 8 24 44 33 15];\r\ny_correct = [true false true true true false false];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = [99 558 100; 101 6 4; 44 31 39];\r\ny_correct = [false true true; false true true; true false false];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nfiletext = fileread('your_fcn_name.m');\r\nassert(isempty(strfind(filetext, 'for')),'for command is forbidden')\r\nassert(isempty(strfind(filetext, 'repelem')),'repelem command is forbidden')\r\nassert(isempty(strfind(filetext, 'discretize')),'discretize command is forbidden')\r\nassert(isempty(strfind(filetext, 'while')),'while command is forbidden')\r\nassert(isempty(strfind(filetext, 'if')),'if command is forbidden')\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":37163,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":"2017-05-13T10:06:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-05-12T19:40:58.000Z","updated_at":"2026-03-15T04:04:38.000Z","published_at":"2017-05-12T20:01:56.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\u003eWrite a function which can tell us if the given value x is odd or even. So if x is even return true and if x is odd return false.\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[ Input:  x = 9;\\n Output: y = false;]]\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":43006,"title":"Odd row","description":"Create a row 'y' with odd numbers where the potential maximum number is given by 'x' and the space between them by 'm'. The first number of the row is 1.","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: 42px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 21px; transform-origin: 407px 21px; vertical-align: baseline; \"\u003e\u003cdiv style=\"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: 384px 8px; transform-origin: 384px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCreate a row 'y' with odd numbers where the potential maximum number is given by 'x' and the space between them by 'm'. The first number of the row is 1.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = OddRow(x)\r\n  y = 1;\r\nend","test_suite":"%%\r\nr = 15;\r\nm = 4;\r\ny_correct = [1 5 9 13];\r\nassert(isequal(OddRow(r,m),y_correct))\r\n\r\n\r\n%%\r\nr = 21;\r\nm = 6;\r\ny_correct = [1 7 13 19];\r\nassert(isequal(OddRow(r,m),y_correct))\r\n\r\n\r\n%%\r\nr = 31;\r\nm = 8;\r\ny_correct = [1 9 17 25];\r\nassert(isequal(OddRow(r,m),y_correct))\r\n\r\n%%\r\nr = 27;\r\nm = 4;\r\ny_correct = [1 5 9 13 17 21 25];\r\nassert(isequal(OddRow(r,m),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":3,"created_by":94418,"edited_by":223089,"edited_at":"2022-10-22T09:41:38.000Z","deleted_by":null,"deleted_at":null,"solvers_count":84,"test_suite_updated_at":"2022-10-22T09:41:38.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-10-02T12:01:30.000Z","updated_at":"2026-02-28T13:13:45.000Z","published_at":"2016-10-02T12:01:30.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\u003eCreate a row 'y' with odd numbers where the potential maximum number is given by 'x' and the space between them by 'm'. The first number of the row is 1.\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":44397,"title":"Determine whether the input is odd, even, or neither.","description":"Make a function that returns ‘odd’ if the input is odd, ‘even’ if the input if even or ‘error’ if the input  is neither odd nor even. Where the input could be a number, letter or symbol.","description_html":"\u003cp\u003eMake a function that returns ‘odd’ if the input is odd, ‘even’ if the input if even or ‘error’ if the input  is neither odd nor even. Where the input could be a number, letter or symbol.\u003c/p\u003e","function_template":"function n=oddornot(x);\r\n\r\nend","test_suite":"%%\r\nx = 1;\r\nn_correct = 'odd';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 12;\r\nn_correct = 'even';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 467.3;\r\nn_correct = 'error';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = -911;\r\nn_correct = 'odd';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 8230749726348;\r\nn_correct = 'even';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = pi;\r\nn_correct = 'error';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 'a';\r\nn_correct = 'error';\r\nassert(isequal(oddornot(x),n_correct))\r\n%%\r\nx = 'donald';\r\nn_correct = 'error';\r\nassert(isequal(oddornot(x),n_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":157578,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":52,"test_suite_updated_at":"2017-11-07T16:19:21.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2017-11-03T15:22:49.000Z","updated_at":"2026-04-01T11:19:18.000Z","published_at":"2017-11-03T15:22:49.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\u003eMake a function that returns ‘odd’ if the input is odd, ‘even’ if the input if even or ‘error’ if the input is neither odd nor even. Where the input could be a number, letter or symbol.\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":42318,"title":"Evened up (or not)","description":"You will be provided with an array or matrix that contains various numbers, in addition to an evening variable, e, set to 1 or 0. If e==1, then you should return an evened version of the matrix, wherein all odd numbers have one added to them to make them even. For example, \r\n\r\n* if M = 1:10, \r\n* then the evened array is [2,2,4,4,6,6,8,8,10,10].\r\n\r\nOn the other hand, if e==0, then you should return the same matrix with only odd numbers, wherein one has been added to every even number. For example,\r\n\r\n* if M = 1:10, \r\n* then the odd array is [1,3,3,5,5,7,7,9,9,11].","description_html":"\u003cp\u003eYou will be provided with an array or matrix that contains various numbers, in addition to an evening variable, e, set to 1 or 0. If e==1, then you should return an evened version of the matrix, wherein all odd numbers have one added to them to make them even. For example,\u003c/p\u003e\u003cul\u003e\u003cli\u003eif M = 1:10,\u003c/li\u003e\u003cli\u003ethen the evened array is [2,2,4,4,6,6,8,8,10,10].\u003c/li\u003e\u003c/ul\u003e\u003cp\u003eOn the other hand, if e==0, then you should return the same matrix with only odd numbers, wherein one has been added to every even number. For example,\u003c/p\u003e\u003cul\u003e\u003cli\u003eif M = 1:10,\u003c/li\u003e\u003cli\u003ethen the odd array is [1,3,3,5,5,7,7,9,9,11].\u003c/li\u003e\u003c/ul\u003e","function_template":"function [M] = evened_up(M,e)\r\n\r\nM = M;\r\n\r\nend\r\n","test_suite":"%%\r\nM = 1:10;\r\ne = 1;\r\nM_corr = [2,2,4,4,6,6,8,8,10,10];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 1:10;\r\ne = 0;\r\nM_corr = [1,3,3,5,5,7,7,9,9,11];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 20:3:50;\r\ne = 1;\r\nM_corr = [20,24,26,30,32,36,38,42,44,48,50];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 20:3:50;\r\ne = 0;\r\nM_corr = [21,23,27,29,33,35,39,41,45,47,51];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 2:2:100;\r\ne = 1;\r\nM_corr = M;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = 2:2:100;\r\ne = 0;\r\nM_corr = M+1;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = ones(3);\r\ne = 1;\r\nM_corr = M*2;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = magic(3);\r\ne = 0;\r\nM_corr = [9,1,7;3,5,7;5,9,3];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = magic(3);\r\ne = 1;\r\nM_corr = [8,2,6;4,6,8;4,10,2];\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = eye(4);\r\ne = 1;\r\nM_corr = M*2;\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nM = eye(4);\r\ne = 0;\r\nM_corr = ones(4);\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 1:10;\r\n\t\te = 1;\r\n\t\tM_corr = [2,2,4,4,6,6,8,8,10,10];\r\n\tcase 2\r\n\t\tM = 20:3:50;\r\n\t\te = 1;\r\n\t\tM_corr = [20,24,26,30,32,36,38,42,44,48,50];\r\n\tcase 3\r\n\t\tM = ones(3);\r\n\t\te = 1;\r\n\t\tM_corr = M*2;\r\n\tcase 4\r\n\t\tM = eye(4);\r\n\t\te = 0;\r\n\t\tM_corr = ones(4);\r\nend\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = 2:2:100;\r\n\t\te = 0;\r\n\t\tM_corr = M+1;\r\n\tcase 2\r\n\t\tM = 1:10;\r\n\t\te = 0;\r\n\t\tM_corr = [1,3,3,5,5,7,7,9,9,11];\r\n\tcase 3\r\n\t\tM = 1:10;\r\n\t\te = 1;\r\n\t\tM_corr = [2,2,4,4,6,6,8,8,10,10];\r\n\tcase 4\r\n\t\tM = magic(3);\r\n\t\te = 0;\r\n\t\tM_corr = [9,1,7;3,5,7;5,9,3];\r\nend\r\nassert(isequal(evened_up(M,e),M_corr))\r\n\r\n%%\r\nind = randi(4);\r\nswitch ind\r\n\tcase 1\r\n\t\tM = eye(4);\r\n\t\te = 0;\r\n\t\tM_corr = ones(4);\r\n\tcase 2\r\n\t\tM = ones(3);\r\n\t\te = 1;\r\n\t\tM_corr = M*2;\r\n\tcase 3\r\n\t\tM = 20:3:50;\r\n\t\te = 1;\r\n\t\tM_corr = [20,24,26,30,32,36,38,42,44,48,50];\r\n\tcase 4\r\n\t\tM = 2:2:100;\r\n\t\te = 1;\r\n\t\tM_corr = M;\r\nend\r\nassert(isequal(evened_up(M,e),M_corr))\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":175,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":45,"created_at":"2015-05-17T02:32:54.000Z","updated_at":"2026-04-02T10:10:53.000Z","published_at":"2015-05-17T02:32: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\u003eYou will be provided with an array or matrix that contains various numbers, in addition to an evening variable, e, set to 1 or 0. If e==1, then you should return an evened version of the matrix, wherein all odd numbers have one added to them to make them even. For example,\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\u003eif M = 1: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\u003ethen the evened array is [2,2,4,4,6,6,8,8,10,10].\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\u003eOn the other hand, if e==0, then you should return the same matrix with only odd numbers, wherein one has been added to every even number. For example,\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\u003eif M = 1: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\u003ethen the odd array is [1,3,3,5,5,7,7,9,9,11].\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":44721,"title":"Seperate array to small section according to its index position","description":"Given a integer n, we can generate a sequence [0,1,2,3,4,..., 2^n-1], then we separate it to two sequence according to their index position which is odd or even. We repeat this action until the number of sequence equal 2.\r\n\r\nfor example:\r\n\r\nn = 3;\r\n\r\n\r\nv = [0, 1, 2, 3, 4, 5 , 6, 7]\r\n\r\nstep 1:\r\n\r\nO = [0, 2, 4, 6]\r\n\r\nE = [1, 3, 5, 7]\r\n\r\nso v1 = {[0, 2, 4, 6], [1, 3, 5, 7]}\r\n\r\nstep 2:\r\n\r\nfor every element of this cell, wo separate, we can get\r\n\r\nv2 = {[0, 4], [2, 6], [1, 5], [3, 7]}\r\n\r\nthis is the solution, because the number of every element is two.\r\n\r\nhave fun! \r\n\r\n\r\n","description_html":"\u003cp\u003eGiven a integer n, we can generate a sequence [0,1,2,3,4,..., 2^n-1], then we separate it to two sequence according to their index position which is odd or even. We repeat this action until the number of sequence equal 2.\u003c/p\u003e\u003cp\u003efor example:\u003c/p\u003e\u003cp\u003en = 3;\u003c/p\u003e\u003cp\u003ev = [0, 1, 2, 3, 4, 5 , 6, 7]\u003c/p\u003e\u003cp\u003estep 1:\u003c/p\u003e\u003cp\u003eO = [0, 2, 4, 6]\u003c/p\u003e\u003cp\u003eE = [1, 3, 5, 7]\u003c/p\u003e\u003cp\u003eso v1 = {[0, 2, 4, 6], [1, 3, 5, 7]}\u003c/p\u003e\u003cp\u003estep 2:\u003c/p\u003e\u003cp\u003efor every element of this cell, wo separate, we can get\u003c/p\u003e\u003cp\u003ev2 = {[0, 4], [2, 6], [1, 5], [3, 7]}\u003c/p\u003e\u003cp\u003ethis is the solution, because the number of every element is two.\u003c/p\u003e\u003cp\u003ehave fun!\u003c/p\u003e","function_template":"function y = odd_and_even_fun(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nfor n = 3 : 12\r\n    y = odd_and_even_fun(n);\r\n    while length(y) ~= 1\r\n        y = cellfun(@(x)x(:)',mat2cell(cell2mat(reshape(y,2,'')),2,repelem(numel(y{1}),length(y)/2)),'uni',0);\r\n    end\r\n    assert(isequal(y{1},0:2^n-1))\r\nend\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":3668,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":20,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-07T04:29:13.000Z","updated_at":"2026-01-23T14:29:34.000Z","published_at":"2018-08-07T04:29: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\u003eGiven a integer n, we can generate a sequence [0,1,2,3,4,..., 2^n-1], then we separate it to two sequence according to their index position which is odd or even. We repeat this action until the number of sequence equal 2.\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\u003en = 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ev = [0, 1, 2, 3, 4, 5 , 6, 7]\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\u003estep 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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eO = [0, 2, 4, 6]\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 = [1, 3, 5, 7]\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\u003eso v1 = {[0, 2, 4, 6], [1, 3, 5, 7]}\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\u003estep 2:\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 every element of this cell, wo separate, we can get\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\u003ev2 = {[0, 4], [2, 6], [1, 5], [3, 7]}\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\u003ethis is the solution, because the number of every element is two.\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\u003ehave fun!\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":42083,"title":"Ring Matrix","description":"Given n (only odd), return output matrix a that has concentric rings of the numbers 1 through (n+1)/2 around the center point.\r\n\r\nFor n = 3,\r\n\r\n  a = [2 2 2;\r\n       2 1 2;\r\n       2 2 2;]\r\n\r\nFor n = 5,\r\n\r\n  a = [3 3 3 3 3;\r\n       3 2 2 2 3;\r\n       3 2 1 2 3;\r\n       3 2 2 2 3;\r\n       3 3 3 3 3;]\r\n","description_html":"\u003cp\u003eGiven n (only odd), return output matrix a that has concentric rings of the numbers 1 through (n+1)/2 around the center point.\u003c/p\u003e\u003cp\u003eFor n = 3,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ea = [2 2 2;\r\n     2 1 2;\r\n     2 2 2;]\r\n\u003c/pre\u003e\u003cp\u003eFor n = 5,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ea = [3 3 3 3 3;\r\n     3 2 2 2 3;\r\n     3 2 1 2 3;\r\n     3 2 2 2 3;\r\n     3 3 3 3 3;]\r\n\u003c/pre\u003e","function_template":"function a = concentric_array(n)\r\n a = n;\r\nend","test_suite":"%%\r\nn = 1;\r\na = 1;\r\nassert(isequal(concentric_array(n),a))\r\n\r\n%%\r\nn = 3;\r\na = [2 2 2;\r\n     2 1 2;\r\n     2 2 2];\r\nassert(isequal(concentric_array(n),a))\r\n\r\n%%\r\nn = 5;\r\na = [3 3 3 3 3;\r\n     3 2 2 2 3;\r\n     3 2 1 2 3;\r\n     3 2 2 2 3;\r\n     3 3 3 3 3];\r\nassert(isequal(concentric_array(n),a))\r\n\r\n%%\r\nn = 7;\r\na = [4 4 4 4 4 4 4;\r\n     4 3 3 3 3 3 4;\r\n     4 3 2 2 2 3 4;\r\n     4 3 2 1 2 3 4;\r\n     4 3 2 2 2 3 4;\r\n     4 3 3 3 3 3 4;\r\n     4 4 4 4 4 4 4];\r\nassert(isequal(concentric_array(n),a))","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":15348,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":"2016-09-30T20:59:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2015-04-21T05:24:21.000Z","updated_at":"2026-02-18T16:42:50.000Z","published_at":"2015-04-21T05:24:28.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 n (only odd), return output matrix a that has concentric rings of the numbers 1 through (n+1)/2 around the center point.\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 n = 3,\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 = [2 2 2;\\n     2 1 2;\\n     2 2 2;]]]\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 n = 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[a = [3 3 3 3 3;\\n     3 2 2 2 3;\\n     3 2 1 2 3;\\n     3 2 2 2 3;\\n     3 3 3 3 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\"}]}"}],"term":"tag:\"odd\"","current_player_id":null,"fields":[{"name":"page","type":"integer","callback":null,"default":1,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"per_page","type":"integer","callback":null,"default":50,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"sort","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":null,"prepend":true},{"name":"body","type":"text","callback":null,"default":"*:*","directive":null,"facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":false},{"name":"group","type":"string","callback":null,"default":null,"directive":"group","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"difficulty_rating_bin","type":"string","callback":null,"default":null,"directive":"difficulty_rating_bin","facet":true,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"id","type":"integer","callback":null,"default":null,"directive":"id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"tag","type":"string","callback":null,"default":null,"directive":"tag","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"product","type":"string","callback":null,"default":null,"directive":"product","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_at","type":"timeframe","callback":{},"default":null,"directive":"created_at","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"profile_id","type":"integer","callback":null,"default":null,"directive":"author_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"created_by","type":"string","callback":null,"default":null,"directive":"author","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player_id","type":"integer","callback":null,"default":null,"directive":"solver_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"player","type":"string","callback":null,"default":null,"directive":"solver","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"solvers_count","type":"integer","callback":null,"default":null,"directive":"solvers_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"comments_count","type":"integer","callback":null,"default":null,"directive":"comments_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"likes_count","type":"integer","callback":null,"default":null,"directive":"likes_count","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leader_id","type":"integer","callback":null,"default":null,"directive":"leader_id","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true},{"name":"leading_solution","type":"integer","callback":null,"default":null,"directive":"leading_solution","facet":null,"facet_method":"and","operator":null,"param":"term","static":null,"prepend":true}],"filters":[{"name":"asset_type","type":"string","callback":null,"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":null,"static":"\"cody:problem\"","prepend":true},{"name":"profile_id","type":"integer","callback":{},"default":null,"directive":null,"facet":null,"facet_method":"and","operator":null,"param":"author_id","static":null,"prepend":true}],"query":{"params":{"per_page":50,"term":"tag:\"odd\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"odd\"","","\"","odd","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4f26dd0d20\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f4f26dd0c80\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4f26dd0320\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4f26dd1220\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4f26dd0fa0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4f26dd0e60\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4f26dd0dc0\u003e":"tag:\"odd\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4f26dd0dc0\u003e":"tag:\"odd\""},"queried_facets":{}},"query_backend":{"connection":{"configuration":{"index_url":"http://index-op-v2/solr/","query_url":"http://search-op-v2/solr/","direct_access_index_urls":["http://index-op-v2/solr/"],"direct_access_query_urls":["http://search-op-v2/solr/"],"timeout":10,"vhost":"search","exchange":"search.topic","heartbeat":30,"pre_index_mode":false,"host":"rabbitmq-eks","port":5672,"username":"search","password":"J3bGPZzQ7asjJcCk","virtual_host":"search","indexer":"amqp","http_logging":"true","core":"cody"},"query_connection":{"uri":"http://search-op-v2/solr/cody/","proxy":null,"connection":{"parallel_manager":null,"headers":{"User-Agent":"Faraday v1.0.1"},"params":{},"options":{"params_encoder":"Faraday::FlatParamsEncoder","proxy":null,"bind":null,"timeout":null,"open_timeout":null,"read_timeout":null,"write_timeout":null,"boundary":null,"oauth":null,"context":null,"on_data":null},"ssl":{"verify":true,"ca_file":null,"ca_path":null,"verify_mode":null,"cert_store":null,"client_cert":null,"client_key":null,"certificate":null,"private_key":null,"verify_depth":null,"version":null,"min_version":null,"max_version":null},"default_parallel_manager":null,"builder":{"adapter":{"name":"Faraday::Adapter::NetHttp","args":[],"block":null},"handlers":[{"name":"Faraday::Response::RaiseError","args":[],"block":null}],"app":{"app":{"ssl_cert_store":{"verify_callback":null,"error":null,"error_string":null,"chain":null,"time":null},"app":{},"connection_options":{},"config_block":null}}},"url_prefix":"http://search-op-v2/solr/cody/","manual_proxy":false,"proxy":null},"update_format":"RSolr::JSON::Generator","update_path":"update","options":{"url":"http://search-op-v2/solr/cody"}}},"query":{"params":{"per_page":50,"term":"tag:\"odd\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"odd\"","","\"","odd","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4f26dd0d20\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f4f26dd0c80\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4f26dd0320\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4f26dd1220\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4f26dd0fa0\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4f26dd0e60\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4f26dd0dc0\u003e":"tag:\"odd\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4f26dd0dc0\u003e":"tag:\"odd\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":43114,"difficulty_rating":"easy"},{"id":43140,"difficulty_rating":"easy"},{"id":43141,"difficulty_rating":"easy"},{"id":44158,"difficulty_rating":"easy"},{"id":43006,"difficulty_rating":"easy"},{"id":44397,"difficulty_rating":"easy"},{"id":42318,"difficulty_rating":"easy"},{"id":44721,"difficulty_rating":"easy"},{"id":42083,"difficulty_rating":"easy-medium"}]}}