{"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":44634,"title":"Basic matrix operations using standard MATLAB commands","description":"Create the matrix:\r\n\r\n 1.0e+15 *\r\n\r\n    0.0000    0.0000    0.0000    0.0000    0.0000\r\n    0.0000    0.0000    0.0000    0.0000    0.0000\r\n    0.0001    0.0010    0.0100    0.1000    1.0000\r\n\r\nFind the row vector of all column means\r\n\r\nHint: Use _logspace_ to create the matrix. Avoid looking at the test suite before writing a solution","description_html":"\u003cp\u003eCreate the matrix:\u003c/p\u003e\u003cpre\u003e 1.0e+15 *\u003c/pre\u003e\u003cpre\u003e    0.0000    0.0000    0.0000    0.0000    0.0000\r\n    0.0000    0.0000    0.0000    0.0000    0.0000\r\n    0.0001    0.0010    0.0100    0.1000    1.0000\u003c/pre\u003e\u003cp\u003eFind the row vector of all column means\u003c/p\u003e\u003cp\u003eHint: Use \u003ci\u003elogspace\u003c/i\u003e to create the matrix. Avoid looking at the test suite before writing a solution\u003c/p\u003e","function_template":"function y = matrix_ls_means()\r\n  y = x;\r\nend","test_suite":"%%\r\ny_correct = mean([logspace(1,5,5);logspace(6,10,5);logspace(11,15,5)]);\r\nassert(isequal(matrix_ls_means(),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":"2018-05-09T05:37:01.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-09T05:32:41.000Z","updated_at":"2026-02-17T08:19:25.000Z","published_at":"2018-05-09T05:35: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\",\"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 the matrix:\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.0e+15 *\\n\\n    0.0000    0.0000    0.0000    0.0000    0.0000\\n    0.0000    0.0000    0.0000    0.0000    0.0000\\n    0.0001    0.0010    0.0100    0.1000    1.0000]]\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\u003eFind the row vector of all column means\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\u003eHint: Use\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\u003elogspace\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to create the matrix. Avoid looking at the test suite before writing a solution\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":44670,"title":"Basic Quadratic Equation","description":"Create the equation:\r\n\r\ny=(3x)^2+(5x)+35\r\nand compute y for various values of x","description_html":"\u003cp\u003eCreate the equation:\u003c/p\u003e\u003cp\u003ey=(3x)^2+(5x)+35\r\nand compute y for various values of x\u003c/p\u003e","function_template":"function y = quad1(x)\r\n\r\nend","test_suite":"%%\r\nx = -3;\r\ny_correct = 101;\r\nassert(isequal(quad1(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = 285;\r\nassert(isequal(quad1(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":91,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-30T10:55:15.000Z","updated_at":"2026-02-13T15:28:08.000Z","published_at":"2018-05-30T10:55:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eCreate the equation:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ey=(3x)^2+(5x)+35 and compute y for various values of x\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":42347,"title":"Create a Standard Size Vector","description":"Given an input x, create a row vector y from 1 to x with 5 elements.","description_html":"\u003cp\u003eGiven an input x, create a row vector y from 1 to x with 5 elements.\u003c/p\u003e","function_template":"function y = standard_vector(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 220;\r\ny_correct = [1.0000   55.7500  110.5000  165.2500  220.0000];\r\nassert(isequal(standard_vector(x),y_correct))\r\n\r\n%%\r\nx = 801;\r\ny_correct = [ 1   201   401   601   801];\r\nassert(isequal(standard_vector(x),y_correct))\r\n\r\n%%\r\nx = 4;\r\ny_correct = [   1.0000    1.7500    2.5000    3.2500    4.000];\r\nassert(isequal(standard_vector(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":44605,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":150,"test_suite_updated_at":"2015-06-17T17:59:34.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2015-06-01T01:19:15.000Z","updated_at":"2026-02-17T17:52:43.000Z","published_at":"2015-06-01T01:19:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input x, create a row vector y from 1 to x with 5 elements.\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":42346,"title":"Create a Matrix of Zeros","description":"Given an input x, create a square matrix y of zeros with x rows and x columns.","description_html":"\u003cp\u003eGiven an input x, create a square matrix y of zeros with x rows and x columns.\u003c/p\u003e","function_template":"function y = matrix_zeros(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2;\r\ny_correct = [ ...\r\n     0     0  \r\n     0     0  ];\r\nassert(isequal(matrix_zeros(x),y_correct))\r\n\r\n%%\r\nx = 6;\r\ny_correct = [ ...\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0];\r\nassert(isequal(matrix_zeros(x),y_correct))\r\n\r\n%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(matrix_zeros(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":44605,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":647,"test_suite_updated_at":"2015-06-17T18:04:48.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2015-06-01T01:15:52.000Z","updated_at":"2026-02-15T15:03:06.000Z","published_at":"2015-06-01T01:16:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input x, create a square matrix y of zeros with x rows and x columns.\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":44653,"title":"Basics: counting digits of a number irrespective of the sign","description":"publish the number of digits in any input integer\r\nexample: -23----\u003e2","description_html":"\u003cp\u003epublish the number of digits in any input integer\r\nexample: -23----\u0026gt;2\u003c/p\u003e","function_template":"function y = count_digits(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = -21;\r\ny_correct = 2;\r\nassert(isequal(count_digits(x),y_correct))\r\n\r\n%%\r\nx = 3567;\r\ny_correct = 4;\r\nassert(isequal(count_digits(x),y_correct))\r\n\r\n%%\r\nx = -2;\r\ny_correct = 1;\r\nassert(isequal(count_digits(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":70,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-25T11:35:55.000Z","updated_at":"2026-02-28T08:19:58.000Z","published_at":"2018-05-25T11:35:55.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003epublish the number of digits in any input integer example: -23----\u0026gt;2\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":44621,"title":"Product of all elements in an array","description":"Compute the product of all elements in an array.","description_html":"\u003cp\u003eCompute the product of all elements in an array.\u003c/p\u003e","function_template":"function y = array_prod(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 2 5];\r\ny_correct = 10;\r\nassert(isequal(array_prod(x),y_correct))\r\n\r\n%%\r\nx = [10, 200];\r\ny_correct = 2000;\r\nassert(isequal(array_prod(x),y_correct))\r\n\r\n%%\r\nx = [true, false];\r\ny_correct = 0;\r\nassert(isequal(array_prod(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":93,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-20T18:07:49.000Z","updated_at":"2026-02-13T19:02:31.000Z","published_at":"2018-04-20T18:07: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\u003eCompute the product of all elements in an array.\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":44654,"title":"convert the number to binary format \u0026 count digits","description":"Convert the given number to the corresponding binary format and count the number of digits in that binary number","description_html":"\u003cp\u003eConvert the given number to the corresponding binary format and count the number of digits in that binary number\u003c/p\u003e","function_template":"function y = dec_2_bin(x)\r\n \r\nend","test_suite":"%%\r\nx = 23;\r\ny_correct = 5;\r\nassert(isequal(dec_2_bin(x),y_correct))\r\n\r\n%%\r\nx = 234;\r\ny_correct = 8;\r\nassert(isequal(dec_2_bin(x),y_correct))\r\n\r\n%%\r\nx = 22;\r\ny_correct = 5;\r\nassert(isequal(dec_2_bin(x),y_correct))\r\n\r\n%%\r\nx = 2;\r\ny_correct = 2;\r\nassert(isequal(dec_2_bin(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-25T11:50:28.000Z","updated_at":"2026-02-10T18:29:49.000Z","published_at":"2018-05-25T11:50: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\",\"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\u003eConvert the given number to the corresponding binary format and count the number of digits in that binary number\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":44622,"title":"Check for keywords","description":"If the entered string is a MATLAB keyword, return true else false","description_html":"\u003cp\u003eIf the entered string is a MATLAB keyword, return true else false\u003c/p\u003e","function_template":"function y = check_keyword(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'function';\r\ny_correct = true;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'persistent';\r\ny_correct = true;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'classdef';\r\ny_correct = true;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'variable';\r\ny_correct = false;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'dateadd';\r\ny_correct = false;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'spmd';\r\ny_correct = true;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'partition';\r\ny_correct = false;\r\nassert(isequal(check_keyword(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-21T03:51:04.000Z","updated_at":"2026-02-27T14:13:45.000Z","published_at":"2018-04-21T03:51:04.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the entered string is a MATLAB keyword, return true else false\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":44687,"title":"basic matrix operations: rotate and find sum of diagonal elements of the resultant matrix","description":"For given input matrix a, rotate it by 90 degrees and find the sum of the diagonals.\r\n\r\nExample:\r\nInput:\r\n\r\n  a =\r\n\r\n     1     2     3     4\r\n     5     6     7     8\r\n     8    10    12    -2\r\n    -1    -3    -5    -7\r\n\r\nOutput is: \r\n\r\n  20","description_html":"\u003cp\u003eFor given input matrix a, rotate it by 90 degrees and find the sum of the diagonals.\u003c/p\u003e\u003cp\u003eExample:\r\nInput:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ea =\r\n\u003c/pre\u003e\u003cpre\u003e     1     2     3     4\r\n     5     6     7     8\r\n     8    10    12    -2\r\n    -1    -3    -5    -7\u003c/pre\u003e\u003cp\u003eOutput is:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e20\r\n\u003c/pre\u003e","function_template":"function ans = matrix_manipulation(x)\r\n  \r\nend","test_suite":"%%\r\nx = [1 2 3 4; 5 6 7 8;8 10, 12, -2;-1 -3 -5,-7];\r\ny_correct = 20;\r\nassert(isequal(matrix_manipulation(x),y_correct))\r\n\r\n%%\r\nx = ones(5).*3\r\ny_correct = 15;\r\nassert(isequal(matrix_manipulation(x),y_correct))\r\n\r\n%%\r\na=[3,2,5]\r\nx = [a;a;a];\r\ny_correct = 10;\r\nassert(isequal(matrix_manipulation(x),y_correct))\r\n\r\n%%\r\nx = [-5,25,-10;8,-18,10;-2,7,-1]\r\ny_correct = -30;\r\nassert(isequal(matrix_manipulation(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":62,"test_suite_updated_at":"2018-06-13T08:54:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-06-13T08:49:50.000Z","updated_at":"2026-03-02T08:56:19.000Z","published_at":"2018-06-13T08:54:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor given input matrix a, rotate it by 90 degrees and find the sum of the diagonals.\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: 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[a =\\n\\n     1     2     3     4\\n     5     6     7     8\\n     8    10    12    -2\\n    -1    -3    -5    -7]]\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\u003eOutput is:\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[20]]\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":42348,"title":"Square a Number","description":"Given an input x, return y, which is equal to the square of x.","description_html":"\u003cp\u003eGiven an input x, return y, which is equal to the square of x.\u003c/p\u003e","function_template":"function y = square(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 4;\r\ny_correct = 16;\r\nassert(isequal(square(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":44605,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":899,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-06-01T01:29:01.000Z","updated_at":"2026-02-15T15:05:29.000Z","published_at":"2015-06-01T01:29:01.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input x, return y, which is equal to the square of x.\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":1926,"title":"Unit Matrix","description":"Given n, you should return an n-by-n unit matrix.\r\nExample:\r\nIf input is n=2 then\r\n A = [ 1 0 \r\n       0 1 ]\r\nIf input is n=4 then\r\n A = [ 1 0 0 0\r\n       0 1 0 0\r\n       0 0 1 0 \r\n       0 0 0 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: 254.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 127.3px; transform-origin: 407px 127.3px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 152.5px 8px; transform-origin: 152.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven n, you should return an n-by-n unit matrix.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 58px 8px; transform-origin: 58px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf input is n=2 then\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 44px 8.5px; tab-size: 4; transform-origin: 44px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e A = [ 1 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 48px 8.5px; tab-size: 4; transform-origin: 48px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0 1 ]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 58px 8px; transform-origin: 58px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf input is n=4 then\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; tab-size: 4; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e A = [ 1 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; tab-size: 4; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0 1 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0 0 1 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 64px 8.5px; tab-size: 4; transform-origin: 64px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0 0 0 1 ]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2;\r\ny_correct = [1 0;0 1];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = 3;\r\ny_correct = [1 0 0;0 1 0; 0 0 1];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":18257,"edited_by":223089,"edited_at":"2022-10-31T04:49:45.000Z","deleted_by":null,"deleted_at":null,"solvers_count":512,"test_suite_updated_at":"2022-10-31T04:49:45.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-10-09T18:48:08.000Z","updated_at":"2026-02-09T16:23:54.000Z","published_at":"2013-10-09T18:48:08.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\u003eGiven n, you should return an n-by-n unit matrix.\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=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf input is n=2 then\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 0 \\n       0 1 ]]]\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\u003eIf input is n=4 then\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 0 0 0\\n       0 1 0 0\\n       0 0 1 0 \\n       0 0 0 1 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44620,"title":"generate capital english alphabets ","description":"Based on the numeric input 'n', generate the capital english alphabet starting from A till the english alphabet at the 'n'th position.\r\n\r\nEx: if n=3, generate 'ABC'","description_html":"\u003cp\u003eBased on the numeric input 'n', generate the capital english alphabet starting from A till the english alphabet at the 'n'th position.\u003c/p\u003e\u003cp\u003eEx: if n=3, generate 'ABC'\u003c/p\u003e","function_template":"function letters = generate_alphabets(n)\r\n letters = [];\r\nend","test_suite":"%%\r\nn = 1;\r\ny_correct = 'A';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 6;\r\ny_correct = 'ABCDEF';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 26;\r\ny_correct = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 12;\r\ny_correct = 'ABCDEFGHIJKL';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 21;\r\ny_correct = 'ABCDEFGHIJKLMNOPQRSTU';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 3;\r\ny_correct = 'ABC';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":"2018-07-16T17:02:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-20T08:51:49.000Z","updated_at":"2026-03-02T08:58:15.000Z","published_at":"2018-04-20T08:51: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\u003eBased on the numeric input 'n', generate the capital english alphabet starting from A till the english alphabet at the 'n'th position.\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\u003eEx: if n=3, generate 'ABC'\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":1501,"title":"Try 1.5.4: Celsius to Fahrenheit","description":"Write a program to convert an input given in Celsius to Fahrenheit.\r\n\r\nExamples:\r\n\r\n Input  celsiusValue = 100\r\n Output fahrValue is 212\r\n\r\n Input  celsiusValue  = 0\r\n Output fahrValue is 32","description_html":"\u003cp\u003eWrite a program to convert an input given in Celsius to Fahrenheit.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e Input  celsiusValue = 100\r\n Output fahrValue is 212\u003c/pre\u003e\u003cpre\u003e Input  celsiusValue  = 0\r\n Output fahrValue is 32\u003c/pre\u003e","function_template":"function fahrValue = ConvertCelsiusToFahrenheit(celsiusValue)\r\n% Modify the line below so that the output y is the input x converted to Fahrenheit.\r\n\r\n  fahrValue = celsiusValue;\r\n\r\n% After you fix the code, press the \"Submit\" button, and you're on your way.\r\nend","test_suite":"%%\r\ncelsiusValue = 1;\r\nfahrValue = 33.8;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))\r\n%%\r\ncelsiusValue = 0;\r\nfahrValue = 32.0;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))\r\n%%\r\ncelsiusValue = 100;\r\nfahrValue = 212;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))\r\n%%\r\ncelsiusValue = -100;\r\nfahrValue = -148;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))\r\n%%\r\ncelsiusValue = -10;\r\nfahrValue = 14;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":13656,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":867,"test_suite_updated_at":"2013-05-13T02:47:06.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-05-12T04:05:29.000Z","updated_at":"2026-02-19T11:02:07.000Z","published_at":"2013-05-12T04:05: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\u003eWrite a program to convert an input given in Celsius to Fahrenheit.\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  celsiusValue = 100\\n Output fahrValue is 212\\n\\n Input  celsiusValue  = 0\\n Output fahrValue is 32]]\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":8,"title":"Add two numbers","description":"Given a and b, return the sum a+b in c.","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: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; 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 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 123.5px 8px; transform-origin: 123.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a and b, return the sum a+b in c.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function c = add_two_numbers(a,b)\r\n  c = 17;\r\nend","test_suite":"%%\r\nfiletext = fileread('add_two_numbers.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'if') || contains(filetext, 'switch'); \r\nassert(~illegal)\r\n\r\n%%\r\na = 1;\r\nb = 2;\r\nc_correct = 3;\r\nassert(isequal(add_two_numbers(a,b),c_correct))\r\n\r\n%%\r\na = 17;\r\nb = 2;\r\nc_correct = 19;\r\nassert(isequal(add_two_numbers(a,b),c_correct))\r\n\r\n\r\n%%\r\na = -5;\r\nb = 2;\r\nc_correct = -3;\r\nassert(isequal(add_two_numbers(a,b),c_correct))\r\n\r\n%%\r\na = randi(1e4);\r\nb = -a;\r\nassert(isequal(add_two_numbers(a,b),0))\r\n\r\n%%\r\na = randi(1e3);\r\nb = a;\r\nassert(isequal(add_two_numbers(a,b),2*a))\r\n","published":true,"deleted":false,"likes_count":306,"comments_count":84,"created_by":1,"edited_by":223089,"edited_at":"2022-12-19T10:49:35.000Z","deleted_by":null,"deleted_at":null,"solvers_count":46842,"test_suite_updated_at":"2022-12-19T10:49:47.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:18.000Z","updated_at":"2026-04-05T08:26:29.000Z","published_at":"2012-01-18T01:00:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a and b, return the sum a+b in c.\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":44663,"title":"Datetime basics","description":"Generate the datetime scalar representing the current date","description_html":"\u003cp\u003eGenerate the datetime scalar representing the current date\u003c/p\u003e","function_template":"function y = generate_datetime()\r\n  \r\nend","test_suite":"%%\r\ny_correct = datetime('today');\r\nassert(isequal(generate_datetime(),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":135,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T14:59:26.000Z","updated_at":"2026-03-02T09:12:44.000Z","published_at":"2018-05-29T14:59:26.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\u003eGenerate the datetime scalar representing the current date\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":44662,"title":"Check if there are white spaces in the input string","description":"If there are white spaces in the input string, output=1 else 0","description_html":"\u003cp\u003eIf there are white spaces in the input string, output=1 else 0\u003c/p\u003e","function_template":"function y = white_space_tf(x)\r\n  \r\nend","test_suite":"%%\r\nx = '123 test';\r\ny_correct = 1;\r\nassert(isequal(white_space_tf(x),y_correct))\r\n\r\n%%\r\nx = '123';\r\ny_correct = 0;\r\nassert(isequal(white_space_tf(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T14:24:57.000Z","updated_at":"2026-03-05T10:45:19.000Z","published_at":"2018-05-29T14:24:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf there are white spaces in the input string, output=1 else 0\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":44696,"title":"Sum of unique multiples of 3 and 5","description":"If we list all the natural numbers up to 15 that are multiples of 3 or 5, we get 3, 5, 6, 9, 10, 12 and 15. The sum of these multiples is 60. \r\n\r\nWrite a function called _*sum3and5muls*_ that returns the sum of all the unique multiples of 3 or 5 up to n where n is a positive integer and the only input argument of the function.","description_html":"\u003cp\u003eIf we list all the natural numbers up to 15 that are multiples of 3 or 5, we get 3, 5, 6, 9, 10, 12 and 15. The sum of these multiples is 60.\u003c/p\u003e\u003cp\u003eWrite a function called \u003ci\u003e\u003cb\u003esum3and5muls\u003c/b\u003e\u003c/i\u003e that returns the sum of all the unique multiples of 3 or 5 up to n where n is a positive integer and the only input argument of the function.\u003c/p\u003e","function_template":"function sum_mult = sum3and5muls(n)\r\n    sum_mult\r\nend","test_suite":"%%\r\nn = 15;\r\nsm_correct = 60;\r\nassert(isequal(sum3and5muls(n),sm_correct))\r\n\r\n%%\r\nn = 18;\r\nsm_correct = 78;\r\nassert(isequal(sum3and5muls(n),sm_correct))\r\n\r\n%%\r\nn = (2^2)-1;\r\nsm_correct = 3;\r\nassert(isequal(sum3and5muls(n),sm_correct))\r\n\r\n%%\r\nn = randi(25);\r\nsm_correct = sum(3:3:n)+sum(5:5:n)-sum(15:15:n);\r\nassert(isequal(sum3and5muls(n),sm_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2018-07-10T11:40:12.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-07-10T11:35:26.000Z","updated_at":"2026-03-02T14:30:43.000Z","published_at":"2018-07-10T11:40:12.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\u003eIf we list all the natural numbers up to 15 that are multiples of 3 or 5, we get 3, 5, 6, 9, 10, 12 and 15. The sum of these multiples is 60.\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\u003eWrite a function called\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esum3and5muls\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that returns the sum of all the unique multiples of 3 or 5 up to n where n is a positive integer and the only input argument of the function.\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":44671,"title":"find number of times of occurrence of the most frequent number in a row vector","description":"In a given row vector, find the number of times a mode of a row vector has occurred\r\n\r\nexample: in [2 5 5 5 5 3], output is 4\r\n\r\n","description_html":"\u003cp\u003eIn a given row vector, find the number of times a mode of a row vector has occurred\u003c/p\u003e\u003cp\u003eexample: in [2 5 5 5 5 3], output is 4\u003c/p\u003e","function_template":"function y = num_mode(x)\r\n\r\nend","test_suite":"%%\r\nx =[2 3 3 3 5 3 3 5 5 5 5 5 5];\r\ny_correct = 7;\r\nassert(isequal(num_mode(x),y_correct))\r\n\r\n%%\r\nx =[8 8];\r\ny_correct = 2;\r\nassert(isequal(num_mode(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-31T15:30:12.000Z","updated_at":"2026-02-18T10:08:10.000Z","published_at":"2018-05-31T15:30:12.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\u003eIn a given row vector, find the number of times a mode of a row vector has occurred\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: in [2 5 5 5 5 3], output is 4\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":44659,"title":"Nth root of a number","description":"Given an input and a number N, find the Nth root of the number(s)","description_html":"\u003cp\u003eGiven an input and a number N, find the Nth root of the number(s)\u003c/p\u003e","function_template":"function y = rootN(a,N)\r\n  y = x;\r\nend","test_suite":"%%\r\na = 1;\r\nN = 100\r\ny_correct = 1;\r\nassert(isequal(rootN(a,N),y_correct))\r\n\r\n%%\r\na = [1 64 216];\r\nN = 3\r\ny_correct = [1    4    6];\r\nassert(isequal(rootN(a,N),y_correct))\r\n\r\n%%\r\na = 1/100;\r\nN = 2\r\ny_correct = 1/10;\r\nassert(isequal(rootN(a,N),y_correct))\r\n\r\n%%\r\na = 826^10;\r\nN = 10\r\ny_correct = 826;\r\nassert(isequal(rootN(a,N),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":59,"test_suite_updated_at":"2018-05-29T13:54:08.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T13:48:03.000Z","updated_at":"2026-02-20T14:32:58.000Z","published_at":"2018-05-29T13:48:03.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input and a number N, find the Nth root of the number(s)\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":44624,"title":"Return median of a matrix","description":"Compute median of a matrix of any dimension. Exclude the NaNs if any.","description_html":"\u003cp\u003eCompute median of a matrix of any dimension. Exclude the NaNs if any.\u003c/p\u003e","function_template":"function y = matrix_median(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [2,3,4;4,5,6];\r\ny_correct = 4;\r\nassert(isequal(matrix_median(x),y_correct))\r\n\r\n%%\r\nx = int8(1:4);\r\ny_correct = 3;\r\nassert(isequal(matrix_median(x),y_correct))\r\n\r\n%%\r\nx = [2 6 8 10 NaN 14 NaN 18 NaN];\r\ny_correct = 9;\r\nassert(isequal(matrix_median(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":73,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-21T04:30:24.000Z","updated_at":"2026-02-18T11:12:59.000Z","published_at":"2018-04-21T04:30:24.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\u003eCompute median of a matrix of any dimension. Exclude the NaNs if any.\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":44697,"title":"count upper and lower case characters","description":"In a given input string, count and return the number of upper and lower case characters as u and l respectively.\r\n\r\nFor example:\r\n\r\n_in 'This is a Test Case'_\r\n\r\n_ans= [u,l]= [3,12]_","description_html":"\u003cp\u003eIn a given input string, count and return the number of upper and lower case characters as u and l respectively.\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cp\u003e\u003ci\u003ein 'This is a Test Case'\u003c/i\u003e\u003c/p\u003e\u003cp\u003e\u003ci\u003eans= [u,l]= [3,12]\u003c/i\u003e\u003c/p\u003e","function_template":"function y = counter_ul(str)\r\n  \r\nend","test_suite":"%%\r\nstr = 'This is a Test Case';\r\nans_corr = [3 12];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'RandoM';\r\nans_corr = [2 4];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'Hello World';\r\nans_corr = [2 8];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'HELLO WORLD';\r\nans_corr = [10 0];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'hello world';\r\nans_corr = [0 10];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\r\nans_corr = [26 0];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'abcdefghijklmnopqrstuvwxyz';\r\nans_corr = [0 26];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = '42';\r\nans_corr = [0 0];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'Matlab';\r\nans_corr = [1 5];\r\nassert(isequal(counter_ul(str),ans_corr))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":"2018-07-17T18:33:09.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-07-10T11:53:29.000Z","updated_at":"2026-03-11T08:29:11.000Z","published_at":"2018-07-10T11:53: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\u003eIn a given input string, count and return the number of upper and lower case characters as u and l respectively.\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ein 'This is a Test Case'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eans= [u,l]= [3,12]\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":1458,"title":"Is it a number?","description":"Determine if input is numeric. If it is,output is 1; if it is not, output is 0.","description_html":"\u003cp\u003eDetermine if input is numeric. If it is,output is 1; if it is not, output is 0.\u003c/p\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 'a';\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = isreal(i);\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":1321,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":531,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-04-25T18:56:35.000Z","updated_at":"2026-02-18T14:34:21.000Z","published_at":"2013-04-25T18:56: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\",\"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\u003eDetermine if input is numeric. If it is,output is 1; if it is not, output is 0.\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":3,"title":"Find the sum of all the numbers of the input vector","description":"Find the sum of all the numbers of the input vector x. \r\n\r\n Examples:\r\n\r\n  Input  x = [1 2 3 5]\r\n  Output y is 11\r\n\r\n  Input  x = [42 -1]\r\n  Output y is 41\r\n ","description_html":"\u003cp\u003eFind the sum of all the numbers of the input vector x.\u003c/p\u003e\u003cpre\u003e Examples:\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eInput  x = [1 2 3 5]\r\nOutput y is 11\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eInput  x = [42 -1]\r\nOutput y is 41\r\n\u003c/pre\u003e","function_template":"function y = vecsum(x)\r\n   y = x\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(vecsum(x),y_correct))\r\n\r\n%%\r\nx = [1 2 3 5];\r\ny_correct = 11;\r\nassert(isequal(vecsum(x),y_correct))\r\n\r\n%%\r\nx = [1 2 3 5];\r\ny_correct = 11;\r\nassert(isequal(vecsum(x),y_correct))\r\n\r\n%%\r\nx = 1:100;\r\ny_correct = 5050;\r\nassert(isequal(vecsum(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":343,"comments_count":85,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54193,"test_suite_updated_at":"2013-07-17T17:49:37.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:17.000Z","updated_at":"2026-04-05T08:18:19.000Z","published_at":"2012-01-18T01:00:17.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\u003eFind the sum of all the numbers of the input vector x.\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[ Examples:\\n\\nInput  x = [1 2 3 5]\\nOutput y is 11\\n\\nInput  x = [42 -1]\\nOutput y is 41]]\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":1838,"title":"Min of a Matrix","description":"Return the minimum value in the given matrix.","description_html":"\u003cp\u003eReturn the minimum value in the given matrix.\u003c/p\u003e","function_template":"function y = matrixMin(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 2 3; 4 5 6; 7 8 9;];\r\ny_correct = 1;\r\nassert(isequal(matrixMin(x),y_correct))\r\n\r\n%%\r\nx = [42 35 18 9; 28 92 11 444; 8 12 9 111];\r\ny_correct = 8;\r\nassert(isequal(matrixMin(x),y_correct));\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":16420,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":759,"test_suite_updated_at":"2013-08-19T18:54:37.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-08-19T18:50:01.000Z","updated_at":"2026-02-24T00:54:24.000Z","published_at":"2013-08-19T18:50:00.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\u003eReturn the minimum value in the given matrix.\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":44623,"title":"Basic matlab numeric and string manipulations","description":"If entered input (n) is _numeric_ , compute its *log to the base (n+2)* , \r\n\r\nif it is a _lower case_ alphabet, *convert it to its numeric ascii value* , \r\n\r\nif it is an upper case character, create a string with '!' *concatenated* to the value 'n'\r\nExample: 'A' will become 'A!'\r\n\r\nelse return the input as is","description_html":"\u003cp\u003eIf entered input (n) is \u003ci\u003enumeric\u003c/i\u003e , compute its \u003cb\u003elog to the base (n+2)\u003c/b\u003e ,\u003c/p\u003e\u003cp\u003eif it is a \u003ci\u003elower case\u003c/i\u003e alphabet, \u003cb\u003econvert it to its numeric ascii value\u003c/b\u003e ,\u003c/p\u003e\u003cp\u003eif it is an upper case character, create a string with '!' \u003cb\u003econcatenated\u003c/b\u003e to the value 'n'\r\nExample: 'A' will become 'A!'\u003c/p\u003e\u003cp\u003eelse return the input as is\u003c/p\u003e","function_template":"function y = manipulate(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'p';\r\ny_correct = 112;\r\nassert(isequal(manipulate(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = log(x)/log(7);\r\nassert(isequal(manipulate(x),y_correct))\r\n\r\n%%\r\nx = 'A';\r\ny_correct = 'A!';\r\nassert(isequal(manipulate(x),y_correct))\r\n\r\n%%\r\nx = '!';\r\ny_correct = '!';\r\nassert(isequal(manipulate(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":41,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-21T04:14:55.000Z","updated_at":"2026-03-04T14:29:39.000Z","published_at":"2018-04-21T04:14:55.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eIf entered input (n) is\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\u003enumeric\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , compute its\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\u003elog to the base (n+2)\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\u003eif it is 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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elower case\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e alphabet,\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\u003econvert it to its numeric ascii value\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\u003eif it is an upper case character, create a string with '!'\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\u003econcatenated\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to the value 'n' Example: 'A' will become '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\u003eelse return the input as is\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":44707,"title":"Raise each element to the power of its index in a matrix","description":"In a matrix, A = [1,2;3,4]\r\nraise the power of each element like: 1^1+2^3+3^2+4^4 and add it all to produce the result 274\r\n\r\n","description_html":"\u003cp\u003eIn a matrix, A = [1,2;3,4]\r\nraise the power of each element like: 1^1+2^3+3^2+4^4 and add it all to produce the result 274\u003c/p\u003e","function_template":"function y = matrix_pow(x)\r\n\r\nend","test_suite":"%%\r\nx = [1,2;3,4];\r\ny_correct = 274;\r\nassert(isequal(matrix_pow(x),y_correct))\r\n\r\n%%\r\nx = [1 7 8 -9];\r\ny_correct = 7123;\r\nassert(isequal(matrix_pow(x),y_correct))\r\n\r\n%%\r\nx = eye(3).*8;\r\ny_correct = 134250504;\r\nassert(isequal(matrix_pow(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-03T09:00:18.000Z","updated_at":"2026-02-18T14:10:57.000Z","published_at":"2018-08-03T09:18:08.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\u003eIn a matrix, A = [1,2;3,4] raise the power of each element like: 1^1+2^3+3^2+4^4 and add it all to produce the result 274\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":44635,"title":"Repetition of matrices","description":"*A is a bold matrix: [1 2 3; 4 5 6;7 8 9]*\r\n\r\nGiven an integer 'n' , a matrix B exists such that has n copies of A in the row and column dimensions\r\n\r\nexample:\r\nfor n=2; B= [A A; A A]\r\n\r\nFor such a matrix B return the sum of all elements multiplied by the size of B i.e. \r\n\r\n  C=sum (all elements of B) * size(B)\r\n\r\n* _Kindly note you will have to make the matrix A yourself_ *","description_html":"\u003cp\u003e\u003cb\u003eA is a bold matrix: [1 2 3; 4 5 6;7 8 9]\u003c/b\u003e\u003c/p\u003e\u003cp\u003eGiven an integer 'n' , a matrix B exists such that has n copies of A in the row and column dimensions\u003c/p\u003e\u003cp\u003eexample:\r\nfor n=2; B= [A A; A A]\u003c/p\u003e\u003cp\u003eFor such a matrix B return the sum of all elements multiplied by the size of B i.e.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eC=sum (all elements of B) * size(B)\r\n\u003c/pre\u003e\u003cul\u003e\u003cli\u003e\u003ci\u003eKindly note you will have to make the matrix A yourself\u003c/i\u003e *\u003c/li\u003e\u003c/ul\u003e","function_template":"function C = matrix_rep(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nn = 2;\r\nC_correct = [1080,1080];\r\nassert(isequal(matrix_rep(n),C_correct))\r\n\r\n%%\r\nn = 5;\r\nC_correct = [16875,16875];\r\nassert(isequal(matrix_rep(n),C_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":58,"test_suite_updated_at":"2018-05-09T11:43:47.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-09T11:42:39.000Z","updated_at":"2026-03-05T11:04:40.000Z","published_at":"2018-05-09T11:42:39.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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eA is a bold matrix: [1 2 3; 4 5 6;7 8 9]\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 an integer 'n' , a matrix B exists such that has n copies of A in the row and column dimensions\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: for n=2; B= [A A; A 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\u003eFor such a matrix B return the sum of all elements multiplied by the size of B i.e.\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=sum (all elements of B) * size(B)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eKindly note you will have to make the matrix A yourself\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\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":44665,"title":"Percentage of zeros in a matrix of only 1s and 0s","description":"Write a function called _zero_stat_ that takes a matrix as an input that only has 0 and 1 elements. The function needs to compute and return the percentage of 0 elements in the matrix. For example, if there are 10 zeros and 15 ones in a 5-by-5 matrix that is provided as an input to zero_stat, it would return 40 because 40% of the elements are zero.\r\n*Please return the answer rounded to the nearest integer*","description_html":"\u003cp\u003eWrite a function called \u003ci\u003ezero_stat\u003c/i\u003e that takes a matrix as an input that only has 0 and 1 elements. The function needs to compute and return the percentage of 0 elements in the matrix. For example, if there are 10 zeros and 15 ones in a 5-by-5 matrix that is provided as an input to zero_stat, it would return 40 because 40% of the elements are zero. \u003cb\u003ePlease return the answer rounded to the nearest integer\u003c/b\u003e\u003c/p\u003e","function_template":"function pct_zero = zero_stat(inp_matrix)\r\nend","test_suite":"%%\r\ninp_matrix = [1,0,0,1,1;0,1,1,0,0;0,0,0,0,0;1,1,1,1,1;1,1,1,1,1];\r\npct_zero_corr = 40;\r\nassert(isequal(zero_stat(inp_matrix),pct_zero_corr))\r\n\r\n%%\r\ninp_matrix = diag([1,0,1,1,1]);\r\npct_zero_corr = 84;\r\nassert(isequal(zero_stat(inp_matrix),pct_zero_corr))\r\n\r\n%%\r\ninp_matrix = [1,0,1,0,0,0,1]';\r\npct_zero_corr = 57;\r\nassert(isequal(zero_stat(inp_matrix),pct_zero_corr))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T15:29:49.000Z","updated_at":"2026-04-02T10:26:58.000Z","published_at":"2018-05-29T15:29: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\",\"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 called\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\u003ezero_stat\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that takes a matrix as an input that only has 0 and 1 elements. The function needs to compute and return the percentage of 0 elements in the matrix. For example, if there are 10 zeros and 15 ones in a 5-by-5 matrix that is provided as an input to zero_stat, it would return 40 because 40% of the elements are zero.\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\u003ePlease return the answer rounded to the nearest integer\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":44660,"title":"Perimeter of a semicircle","description":"Given the diameter d, find the perimeter of a semicircle","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: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; 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 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 172.5px 8px; transform-origin: 172.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven the diameter d, find the perimeter of a semicircle\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = perm_semicircle(d)\r\n  d\r\nend","test_suite":"%%\r\nd = 20;\r\ny_correct = 51.4159265358979;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)\r\n\r\n%%\r\nd = 42;\r\ny_correct = 107.973445725386;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)\r\n\r\n%%\r\nd = 50;\r\ny_correct = 128.539816339745;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)\r\n\r\n%%\r\nd = 100;\r\ny_correct = 257.07963267949;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)\r\n\r\n%%\r\nd = 135;\r\ny_correct = 347.057504117311;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)","published":true,"deleted":false,"likes_count":10,"comments_count":3,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2178,"test_suite_updated_at":"2021-08-03T16:46:04.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T14:09:07.000Z","updated_at":"2026-04-04T17:46:02.000Z","published_at":"2018-05-29T14:09:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven the diameter d, find the perimeter of a semicircle\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":44618,"title":"surface areas of a cylinder","description":"There are 3 inputs: option, radius and height. If option= '1', compute the lateral surface area of the cylinder, for option 2 calculate the total surface area of the cylinder. For any other option, compute the total area of both flat sides of the cylinder.","description_html":"\u003cp\u003eThere are 3 inputs: option, radius and height. If option= '1', compute the lateral surface area of the cylinder, for option 2 calculate the total surface area of the cylinder. For any other option, compute the total area of both flat sides of the cylinder.\u003c/p\u003e","function_template":"function y = surface_area_cyl(optn,r,h)\r\n  y = r*h;\r\nend","test_suite":"%%\r\noptn=1;\r\nr=3;\r\nh=6;\r\ny_correct = 36*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=5;\r\nr=3;\r\nh=6;\r\ny_correct = 18*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=2;\r\nr=2;\r\nh=2;\r\ny_correct = 16*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=0;\r\nr=5;\r\nh=10;\r\ny_correct = 50*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=1;\r\nr=5;\r\nh=10;\r\ny_correct = 100*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=2;\r\nr=5;\r\nh=10;\r\ny_correct = 150*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=42;\r\nr=3;\r\nh=7;\r\ny_correct = 18*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=2;\r\nr=3\r\nh=7;\r\ny_correct = 60*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=1;\r\nr=3;\r\nh=7;\r\ny_correct = 42*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":"2018-07-16T16:54:54.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-20T05:49:29.000Z","updated_at":"2026-04-03T06:59:13.000Z","published_at":"2018-04-20T05:49: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\",\"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\u003eThere are 3 inputs: option, radius and height. If option= '1', compute the lateral surface area of the cylinder, for option 2 calculate the total surface area of the cylinder. For any other option, compute the total area of both flat sides of the cylinder.\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":2114,"title":"Factorial Numbers ","description":"Factorial is multiplication of integers. So factorial of 6 is\r\n 720 = 1 * 2 * 3 * 4* 5 *6\r\n\r\nThus 6 factorial  = factorial(720). Given n, return t, the factorial number for n.\r\n\r\nExample: Input n = 6 Output t is 720\r\n","description_html":"\u003cp\u003eFactorial is multiplication of integers. So factorial of 6 is\r\n 720 = 1 * 2 * 3 * 4* 5 *6\u003c/p\u003e\u003cp\u003eThus 6 factorial  = factorial(720). Given n, return t, the factorial number for n.\u003c/p\u003e\u003cp\u003eExample: Input n = 6 Output t is 720\u003c/p\u003e","function_template":"function t = factorial(n)\r\n  t = n;\r\nend\r\n","test_suite":"%%\r\nn = 1;\r\nt = 1;\r\nassert(isequal(factorial(n),t))\r\n%%\r\nn = 2;\r\nt = 2;\r\nassert(isequal(factorial(n),t))\r\n%%\r\nn = 3;\r\nt = 6;\r\nassert(isequal(factorial (n),t))\r\n%%\r\nn = 6;\r\nt = 720;","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":21325,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":447,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-01-13T16:39:00.000Z","updated_at":"2026-04-02T10:43:25.000Z","published_at":"2014-01-13T16:39:33.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\u003eFactorial is multiplication of integers. So factorial of 6 is 720 = 1 * 2 * 3 * 4* 5 *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\u003eThus 6 factorial = factorial(720). Given n, return t, the factorial number for n.\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: Input n = 6 Output t is 720\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":44661,"title":"Remove white spaces at the end of the input string","description":"Remove all trailing white spaces at the end of the input strings","description_html":"\u003cp\u003eRemove all trailing white spaces at the end of the input strings\u003c/p\u003e","function_template":"function y = rem_trail_ws(A)\r\n  A\r\nend","test_suite":"%%\r\nA = 'This is a test string.             ';\r\ny_correct = 'This is a test string.';\r\nassert(isequal(rem_trail_ws(A),y_correct))\r\n\r\n%%\r\nA = '          Testing function rem_trail_ws';\r\ny_correct = '          Testing function rem_trail_ws';\r\nassert(isequal(rem_trail_ws(A),y_correct))\r\n\r\n%%\r\nA = {'MATLAB    ','SIMULINK    ';\r\n     'Toolboxes    ','MathWorks    '};\r\ny_correct = {'MATLAB','SIMULINK';\r\n     'Toolboxes','MathWorks'};\r\nassert(isequal(rem_trail_ws(A),y_correct))\r\n\r\n%%\r\nA = sprintf('MATHWORKS \\t');\r\ny_correct = 'MATHWORKS';\r\nassert(isequal(rem_trail_ws(A),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T14:21:22.000Z","updated_at":"2025-12-07T18:25:49.000Z","published_at":"2018-05-29T14:21:22.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\u003eRemove all trailing white spaces at the end of the input strings\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":42801,"title":"means","description":"Calculate the arithmetic, the geometric and the harmonic mean of a given vector (with positive elements) and return them in a vector!","description_html":"\u003cp\u003eCalculate the arithmetic, the geometric and the harmonic mean of a given vector (with positive elements) and return them in a vector!\u003c/p\u003e","function_template":"function y = means(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1];\r\ny_correct = [1,1,1];\r\nassert(isequal(means(x),y_correct))\r\n\r\n%%\r\nx = [1,4];\r\ny_correct = [2.5,2,8/5];\r\nassert(isequal(means(x),y_correct))\r\n\r\n%%\r\nx = 1:10;\r\ny = means(x);\r\ny_correct = [5.5,nthroot(3628800,10),25200/7381];\r\nfor i = 1:3\r\n assert(abs(y(i)-y_correct(i))\u003c1e-4)\r\nend\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":73322,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":64,"test_suite_updated_at":"2018-07-24T20:23:10.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-04-15T14:30:45.000Z","updated_at":"2025-12-07T20:59:17.000Z","published_at":"2016-04-15T14:30:45.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\u003eCalculate the arithmetic, the geometric and the harmonic mean of a given vector (with positive elements) and return them in a vector!\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":42818,"title":"center of mass","description":"R is a given matrix with size [n,2]. R(i,:) is interpreted as the 2D-position of a mass point with mass i. Calculate the center of mass of all mass points proposed by R. ","description_html":"\u003cp\u003eR is a given matrix with size [n,2]. R(i,:) is interpreted as the 2D-position of a mass point with mass i. Calculate the center of mass of all mass points proposed by R.\u003c/p\u003e","function_template":"function [X,Y] = center_of_mass(R)\r\nX=0;\r\nY=0;\r\nend\r\n","test_suite":"%%\r\nR=[0,0];\r\nX_correct = 0;\r\nY_correct = 0;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);\r\n\r\n%%\r\nR=[0,0;1,1];\r\nX_correct = 2/3;\r\nY_correct = 2/3;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);\r\n\r\n%%\r\nR=[0,0;0,4];\r\nX_correct = 0;\r\nY_correct = 8/3;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);\r\n\r\n%%\r\nR=[1:10;1:10]';\r\nX_correct = 7;\r\nY_correct = 7;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);\r\n\r\n%%\r\nR=[10:(-1):1;0:9]'\r\nX_correct = 4;\r\nY_correct = 6;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);","published":true,"deleted":false,"likes_count":3,"comments_count":4,"created_by":73322,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":"2016-06-20T13:23:20.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-04-24T07:51:53.000Z","updated_at":"2026-02-13T20:02:09.000Z","published_at":"2016-04-24T07:51: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\",\"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\u003eR is a given matrix with size [n,2]. R(i,:) is interpreted as the 2D-position of a mass point with mass i. Calculate the center of mass of all mass points proposed by R.\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":44730,"title":"Substring Extraction","description":"In a given string, find the substring between Start_string and End_string. \r\n\r\nYou will have to include or exclude the Start_string and End_string as a part of the substring depending on the third argument 'include_se'\r\n\r\nIf include_se=1, include the Start_string and End_string as a part of the extracted substring, else exclude them\r\n\r\nExample: \r\n\r\n  input_str: 'This is a test sentence'\r\n  Start_string: 'is'\r\n  End_string: 'sentence'\r\n  include_se=1\r\n  extract_function(input_str,Start_string,End_string, include_se)= 'is a test sentence'\r\n","description_html":"\u003cp\u003eIn a given string, find the substring between Start_string and End_string.\u003c/p\u003e\u003cp\u003eYou will have to include or exclude the Start_string and End_string as a part of the substring depending on the third argument 'include_se'\u003c/p\u003e\u003cp\u003eIf include_se=1, include the Start_string and End_string as a part of the extracted substring, else exclude them\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003einput_str: 'This is a test sentence'\r\nStart_string: 'is'\r\nEnd_string: 'sentence'\r\ninclude_se=1\r\nextract_function(input_str,Start_string,End_string, include_se)= 'is a test sentence'\r\n\u003c/pre\u003e","function_template":"function output_str = extract_function(input_str,Start_string,End_string, include_se)\r\n\r\nend","test_suite":"%%\r\ninput_str= 'This is a test sentence'\r\nStart_string= ' is'\r\nEnd_string= 'sentence'\r\ninclude_se=1\r\noutput_str= {' is a test sentence'}\r\nassert(isequal(extract_function(input_str,Start_string,End_string, include_se),output_str))\r\n\r\n%%\r\ninput_str= 'This is a test sentence'\r\nStart_string= ' is'\r\nEnd_string= 'sentence'\r\ninclude_se=0\r\noutput_str={' a test '}\r\nassert(isequal(extract_function(input_str,Start_string,End_string, include_se),output_str))\r\n\r\n%%\r\ninput_str= 'Right now!I said RIGHT NOW!'\r\nStart_string= 'now!'\r\nEnd_string= '!'\r\ninclude_se=0\r\noutput_str={'I said RIGHT NOW'}\r\nassert(isequal(extract_function(input_str,Start_string,End_string, include_se),output_str))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":"2018-08-16T12:54:54.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-16T12:52:30.000Z","updated_at":"2025-12-29T13:54:03.000Z","published_at":"2018-08-16T12:52:30.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\u003eIn a given string, find the substring between Start_string and End_string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will have to include or exclude the Start_string and End_string as a part of the substring depending on the third argument 'include_se'\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 include_se=1, include the Start_string and End_string as a part of the extracted substring, else exclude them\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_str: 'This is a test sentence'\\nStart_string: 'is'\\nEnd_string: 'sentence'\\ninclude_se=1\\nextract_function(input_str,Start_string,End_string, include_se)= 'is a test sentence']]\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":42646,"title":"Matrix FUN","description":"Given a Matrix M, find out the number of elements of matrix that are divisible by 3.\r\n\r\n  \r\n    M = [1 2 3;4 5 6;7 8 9];\r\n    out = 3\r\n\r\n    M = [32 12 15; 2 6 45];\r\n    out = 4\r\n ","description_html":"\u003cp\u003eGiven a Matrix M, find out the number of elements of matrix that are divisible by 3.\u003c/p\u003e\u003cpre\u003e    M = [1 2 3;4 5 6;7 8 9];\r\n    out = 3\u003c/pre\u003e\u003cpre\u003e    M = [32 12 15; 2 6 45];\r\n    out = 4\u003c/pre\u003e","function_template":"function y = mat_fun(m)\r\n  y = x; %think and solve\r\nend","test_suite":"%%\r\nx = 4;\r\ny_correct = 0;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = [3 2 3 2 5 6 2 1 2];\r\ny_correct = 3;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = [999 999 999 2 15 6];\r\ny_correct = 5;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = 3:3:999;\r\ny_correct = 333;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5 6;6 5 4 3 2 1];\r\ny_correct = 4;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = [7 8 11 13 14 17];\r\ny_correct = 0;\r\nassert(isequal(mat_fun(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":44015,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":165,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-10-03T05:59:11.000Z","updated_at":"2026-03-23T15:33:33.000Z","published_at":"2015-10-03T06:00:26.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 Matrix M, find out the number of elements of matrix that are divisible by 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[    M = [1 2 3;4 5 6;7 8 9];\\n    out = 3\\n\\n    M = [32 12 15; 2 6 45];\\n    out = 4]]\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":233,"title":"Reverse the vector","description":"Reverse the vector elements.\r\n\r\nExample:\r\n\r\n Input  x = [1,2,3,4,5,6,7,8,9] \r\n Output y = [9,8,7,6,5,4,3,2,1]","description_html":"\u003cp\u003eReverse the vector elements.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e Input  x = [1,2,3,4,5,6,7,8,9] \r\n Output y = [9,8,7,6,5,4,3,2,1]\u003c/pre\u003e","function_template":"function y = reverseVector(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(reverseVector(x),y_correct))\r\n\r\n%%\r\nx = -10:1;\r\ny_correct = 1:-1:-10;\r\nassert(isequal(reverseVector(x),y_correct))\r\n\r\n%%\r\nx = 'able was i ere i saw elba';\r\ny_correct = 'able was i ere i saw elba';\r\nassert(isequal(reverseVector(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":55,"comments_count":9,"created_by":868,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":16481,"test_suite_updated_at":"2016-10-23T02:09:16.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-02T15:28:45.000Z","updated_at":"2026-04-04T14:45:17.000Z","published_at":"2012-02-02T20:11:32.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\u003eReverse the vector elements.\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  x = [1,2,3,4,5,6,7,8,9] \\n Output y = [9,8,7,6,5,4,3,2,1]]]\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":44408,"title":"ゼロでない要素が一番多い行を探そう","description":"行列 a が与えられたとき、行列 a の中で一番ゼロの要素が少ない行のインデクス r を返す関数を作成しましょう。このとき、行列 a には一つだけしかこの条件に当てはまる行がないと仮定します。\r\n\r\n例:\r\n\r\n 入力として、行列  \r\n a = [ 1 2 0 0 0\r\n       0 0 5 0 0 \r\n       2 7 0 0 0\r\n       0 6 9 3 3 ]\r\n が与えられたとき、出力 r は 4 を返します。\r\n\r\n* (英語版) Problem 32. Most nonzero elements in row\r\n\u003chttps://www.mathworks.com/matlabcentral/cody/problems/32\u003e","description_html":"\u003cp\u003e行列 a が与えられたとき、行列 a の中で一番ゼロの要素が少ない行のインデクス r を返す関数を作成しましょう。このとき、行列 a には一つだけしかこの条件に当てはまる行がないと仮定します。\u003c/p\u003e\u003cp\u003e例:\u003c/p\u003e\u003cpre\u003e 入力として、行列  \r\n a = [ 1 2 0 0 0\r\n       0 0 5 0 0 \r\n       2 7 0 0 0\r\n       0 6 9 3 3 ]\r\n が与えられたとき、出力 r は 4 を返します。\u003c/pre\u003e\u003cul\u003e\u003cli\u003e(英語版) Problem 32. Most nonzero elements in row \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/32\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/32\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e","function_template":"function r = fullest_row(a)\r\n  r = 1\r\nend","test_suite":"%%\r\na = [ ...\r\n 1 2 0 0 0\r\n 0 0 5 0 0 \r\n 2 7 0 0 0\r\n 0 6 9 3 3];\r\nr_correct = 4;\r\nassert(isequal(fullest_row(a),r_correct))\r\n\r\n%%\r\na = [ ...\r\n1 2 0 0 \r\n 0 0 5 0  \r\n 0 6 9 -3\r\n 2 7 0 0 \r\n 0 0 0 0];\r\nr_correct = 3;\r\nassert(isequal(fullest_row(a),r_correct))\r\n%%\r\na = [ ...\r\n 1 0 0 \r\n 0 0 0  \r\n 0 0 0\r\n 0 0 0 \r\n 0 2 3];\r\nr_correct = 5;\r\nassert(isequal(fullest_row(a),r_correct))\r\n%%\r\na = [ ...\r\n 0 \r\n 0  \r\n 0\r\n -3\r\n 0 \r\n 0];\r\nr_correct = 4;\r\nassert(isequal(fullest_row(a),r_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":0,"created_by":11824,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":345,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":36,"created_at":"2017-11-14T23:35:31.000Z","updated_at":"2026-03-18T03:46:35.000Z","published_at":"2017-11-14T23:35:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e行列 a が与えられたとき、行列 a の中で一番ゼロの要素が少ない行のインデクス r を返す関数を作成しましょう。このとき、行列 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\u003e例:\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[ 入力として、行列  \\n a = [ 1 2 0 0 0\\n       0 0 5 0 0 \\n       2 7 0 0 0\\n       0 6 9 3 3 ]\\n が与えられたとき、出力 r は 4 を返します。]]\u003e\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(英語版) Problem 32. Most nonzero elements in row\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/32\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/32\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\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":262,"title":"Swap the input arguments","description":"Write a two-input, two-output function that swaps its two input arguments. For example:\r\n\r\n   [q,r] = swap(5,10)\r\n\r\nreturns q = 10 and r = 5.","description_html":"\u003cp\u003eWrite a two-input, two-output function that swaps its two input arguments. For example:\u003c/p\u003e\u003cpre\u003e   [q,r] = swap(5,10)\u003c/pre\u003e\u003cp\u003ereturns q = 10 and r = 5.\u003c/p\u003e","function_template":"function [q,r] = swapInputs(a,b)\r\n  [q,r] = cart2pol(a,b);\r\nend","test_suite":"%%\r\n[q,r] = swapInputs(5,10);\r\nassert(isequal(q,10));\r\nassert(isequal(r,5));\r\n\r\n%%\r\n[q,r] = swapInputs(magic(3), 'hello, world');\r\nassert(isequal(q,'hello, world'));\r\nassert(isequal(r,magic(3)));\r\n\r\n%%\r\n[q,r] = swapInputs({}, NaN);\r\nassert(isnan(q));\r\nassert(iscell(r) \u0026\u0026 isempty(r));\r\n","published":true,"deleted":false,"likes_count":76,"comments_count":11,"created_by":4303371,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13325,"test_suite_updated_at":"2012-02-05T05:04:01.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-05T05:04:01.000Z","updated_at":"2026-04-04T14:50:54.000Z","published_at":"2012-02-05T05:04:30.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 two-input, two-output function that swaps its two input arguments. 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[   [q,r] = swap(5,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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ereturns q = 10 and r = 5.\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":589,"title":"Matrix indexing with two vectors of indices","description":"Given a matrix M and two index vectors a and b, return a row vector x where x(i) = M(a(i),b(i)).","description_html":"\u003cp\u003eGiven a matrix M and two index vectors a and b, return a row vector x where x(i) = M(a(i),b(i)).\u003c/p\u003e","function_template":"function v = twoIndex(M,a,b)\r\n  v = M;\r\nend","test_suite":"%%\r\nM = rand(4);\r\na = [4 3 2 1];\r\nb = [1 2 3 4];\r\nv_correct = M([4 7 10 13]);\r\nassert(isequal(twoIndex(M,a,b),v_correct))\r\n\r\n%%\r\nM = rand(4);\r\na = [3 3 1 3];\r\nb = [1 1 3 1];\r\nv_correct = M([3 3 9 3]);\r\nassert(isequal(twoIndex(M,a,b),v_correct))\r\n\r\n%%\r\nM = rand(100);\r\n[a,b] = size(M);\r\nv_correct = M(end);\r\nassert(isequal(twoIndex(M,a,b),v_correct))\r\n\r\n%%\r\nM = rand(100);\r\na = [];\r\nb = [];\r\nassert(isempty(twoIndex(M,a,b)))\r\n\r\n%%\r\nM = 1;\r\na = [1 1 1 1 1];\r\nb = [1 1 1 1 1];\r\nv_correct = [1 1 1 1 1];\r\nassert(isequal(twoIndex(M,a,b),v_correct))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":3117,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":776,"test_suite_updated_at":"2012-04-16T17:43:15.000Z","rescore_all_solutions":false,"group_id":12,"created_at":"2012-04-16T17:43:15.000Z","updated_at":"2026-04-03T18:25:24.000Z","published_at":"2012-04-16T17:43:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 matrix M and two index vectors a and b, return a row vector x where x(i) = M(a(i),b(i)).\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":1702,"title":"Maximum value in a matrix","description":"Find the maximum value in the given matrix.\r\n\r\nFor example, if \r\n\r\n A = [1 2 3; 4 7 8; 0 9 1];\r\n\r\nthen the answer is 9.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; 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: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; transform-origin: 332px 56px; vertical-align: baseline; perspective-origin: 332px 56px; \"\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; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFind the maximum value in the given matrix.\u003c/span\u003e\u003c/span\u003e\u003c/div\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; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example, if\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 329px 10px; perspective-origin: 329px 10px; 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-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"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-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e A = [1 2 3; 4 7 8; 0 9 1];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ethen the answer is 9.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 2 3; 4 5 6; 7 8 9];\r\ny_correct = 9;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = -10:0;\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = 17;\r\ny_correct = 17;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = magic(6);\r\ny_correct = 36;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [5 23 6 2 9 0 -1]';\r\ny_correct = 23;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":84,"comments_count":25,"created_by":6728,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17774,"test_suite_updated_at":"2013-07-10T18:41:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-09T04:08:24.000Z","updated_at":"2026-04-05T08:23:56.000Z","published_at":"2013-07-09T04:08:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the maximum value in the given matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if\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 2 3; 4 7 8; 0 9 1];]]\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\u003ethen the answer is 9.\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":584,"title":"middleAsColumn:  Return all but first and last element as a column vector","description":"Given input A, return all but the first and last elements, arranged as a column vector.  (I.e., all dimensions after the first should be singleton.)\r\n\r\nFor example,\r\n\r\n  \u003e\u003e middleAsColumn(eye(3))\r\nans =\r\n     0\r\n     0\r\n     0\r\n     1\r\n     0\r\n     0\r\n     0","description_html":"\u003cp\u003eGiven input A, return all but the first and last elements, arranged as a column vector.  (I.e., all dimensions after the first should be singleton.)\u003c/p\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u003e\u003e middleAsColumn(eye(3))\r\nans =\r\n   0\r\n   0\r\n   0\r\n   1\r\n   0\r\n   0\r\n   0\r\n\u003c/pre\u003e","function_template":"function y = middleAsColumn(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = zeros(0,1);\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n%%\r\nx = rand(1,4);\r\ny_correct = x(2:3)';\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n\r\n%%\r\nx = rand(4,1);\r\ny_correct = x(2:3);\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n%%\r\nx = rand(2,2);\r\ny_correct = x(2:3)';\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n%%\r\nx = {1 2 3 4};\r\ny_correct = x(2:3)';\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n%%\r\nx = struct('a',{1 2 3 4},'b',{3 4 5 6});\r\ny_correct = x(2:3)';\r\nassert(isequal(middleAsColumn(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":3117,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":647,"test_suite_updated_at":"2012-04-13T21:04:38.000Z","rescore_all_solutions":false,"group_id":12,"created_at":"2012-04-13T21:04:38.000Z","updated_at":"2026-02-10T12:57:51.000Z","published_at":"2012-04-13T21:04:38.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 input A, return all but the first and last elements, arranged as a column vector. (I.e., all dimensions after the first should be singleton.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[\u003e\u003e middleAsColumn(eye(3))\\nans =\\n   0\\n   0\\n   0\\n   1\\n   0\\n   0\\n   0]]\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":46588,"title":"i was a mistake","description":null,"description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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=\"block-size: 71.7188px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.989px 35.8523px; transform-origin: 406.996px 35.8594px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 41.8182px; 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.991px 20.9091px; text-align: left; transform-origin: 383.999px 20.9091px; 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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYou start with a Function Template that is only two characters away from working properly. The math itself is fairly simple. The actual problem is understanding the purpose of the function despite the somewhat criminal coding style.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYou can pick some ideas to improve your own style \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/fileexchange/46056-matlab-style-guidelines-2-0\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ehere\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function s = ihaveaproblem(a,b,n)\r\n    global i % i is a global variable\r\n    z = a + b*i; % i is an imaginary number\r\n    clear i % i is no longer a global variable\r\n    s = 0;\r\n    for i = 1:n % i for for index\r\n        s = s + z^i;\r\n        i = i + 2; % i steps by 2\r\n    end\r\nend","test_suite":"global i % i for i\r\ni = 1i;\r\n\r\n%%\r\n\r\na = 1;\r\nb = 0;\r\nn = 1;\r\n\r\ns_correct = 1;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 1;\r\nb = 0;\r\nn = 2;\r\n\r\ns_correct = 1;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 1;\r\nb = 0;\r\nn = 3;\r\n\r\ns_correct = 2;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 0;\r\nb = 1;\r\nn = 1;\r\n\r\ns_correct = 1i;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 1;\r\nb = 1;\r\nn = 8;\r\n\r\ns_correct = 3 - 9i;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 2;\r\nb = 1;\r\nn = 6;\r\n\r\ns_correct = -34 + 53i;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":543257,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-09-15T17:50:42.000Z","updated_at":"2026-03-13T12:16:16.000Z","published_at":"2020-09-16T01:52:51.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 start with a Function Template that is only two characters away from working properly. The math itself is fairly simple. The actual problem is understanding the purpose of the function despite the somewhat criminal coding style.\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 can pick some ideas to improve your own style \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/fileexchange/46056-matlab-style-guidelines-2-0\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":6,"title":"Select every other element of a vector","description":"Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, starting with the first.\r\nExamples:\r\n Input  x = [1 3 2 4 3 5]\r\n Output y is [1 2 3]\r\n\r\n Input  x = [5 9 3 2 2 0 -1]\r\n Output y is [5 3 2 -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: 184.167px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 92.0833px; transform-origin: 407px 92.0833px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 361.5px 8px; transform-origin: 361.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, starting with the first.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 32px 8px; transform-origin: 32px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExamples:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 102.167px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 51.0833px; transform-origin: 404px 51.0833px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 68px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 68px 8.5px; \"\u003ex = [1 3 2 4 3 5]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 80px 8.5px; tab-size: 4; transform-origin: 80px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 48px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 48px 8.5px; \"\u003ey is [1 2 3]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 8.5px; tab-size: 4; transform-origin: 0px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 112px 8.5px; tab-size: 4; transform-origin: 112px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 80px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 80px 8.5px; \"\u003ex = [5 9 3 2 2 0 -1]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 92px 8.5px; tab-size: 4; transform-origin: 92px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 60px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 60px 8.5px; \"\u003ey is [5 3 2 -1]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = everyOther(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('everyOther.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp'); \r\nassert(~illegal)\r\n\r\n%%\r\nx = rand(1,1);\r\nactual = everyOther(x);\r\nassert(isequal(actual, x))\r\n\r\n%%\r\nx = rand(1,10);\r\nactual = everyOther(x);\r\nexpected = [x(1) x(3) x(5) x(7) x(9)];\r\nassert(isequal(actual, expected))\r\n\r\n%%\r\nx = rand(1,100);\r\nactual = everyOther(x);\r\nexpected = [x(1) x(3) x(5) x(7) x(9) x(11) x(13) x(15) x(17) x(19) ...\r\n    x(21) x(23) x(25) x(27) x(29) x(31) x(33) x(35) x(37) x(39) ...\r\n    x(41) x(43) x(45) x(47) x(49) x(51) x(53) x(55) x(57) x(59) ...\r\n    x(61) x(63) x(65) x(67) x(69) x(71) x(73) x(75) x(77) x(79) ...\r\n    x(81) x(83) x(85) x(87) x(89) x(91) x(93) x(95) x(97) x(99)];\r\nassert(isequal(actual, expected))\r\n\r\n%%\r\nx = ['A' 'long' 'time' 'ago' 'in' 'a' 'galaxy' 'far' 'far' 'away'];\r\nactual = everyOther(x);\r\nexpected = 'Aogiegiaaayafrwy';\r\nassert(isequal(actual, expected))\r\n\r\n%%\r\nx = randi(100,10,1);\r\nactual = everyOther(x);\r\nexpected = [x(1);x(3);x(5);x(7);x(9)];\r\nassert(isequal(actual, expected))\r\n\r\n%%\r\nx = primes(20)';\r\nactual = everyOther(x);\r\nexpected = [2 5 11 17]';\r\nassert(isequal(actual, expected))","published":true,"deleted":false,"likes_count":201,"comments_count":55,"created_by":1,"edited_by":223089,"edited_at":"2023-07-12T18:56:59.000Z","deleted_by":null,"deleted_at":null,"solvers_count":36374,"test_suite_updated_at":"2023-07-12T18:56:59.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:17.000Z","updated_at":"2026-04-04T14:44:06.000Z","published_at":"2012-01-18T01:00:17.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\u003eWrite a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, starting with the first.\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\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 = [1 3 2 4 3 5]\\n Output y is [1 2 3]\\n\\n Input  x = [5 9 3 2 2 0 -1]\\n Output y is [5 3 2 -1]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2031,"title":"Half-Swap","description":"Given a vector with an even number of elements,\r\nrearrange it so that the elements in its first \r\nhalf are switched with those in the second half.\r\n\r\nFor example, given a vector:\r\n\r\n Vec = [23  24  6  15  15  20  22  23  9  21]\r\n\r\nwill result in\r\n\r\n Vec = [20  22  23  9  21  23  24  6  15  15]\r\n","description_html":"\u003cp\u003eGiven a vector with an even number of elements,\r\nrearrange it so that the elements in its first \r\nhalf are switched with those in the second half.\u003c/p\u003e\u003cp\u003eFor example, given a vector:\u003c/p\u003e\u003cpre\u003e Vec = [23  24  6  15  15  20  22  23  9  21]\u003c/pre\u003e\u003cp\u003ewill result in\u003c/p\u003e\u003cpre\u003e Vec = [20  22  23  9  21  23  24  6  15  15]\u003c/pre\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nVec = ceil(6*rand(1,10)); % To test your function\r\nend","test_suite":"%%\r\n\r\nx = [15 42 91 17 7 4];\r\ny_correct = [17 7 4 15 42 91];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\n\r\nx = [2 10];\r\ny_correct = [10 2];\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = [27 1 13 11 22 23 6 14];\r\ny_correct = [22 23 6 14 27 1 13 11];\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = [13 14 5 13 12 3 3 9 18 7 11 5 14 5];\r\ny_correct = [9 18 7 11 5 14 5 13 14 5 13 12 3 3];\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":16441,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":420,"test_suite_updated_at":"2013-12-04T19:57:51.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-12-02T08:08:35.000Z","updated_at":"2026-02-14T13:03:09.000Z","published_at":"2013-12-02T08:08: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\",\"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 vector with an even number of elements, rearrange it so that the elements in its first half are switched with those in the second half.\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, given a vector:\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[ Vec = [23  24  6  15  15  20  22  23  9  21]]]\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\u003ewill result 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[ Vec = [20  22  23  9  21  23  24  6  15  15]]]\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":649,"title":"Return the first and last characters of a character array","description":"Return the first and last character of a string, concatenated together. If there is only one character in the string, the function should give that character back twice since it is both the first and last character of the string.\r\n\r\nExample:\r\n\r\n   stringfirstandlast('boring example') = 'be'","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: 123.433px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 61.7167px; transform-origin: 407px 61.7167px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; 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 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 364px 8px; transform-origin: 364px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn the first and last characters of a character array, concatenated together. If there is only one character in the character array, the function should give that character back twice since it is both the first and last character of the character array.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 184px 8.5px; transform-origin: 184px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 88px 8.5px; transform-origin: 88px 8.5px; \"\u003e   stringfirstandlast(\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: 64px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 64px 8.5px; \"\u003e'boring example'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 16px 8.5px; transform-origin: 16px 8.5px; \"\u003e) = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 16px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 16px 8.5px; \"\u003e'be'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = stringfirstandlast(x)\r\n  y = x(1);\r\nend","test_suite":"%%\r\nx = 'abcde';\r\ny_correct = 'ae';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = 'a';\r\ny_correct = 'aa';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = 'codyrocks!';\r\ny_correct = 'c!';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = ' ';\r\ny_correct = '  ';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = '  ';\r\ny_correct = '  ';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = 'az';\r\ny_correct = 'az';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = 'abcdefghijklmnopqrstuvwxyz';\r\ny_correct = 'az';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = '0123456789';\r\ny_correct = '09';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = '09';\r\ny_correct = '09';\r\nassert(isequal(stringfirstandlast(x),y_correct))","published":true,"deleted":false,"likes_count":44,"comments_count":5,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11889,"test_suite_updated_at":"2021-01-20T11:13:02.000Z","rescore_all_solutions":false,"group_id":14,"created_at":"2012-05-01T18:41:40.000Z","updated_at":"2026-04-03T02:20:59.000Z","published_at":"2012-05-01T18:41:56.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\u003eReturn the first and last characters of a character array, concatenated together. If there is only one character in the character array, the function should give that character back twice since it is both the first and last character of the character 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\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[   stringfirstandlast('boring example') = 'be']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":7,"title":"Column Removal","description":"Remove the nth column from input matrix A and return the resulting matrix in output B.\r\n\r\nSo if \r\n\r\n A = [1 2 3;\r\n      4 5 6];\r\n\r\nand \r\n\r\n n = 2 \r\n\r\nthen B is\r\n\r\n [ 1 3  \r\n   4 6 ]\r\n","description_html":"\u003cp\u003eRemove the nth column from input matrix A and return the resulting matrix in output B.\u003c/p\u003e\u003cp\u003eSo if\u003c/p\u003e\u003cpre\u003e A = [1 2 3;\r\n      4 5 6];\u003c/pre\u003e\u003cp\u003eand\u003c/p\u003e\u003cpre\u003e n = 2 \u003c/pre\u003e\u003cp\u003ethen B is\u003c/p\u003e\u003cpre\u003e [ 1 3  \r\n   4 6 ]\u003c/pre\u003e","function_template":"function B = column_removal(A,n)\r\n  B = A;\r\nend","test_suite":"%%\r\nA = [1 2 3; 4 5 6];\r\nn = 2;\r\nB_correct = [1 3; 4 6];\r\nassert(isequal(column_removal(A,n),B_correct))\r\n\r\n%%\r\nA = magic(4);\r\nn = 3;\r\nB = [16     2    13;\r\n      5    11     8;\r\n      9     7    12;\r\n      4    14     1];\r\nB_correct = B;\r\nassert(isequal(column_removal(A,n),B_correct))\r\n\r\n%%\r\nA = 1:10;\r\nn = 7;\r\nB_correct = [1 2 3 4 5 6 8 9 10];\r\nassert(isequal(column_removal(A,n),B_correct))\r\n","published":true,"deleted":false,"likes_count":139,"comments_count":25,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":27697,"test_suite_updated_at":"2019-07-24T15:11:33.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-01-18T01:00:17.000Z","updated_at":"2026-04-03T18:23:15.000Z","published_at":"2012-01-18T01:00:17.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\u003eRemove the nth column from input matrix A and return the resulting matrix in output B.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[ A = [1 2 3;\\n      4 5 6];]]\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\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[ n = 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\u003ethen B is\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 3  \\n   4 6 ]]]\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":1463,"title":"Pascal's Matrix","description":"Given an integer n \u0026ge; 0, generate the ( _n_+1) \u0026times; ( _n_+1) lower triangular \u003chttp://en.wikipedia.org/wiki/Pascal_matrix Pascal's Matrix\u003e.\r\n\r\n*Examples*:\r\n\r\n pascalMat(0)\r\n ans =\r\n     1\r\n\r\n \r\n pascalMat(1)\r\n ans =\r\n     1     0 \r\n     1     1 \r\n \r\n pascalMat(2)\r\n ans =\r\n     1     0     0\r\n     1     1     0\r\n     1     2     1\r\n\r\nNeither *string operations* nor *interpolations* are allowed!\r\n","description_html":"\u003cp\u003eGiven an integer n \u0026ge; 0, generate the ( \u003ci\u003en\u003c/i\u003e+1) \u0026times; ( \u003ci\u003en\u003c/i\u003e+1) lower triangular \u003ca href = \"http://en.wikipedia.org/wiki/Pascal_matrix\"\u003ePascal's Matrix\u003c/a\u003e.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples\u003c/b\u003e:\u003c/p\u003e\u003cpre\u003e pascalMat(0)\r\n ans =\r\n     1\u003c/pre\u003e\u003cpre\u003e pascalMat(1)\r\n ans =\r\n     1     0 \r\n     1     1 \u003c/pre\u003e\u003cpre\u003e pascalMat(2)\r\n ans =\r\n     1     0     0\r\n     1     1     0\r\n     1     2     1\u003c/pre\u003e\u003cp\u003eNeither \u003cb\u003estring operations\u003c/b\u003e nor \u003cb\u003einterpolations\u003c/b\u003e are allowed!\u003c/p\u003e","function_template":"function P = pascalMat(n)\r\n  P = n;\r\nend","test_suite":"%%\r\nuser_solution = fileread('pascalMat.m');\r\nassert(isempty(strfind(user_solution,'regexp')));\r\nassert(isempty(strfind(user_solution,'2str')));\r\nassert(isempty(strfind(user_solution,'str2')));\r\nassert(isempty(strfind(user_solution,'interp')));\r\nassert(isempty(strfind(user_solution,'printf')));\r\nassert(isempty(strfind(user_solution,'assert')));\r\n\r\n%%\r\nn = 0;\r\nP_correct = [\r\n    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 1;\r\nP_correct = [\r\n    1  0\r\n    1  1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 2;\r\nP_correct = [\r\n    1  0  0\r\n    1  1  0\r\n    1  2  1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 3;\r\nP_correct = [\r\n    1  0  0  0\r\n    1  1  0  0\r\n    1  2  1  0\r\n    1  3  3  1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 4;\r\nP_correct = [\r\n    1  0  0  0  0\r\n    1  1  0  0  0\r\n    1  2  1  0  0\r\n    1  3  3  1  0\r\n    1  4  6  4  1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 5;\r\nP_correct = [\r\n    1   0   0   0   0   0\r\n    1   1   0   0   0   0\r\n    1   2   1   0   0   0\r\n    1   3   3   1   0   0\r\n    1   4   6   4   1   0\r\n    1   5  10  10   5   1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 6;\r\nP_correct = [\r\n    1   0   0   0   0   0   0\r\n    1   1   0   0   0   0   0\r\n    1   2   1   0   0   0   0\r\n    1   3   3   1   0   0   0\r\n    1   4   6   4   1   0   0\r\n    1   5  10  10   5   1   0\r\n    1   6  15  20  15   6   1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 7;\r\nP_correct = [\r\n    1   0   0   0   0   0   0   0\r\n    1   1   0   0   0   0   0   0\r\n    1   2   1   0   0   0   0   0\r\n    1   3   3   1   0   0   0   0\r\n    1   4   6   4   1   0   0   0\r\n    1   5  10  10   5   1   0   0\r\n    1   6  15  20  15   6   1   0\r\n    1   7  21  35  35  21   7   1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 8;\r\nP_correct = [\r\n    1   0   0   0   0   0   0   0   0\r\n    1   1   0   0   0   0   0   0   0\r\n    1   2   1   0   0   0   0   0   0\r\n    1   3   3   1   0   0   0   0   0\r\n    1   4   6   4   1   0   0   0   0\r\n    1   5  10  10   5   1   0   0   0\r\n    1   6  15  20  15   6   1   0   0\r\n    1   7  21  35  35  21   7   1   0\r\n    1   8  28  56  70  56  28   8   1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 9;\r\nP_correct = [\r\n    1    0    0    0    0    0    0    0    0    0\r\n    1    1    0    0    0    0    0    0    0    0\r\n    1    2    1    0    0    0    0    0    0    0\r\n    1    3    3    1    0    0    0    0    0    0\r\n    1    4    6    4    1    0    0    0    0    0\r\n    1    5   10   10    5    1    0    0    0    0\r\n    1    6   15   20   15    6    1    0    0    0\r\n    1    7   21   35   35   21    7    1    0    0\r\n    1    8   28   56   70   56   28    8    1    0\r\n    1    9   36   84  126  126   84   36    9    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 10;\r\nP_correct = [\r\n    1    0    0    0    0    0    0    0    0    0    0\r\n    1    1    0    0    0    0    0    0    0    0    0\r\n    1    2    1    0    0    0    0    0    0    0    0\r\n    1    3    3    1    0    0    0    0    0    0    0\r\n    1    4    6    4    1    0    0    0    0    0    0\r\n    1    5   10   10    5    1    0    0    0    0    0\r\n    1    6   15   20   15    6    1    0    0    0    0\r\n    1    7   21   35   35   21    7    1    0    0    0\r\n    1    8   28   56   70   56   28    8    1    0    0\r\n    1    9   36   84  126  126   84   36    9    1    0\r\n    1   10   45  120  210  252  210  120   45   10    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 11;\r\nP_correct = [\r\n    1    0    0    0    0    0    0    0    0    0    0    0\r\n    1    1    0    0    0    0    0    0    0    0    0    0\r\n    1    2    1    0    0    0    0    0    0    0    0    0\r\n    1    3    3    1    0    0    0    0    0    0    0    0\r\n    1    4    6    4    1    0    0    0    0    0    0    0\r\n    1    5   10   10    5    1    0    0    0    0    0    0\r\n    1    6   15   20   15    6    1    0    0    0    0    0\r\n    1    7   21   35   35   21    7    1    0    0    0    0\r\n    1    8   28   56   70   56   28    8    1    0    0    0\r\n    1    9   36   84  126  126   84   36    9    1    0    0\r\n    1   10   45  120  210  252  210  120   45   10    1    0\r\n    1   11   55  165  330  462  462  330  165   55   11    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 12;\r\nP_correct = [\r\n    1    0    0    0    0    0    0    0    0    0    0    0    0\r\n    1    1    0    0    0    0    0    0    0    0    0    0    0\r\n    1    2    1    0    0    0    0    0    0    0    0    0    0\r\n    1    3    3    1    0    0    0    0    0    0    0    0    0\r\n    1    4    6    4    1    0    0    0    0    0    0    0    0\r\n    1    5   10   10    5    1    0    0    0    0    0    0    0\r\n    1    6   15   20   15    6    1    0    0    0    0    0    0\r\n    1    7   21   35   35   21    7    1    0    0    0    0    0\r\n    1    8   28   56   70   56   28    8    1    0    0    0    0\r\n    1    9   36   84  126  126   84   36    9    1    0    0    0\r\n    1   10   45  120  210  252  210  120   45   10    1    0    0\r\n    1   11   55  165  330  462  462  330  165   55   11    1    0\r\n    1   12   66  220  495  792  924  792  495  220   66   12    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 13;\r\nP_correct = [\r\n    1     0     0     0     0     0     0     0     0     0     0     0     0     0\r\n    1     1     0     0     0     0     0     0     0     0     0     0     0     0\r\n    1     2     1     0     0     0     0     0     0     0     0     0     0     0\r\n    1     3     3     1     0     0     0     0     0     0     0     0     0     0\r\n    1     4     6     4     1     0     0     0     0     0     0     0     0     0\r\n    1     5    10    10     5     1     0     0     0     0     0     0     0     0\r\n    1     6    15    20    15     6     1     0     0     0     0     0     0     0\r\n    1     7    21    35    35    21     7     1     0     0     0     0     0     0\r\n    1     8    28    56    70    56    28     8     1     0     0     0     0     0\r\n    1     9    36    84   126   126    84    36     9     1     0     0     0     0\r\n    1    10    45   120   210   252   210   120    45    10     1     0     0     0\r\n    1    11    55   165   330   462   462   330   165    55    11     1     0     0\r\n    1    12    66   220   495   792   924   792   495   220    66    12     1     0\r\n    1    13    78   286   715  1287  1716  1716  1287   715   286    78    13     1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 14;\r\nP_correct = [\r\n    1              0              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              1              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              2              1              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              3              3              1              0              0              0              0              0              0              0              0              0              0              0\r\n    1              4              6              4              1              0              0              0              0              0              0              0              0              0              0\r\n    1              5             10             10              5              1              0              0              0              0              0              0              0              0              0\r\n    1              6             15             20             15              6              1              0              0              0              0              0              0              0              0\r\n    1              7             21             35             35             21              7              1              0              0              0              0              0              0              0\r\n    1              8             28             56             70             56             28              8              1              0              0              0              0              0              0\r\n    1              9             36             84            126            126             84             36              9              1              0              0              0              0              0\r\n    1             10             45            120            210            252            210            120             45             10              1              0              0              0              0\r\n    1             11             55            165            330            462            462            330            165             55             11              1              0              0              0\r\n    1             12             66            220            495            792            924            792            495            220             66             12              1              0              0\r\n    1             13             78            286            715           1287           1716           1716           1287            715            286             78             13              1              0\r\n    1             14             91            364           1001           2002           3003           3432           3003           2002           1001            364             91             14              1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 15;\r\nP_correct = [\r\n    1              0              0              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              1              0              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              2              1              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              3              3              1              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              4              6              4              1              0              0              0              0              0              0              0              0              0              0              0\r\n    1              5             10             10              5              1              0              0              0              0              0              0              0              0              0              0\r\n    1              6             15             20             15              6              1              0              0              0              0              0              0              0              0              0\r\n    1              7             21             35             35             21              7              1              0              0              0              0              0              0              0              0\r\n    1              8             28             56             70             56             28              8              1              0              0              0              0              0              0              0\r\n    1              9             36             84            126            126             84             36              9              1              0              0              0              0              0              0\r\n    1             10             45            120            210            252            210            120             45             10              1              0              0              0              0              0\r\n    1             11             55            165            330            462            462            330            165             55             11              1              0              0              0              0\r\n    1             12             66            220            495            792            924            792            495            220             66             12              1              0              0              0\r\n    1             13             78            286            715           1287           1716           1716           1287            715            286             78             13              1              0              0\r\n    1             14             91            364           1001           2002           3003           3432           3003           2002           1001            364             91             14              1              0\r\n    1             15            105            455           1365           3003           5005           6435           6435           5005           3003           1365            455            105             15              1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":10352,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":382,"test_suite_updated_at":"2013-04-28T07:09:30.000Z","rescore_all_solutions":false,"group_id":18,"created_at":"2013-04-27T13:20:43.000Z","updated_at":"2026-03-31T18:04:35.000Z","published_at":"2013-04-27T13:43:22.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 an integer n ≥ 0, generate the (\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\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e+1) × (\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\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e+1) lower triangular\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://en.wikipedia.org/wiki/Pascal_matrix\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePascal's Matrix\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ pascalMat(0)\\n ans =\\n     1\\n\\n pascalMat(1)\\n ans =\\n     1     0 \\n     1     1 \\n\\n pascalMat(2)\\n ans =\\n     1     0     0\\n     1     1     0\\n     1     2     1]]\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\u003eNeither\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\u003estring operations\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e nor\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\u003einterpolations\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e are allowed!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":19,"title":"Swap the first and last columns","description":"Flip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All other columns should be left intact. Return the result in matrix B.\r\nIf the input has one column, the output should be identical to the input.\r\nExample:\r\n Input  A =  [ 12  4   7\r\n                5  1   4 ];\r\n Output B is [  7  4  12 \r\n                4  1   5 ];","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: 193.733px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.5px 96.8667px; transform-origin: 406.5px 96.8667px; 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.642px 7.81667px; transform-origin: 374.642px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFlip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All other columns should be left intact. Return the result in matrix B.\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: 227.242px 7.81667px; transform-origin: 227.242px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf the input has one column, the output should be identical to the input.\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: 30.7083px 7.81667px; transform-origin: 30.7083px 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: 81.7333px; 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 40.8667px; transform-origin: 403.5px 40.8667px; 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: 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: 31.2667px 8.375px; transform-origin: 31.2667px 8.375px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 11.725px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 11.725px 8.375px; \"\u003eA =\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 7.81667px 8.375px; transform-origin: 7.81667px 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: 42.9917px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 42.9917px 8.375px; \"\u003e[ 12  4   7\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: 105.525px 8.375px; tab-size: 4; transform-origin: 105.525px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                5  1   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: 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; perspective-origin: 31.2667px 8.375px; transform-origin: 31.2667px 8.375px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 66.4417px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 66.4417px 8.375px; \"\u003eB is [  7  4  12 \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: 105.525px 8.375px; tab-size: 4; transform-origin: 105.525px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                4  1   5 ];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function B = swap_ends(A)\r\n  B = A;\r\nend","test_suite":"%%\r\nfiletext = fileread('swap_ends.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp');\r\nassert(~illegal)\r\n\r\n%%\r\nA = [ 12  4   7\r\n       5  1   4];\r\nB_correct = [  7  4  12 \r\n               4  1   5 ];\r\nassert(isequal(swap_ends(A),B_correct))\r\n\r\n%%\r\nA = [ 12  7\r\n       5  4];\r\nB_correct = [  7  12 \r\n               4   5 ];\r\nassert(isequal(swap_ends(A),B_correct))\r\n\r\n%%\r\nA = [ 1 5 0 2 3 ];\r\nB_correct = [ 3 5 0 2 1 ];\r\nassert(isequal(swap_ends(A),B_correct))\r\n\r\n%%\r\nA = 1;\r\nB_correct = 1;\r\nassert(isequal(swap_ends(A),B_correct))\r\n\r\n%%\r\nA = randi(100,10,1);\r\nB_correct = A;\r\nassert(isequal(swap_ends(A),B_correct))","published":true,"deleted":false,"likes_count":114,"comments_count":18,"created_by":1,"edited_by":223089,"edited_at":"2024-06-30T13:52:17.000Z","deleted_by":null,"deleted_at":null,"solvers_count":22633,"test_suite_updated_at":"2024-06-30T13:52:17.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:19.000Z","updated_at":"2026-04-04T15:01:07.000Z","published_at":"2012-01-18T01:00:19.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\u003eFlip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All other columns should be left intact. Return the result in matrix B.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input has one column, the output should be identical to the input.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  A =  [ 12  4   7\\n                5  1   4 ];\\n Output B is [  7  4  12 \\n                4  1   5 ];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":10,"title":"Determine whether a vector is monotonically increasing","description":"Return true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return false otherwise.\r\nExamples:\r\n Input  x = [-3 0 7]\r\n Output tf is true\r\n\r\n Input  x = [2 2]\r\n Output tf is false","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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=\"block-size: 184.188px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407.5px 92.0938px; transform-origin: 407.5px 92.0938px; 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: 384.5px 21px; text-align: left; transform-origin: 384.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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eReturn true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return false otherwise.\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: 384.5px 10.5px; text-align: left; transform-origin: 384.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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eExamples:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 102.188px; 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: 404.5px 51.0938px; transform-origin: 404.5px 51.0938px; 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.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); \"\u003ex = [-3 0 7]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); \"\u003etf is true\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); \"\u003ex = [2 2]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); \"\u003etf is false\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tf = mono_increase(x)\r\n  tf = false;\r\nend","test_suite":"%%\r\nfiletext = fileread('mono_increase.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'elseif'); \r\nassert(~illegal)\r\n\r\n%%\r\nx = [0 1 2 3 4];\r\nassert(isequal(mono_increase(x),true));\r\n\r\n%%\r\nx = [0 1 2 3 -4];\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = [-3 -4 2 3 4];\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = 1:.1:10;\r\nassert(isequal(mono_increase(x),true));\r\n\r\n%%\r\nx = cumsum(rand(1,100));\r\nx(5) = -1;\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = cumsum(rand(1,50));\r\nassert(isequal(mono_increase(x),true));\r\n\r\n%%\r\nx = ones(1,25);\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = [5 4 3 2 1];\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = [1 2 3 3 4 5];\r\nassert(isequal(mono_increase(x),false));","published":true,"deleted":false,"likes_count":162,"comments_count":45,"created_by":1,"edited_by":7,"edited_at":"2023-09-11T20:15:05.000Z","deleted_by":null,"deleted_at":null,"solvers_count":22956,"test_suite_updated_at":"2023-09-11T20:15:05.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:18.000Z","updated_at":"2026-04-04T15:03:28.000Z","published_at":"2012-01-18T01:00:18.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\u003eReturn true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return false otherwise.\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\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 = [-3 0 7]\\n Output tf is true\\n\\n Input  x = [2 2]\\n Output tf is false]]\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\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":44634,"title":"Basic matrix operations using standard MATLAB commands","description":"Create the matrix:\r\n\r\n 1.0e+15 *\r\n\r\n    0.0000    0.0000    0.0000    0.0000    0.0000\r\n    0.0000    0.0000    0.0000    0.0000    0.0000\r\n    0.0001    0.0010    0.0100    0.1000    1.0000\r\n\r\nFind the row vector of all column means\r\n\r\nHint: Use _logspace_ to create the matrix. Avoid looking at the test suite before writing a solution","description_html":"\u003cp\u003eCreate the matrix:\u003c/p\u003e\u003cpre\u003e 1.0e+15 *\u003c/pre\u003e\u003cpre\u003e    0.0000    0.0000    0.0000    0.0000    0.0000\r\n    0.0000    0.0000    0.0000    0.0000    0.0000\r\n    0.0001    0.0010    0.0100    0.1000    1.0000\u003c/pre\u003e\u003cp\u003eFind the row vector of all column means\u003c/p\u003e\u003cp\u003eHint: Use \u003ci\u003elogspace\u003c/i\u003e to create the matrix. Avoid looking at the test suite before writing a solution\u003c/p\u003e","function_template":"function y = matrix_ls_means()\r\n  y = x;\r\nend","test_suite":"%%\r\ny_correct = mean([logspace(1,5,5);logspace(6,10,5);logspace(11,15,5)]);\r\nassert(isequal(matrix_ls_means(),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":2,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":"2018-05-09T05:37:01.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-09T05:32:41.000Z","updated_at":"2026-02-17T08:19:25.000Z","published_at":"2018-05-09T05:35: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\",\"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 the matrix:\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.0e+15 *\\n\\n    0.0000    0.0000    0.0000    0.0000    0.0000\\n    0.0000    0.0000    0.0000    0.0000    0.0000\\n    0.0001    0.0010    0.0100    0.1000    1.0000]]\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\u003eFind the row vector of all column means\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\u003eHint: Use\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\u003elogspace\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to create the matrix. Avoid looking at the test suite before writing a solution\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":44670,"title":"Basic Quadratic Equation","description":"Create the equation:\r\n\r\ny=(3x)^2+(5x)+35\r\nand compute y for various values of x","description_html":"\u003cp\u003eCreate the equation:\u003c/p\u003e\u003cp\u003ey=(3x)^2+(5x)+35\r\nand compute y for various values of x\u003c/p\u003e","function_template":"function y = quad1(x)\r\n\r\nend","test_suite":"%%\r\nx = -3;\r\ny_correct = 101;\r\nassert(isequal(quad1(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = 285;\r\nassert(isequal(quad1(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":91,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-30T10:55:15.000Z","updated_at":"2026-02-13T15:28:08.000Z","published_at":"2018-05-30T10:55:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eCreate the equation:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ey=(3x)^2+(5x)+35 and compute y for various values of x\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":42347,"title":"Create a Standard Size Vector","description":"Given an input x, create a row vector y from 1 to x with 5 elements.","description_html":"\u003cp\u003eGiven an input x, create a row vector y from 1 to x with 5 elements.\u003c/p\u003e","function_template":"function y = standard_vector(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 220;\r\ny_correct = [1.0000   55.7500  110.5000  165.2500  220.0000];\r\nassert(isequal(standard_vector(x),y_correct))\r\n\r\n%%\r\nx = 801;\r\ny_correct = [ 1   201   401   601   801];\r\nassert(isequal(standard_vector(x),y_correct))\r\n\r\n%%\r\nx = 4;\r\ny_correct = [   1.0000    1.7500    2.5000    3.2500    4.000];\r\nassert(isequal(standard_vector(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":44605,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":150,"test_suite_updated_at":"2015-06-17T17:59:34.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2015-06-01T01:19:15.000Z","updated_at":"2026-02-17T17:52:43.000Z","published_at":"2015-06-01T01:19:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input x, create a row vector y from 1 to x with 5 elements.\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":42346,"title":"Create a Matrix of Zeros","description":"Given an input x, create a square matrix y of zeros with x rows and x columns.","description_html":"\u003cp\u003eGiven an input x, create a square matrix y of zeros with x rows and x columns.\u003c/p\u003e","function_template":"function y = matrix_zeros(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2;\r\ny_correct = [ ...\r\n     0     0  \r\n     0     0  ];\r\nassert(isequal(matrix_zeros(x),y_correct))\r\n\r\n%%\r\nx = 6;\r\ny_correct = [ ...\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0\r\n     0     0     0     0     0     0];\r\nassert(isequal(matrix_zeros(x),y_correct))\r\n\r\n%%\r\nx = 1;\r\ny_correct = 0;\r\nassert(isequal(matrix_zeros(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":44605,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":647,"test_suite_updated_at":"2015-06-17T18:04:48.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2015-06-01T01:15:52.000Z","updated_at":"2026-02-15T15:03:06.000Z","published_at":"2015-06-01T01:16:06.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input x, create a square matrix y of zeros with x rows and x columns.\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":44653,"title":"Basics: counting digits of a number irrespective of the sign","description":"publish the number of digits in any input integer\r\nexample: -23----\u003e2","description_html":"\u003cp\u003epublish the number of digits in any input integer\r\nexample: -23----\u0026gt;2\u003c/p\u003e","function_template":"function y = count_digits(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = -21;\r\ny_correct = 2;\r\nassert(isequal(count_digits(x),y_correct))\r\n\r\n%%\r\nx = 3567;\r\ny_correct = 4;\r\nassert(isequal(count_digits(x),y_correct))\r\n\r\n%%\r\nx = -2;\r\ny_correct = 1;\r\nassert(isequal(count_digits(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":70,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-25T11:35:55.000Z","updated_at":"2026-02-28T08:19:58.000Z","published_at":"2018-05-25T11:35:55.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003epublish the number of digits in any input integer example: -23----\u0026gt;2\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":44621,"title":"Product of all elements in an array","description":"Compute the product of all elements in an array.","description_html":"\u003cp\u003eCompute the product of all elements in an array.\u003c/p\u003e","function_template":"function y = array_prod(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 2 5];\r\ny_correct = 10;\r\nassert(isequal(array_prod(x),y_correct))\r\n\r\n%%\r\nx = [10, 200];\r\ny_correct = 2000;\r\nassert(isequal(array_prod(x),y_correct))\r\n\r\n%%\r\nx = [true, false];\r\ny_correct = 0;\r\nassert(isequal(array_prod(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":93,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-20T18:07:49.000Z","updated_at":"2026-02-13T19:02:31.000Z","published_at":"2018-04-20T18:07: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\u003eCompute the product of all elements in an array.\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":44654,"title":"convert the number to binary format \u0026 count digits","description":"Convert the given number to the corresponding binary format and count the number of digits in that binary number","description_html":"\u003cp\u003eConvert the given number to the corresponding binary format and count the number of digits in that binary number\u003c/p\u003e","function_template":"function y = dec_2_bin(x)\r\n \r\nend","test_suite":"%%\r\nx = 23;\r\ny_correct = 5;\r\nassert(isequal(dec_2_bin(x),y_correct))\r\n\r\n%%\r\nx = 234;\r\ny_correct = 8;\r\nassert(isequal(dec_2_bin(x),y_correct))\r\n\r\n%%\r\nx = 22;\r\ny_correct = 5;\r\nassert(isequal(dec_2_bin(x),y_correct))\r\n\r\n%%\r\nx = 2;\r\ny_correct = 2;\r\nassert(isequal(dec_2_bin(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-25T11:50:28.000Z","updated_at":"2026-02-10T18:29:49.000Z","published_at":"2018-05-25T11:50: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\",\"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\u003eConvert the given number to the corresponding binary format and count the number of digits in that binary number\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":44622,"title":"Check for keywords","description":"If the entered string is a MATLAB keyword, return true else false","description_html":"\u003cp\u003eIf the entered string is a MATLAB keyword, return true else false\u003c/p\u003e","function_template":"function y = check_keyword(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'function';\r\ny_correct = true;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'persistent';\r\ny_correct = true;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'classdef';\r\ny_correct = true;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'variable';\r\ny_correct = false;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'dateadd';\r\ny_correct = false;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'spmd';\r\ny_correct = true;\r\nassert(isequal(check_keyword(x),y_correct))\r\n\r\n%%\r\nx = 'partition';\r\ny_correct = false;\r\nassert(isequal(check_keyword(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-21T03:51:04.000Z","updated_at":"2026-02-27T14:13:45.000Z","published_at":"2018-04-21T03:51:04.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the entered string is a MATLAB keyword, return true else false\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":44687,"title":"basic matrix operations: rotate and find sum of diagonal elements of the resultant matrix","description":"For given input matrix a, rotate it by 90 degrees and find the sum of the diagonals.\r\n\r\nExample:\r\nInput:\r\n\r\n  a =\r\n\r\n     1     2     3     4\r\n     5     6     7     8\r\n     8    10    12    -2\r\n    -1    -3    -5    -7\r\n\r\nOutput is: \r\n\r\n  20","description_html":"\u003cp\u003eFor given input matrix a, rotate it by 90 degrees and find the sum of the diagonals.\u003c/p\u003e\u003cp\u003eExample:\r\nInput:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003ea =\r\n\u003c/pre\u003e\u003cpre\u003e     1     2     3     4\r\n     5     6     7     8\r\n     8    10    12    -2\r\n    -1    -3    -5    -7\u003c/pre\u003e\u003cp\u003eOutput is:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e20\r\n\u003c/pre\u003e","function_template":"function ans = matrix_manipulation(x)\r\n  \r\nend","test_suite":"%%\r\nx = [1 2 3 4; 5 6 7 8;8 10, 12, -2;-1 -3 -5,-7];\r\ny_correct = 20;\r\nassert(isequal(matrix_manipulation(x),y_correct))\r\n\r\n%%\r\nx = ones(5).*3\r\ny_correct = 15;\r\nassert(isequal(matrix_manipulation(x),y_correct))\r\n\r\n%%\r\na=[3,2,5]\r\nx = [a;a;a];\r\ny_correct = 10;\r\nassert(isequal(matrix_manipulation(x),y_correct))\r\n\r\n%%\r\nx = [-5,25,-10;8,-18,10;-2,7,-1]\r\ny_correct = -30;\r\nassert(isequal(matrix_manipulation(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":62,"test_suite_updated_at":"2018-06-13T08:54:27.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-06-13T08:49:50.000Z","updated_at":"2026-03-02T08:56:19.000Z","published_at":"2018-06-13T08:54:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor given input matrix a, rotate it by 90 degrees and find the sum of the diagonals.\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: 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[a =\\n\\n     1     2     3     4\\n     5     6     7     8\\n     8    10    12    -2\\n    -1    -3    -5    -7]]\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\u003eOutput is:\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[20]]\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":42348,"title":"Square a Number","description":"Given an input x, return y, which is equal to the square of x.","description_html":"\u003cp\u003eGiven an input x, return y, which is equal to the square of x.\u003c/p\u003e","function_template":"function y = square(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 4;\r\ny_correct = 16;\r\nassert(isequal(square(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":44605,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":899,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-06-01T01:29:01.000Z","updated_at":"2026-02-15T15:05:29.000Z","published_at":"2015-06-01T01:29:01.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input x, return y, which is equal to the square of x.\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":1926,"title":"Unit Matrix","description":"Given n, you should return an n-by-n unit matrix.\r\nExample:\r\nIf input is n=2 then\r\n A = [ 1 0 \r\n       0 1 ]\r\nIf input is n=4 then\r\n A = [ 1 0 0 0\r\n       0 1 0 0\r\n       0 0 1 0 \r\n       0 0 0 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: 254.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 127.3px; transform-origin: 407px 127.3px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 152.5px 8px; transform-origin: 152.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven n, you should return an n-by-n unit matrix.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 58px 8px; transform-origin: 58px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf input is n=2 then\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 44px 8.5px; tab-size: 4; transform-origin: 44px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e A = [ 1 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 48px 8.5px; tab-size: 4; transform-origin: 48px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0 1 ]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 58px 8px; transform-origin: 58px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf input is n=4 then\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; tab-size: 4; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e A = [ 1 0 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 56px 8.5px; tab-size: 4; transform-origin: 56px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0 1 0 0\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 60px 8.5px; tab-size: 4; transform-origin: 60px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0 0 1 0 \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 64px 8.5px; tab-size: 4; transform-origin: 64px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0 0 0 1 ]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 2;\r\ny_correct = [1 0;0 1];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = 3;\r\ny_correct = [1 0 0;0 1 0; 0 0 1];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":18257,"edited_by":223089,"edited_at":"2022-10-31T04:49:45.000Z","deleted_by":null,"deleted_at":null,"solvers_count":512,"test_suite_updated_at":"2022-10-31T04:49:45.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-10-09T18:48:08.000Z","updated_at":"2026-02-09T16:23:54.000Z","published_at":"2013-10-09T18:48:08.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\u003eGiven n, you should return an n-by-n unit matrix.\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=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf input is n=2 then\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 0 \\n       0 1 ]]]\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\u003eIf input is n=4 then\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 0 0 0\\n       0 1 0 0\\n       0 0 1 0 \\n       0 0 0 1 ]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":44620,"title":"generate capital english alphabets ","description":"Based on the numeric input 'n', generate the capital english alphabet starting from A till the english alphabet at the 'n'th position.\r\n\r\nEx: if n=3, generate 'ABC'","description_html":"\u003cp\u003eBased on the numeric input 'n', generate the capital english alphabet starting from A till the english alphabet at the 'n'th position.\u003c/p\u003e\u003cp\u003eEx: if n=3, generate 'ABC'\u003c/p\u003e","function_template":"function letters = generate_alphabets(n)\r\n letters = [];\r\nend","test_suite":"%%\r\nn = 1;\r\ny_correct = 'A';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 6;\r\ny_correct = 'ABCDEF';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 26;\r\ny_correct = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 12;\r\ny_correct = 'ABCDEFGHIJKL';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 21;\r\ny_correct = 'ABCDEFGHIJKLMNOPQRSTU';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n\r\n%%\r\nn = 3;\r\ny_correct = 'ABC';\r\nassert(isequal(generate_alphabets(n),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":"2018-07-16T17:02:49.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-20T08:51:49.000Z","updated_at":"2026-03-02T08:58:15.000Z","published_at":"2018-04-20T08:51: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\u003eBased on the numeric input 'n', generate the capital english alphabet starting from A till the english alphabet at the 'n'th position.\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\u003eEx: if n=3, generate 'ABC'\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":1501,"title":"Try 1.5.4: Celsius to Fahrenheit","description":"Write a program to convert an input given in Celsius to Fahrenheit.\r\n\r\nExamples:\r\n\r\n Input  celsiusValue = 100\r\n Output fahrValue is 212\r\n\r\n Input  celsiusValue  = 0\r\n Output fahrValue is 32","description_html":"\u003cp\u003eWrite a program to convert an input given in Celsius to Fahrenheit.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e Input  celsiusValue = 100\r\n Output fahrValue is 212\u003c/pre\u003e\u003cpre\u003e Input  celsiusValue  = 0\r\n Output fahrValue is 32\u003c/pre\u003e","function_template":"function fahrValue = ConvertCelsiusToFahrenheit(celsiusValue)\r\n% Modify the line below so that the output y is the input x converted to Fahrenheit.\r\n\r\n  fahrValue = celsiusValue;\r\n\r\n% After you fix the code, press the \"Submit\" button, and you're on your way.\r\nend","test_suite":"%%\r\ncelsiusValue = 1;\r\nfahrValue = 33.8;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))\r\n%%\r\ncelsiusValue = 0;\r\nfahrValue = 32.0;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))\r\n%%\r\ncelsiusValue = 100;\r\nfahrValue = 212;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))\r\n%%\r\ncelsiusValue = -100;\r\nfahrValue = -148;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))\r\n%%\r\ncelsiusValue = -10;\r\nfahrValue = 14;\r\nassert(isequal(ConvertCelsiusToFahrenheit(celsiusValue),fahrValue))","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":13656,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":867,"test_suite_updated_at":"2013-05-13T02:47:06.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-05-12T04:05:29.000Z","updated_at":"2026-02-19T11:02:07.000Z","published_at":"2013-05-12T04:05: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\u003eWrite a program to convert an input given in Celsius to Fahrenheit.\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  celsiusValue = 100\\n Output fahrValue is 212\\n\\n Input  celsiusValue  = 0\\n Output fahrValue is 32]]\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":8,"title":"Add two numbers","description":"Given a and b, return the sum a+b in c.","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: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; 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 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 123.5px 8px; transform-origin: 123.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven a and b, return the sum a+b in c.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function c = add_two_numbers(a,b)\r\n  c = 17;\r\nend","test_suite":"%%\r\nfiletext = fileread('add_two_numbers.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'if') || contains(filetext, 'switch'); \r\nassert(~illegal)\r\n\r\n%%\r\na = 1;\r\nb = 2;\r\nc_correct = 3;\r\nassert(isequal(add_two_numbers(a,b),c_correct))\r\n\r\n%%\r\na = 17;\r\nb = 2;\r\nc_correct = 19;\r\nassert(isequal(add_two_numbers(a,b),c_correct))\r\n\r\n\r\n%%\r\na = -5;\r\nb = 2;\r\nc_correct = -3;\r\nassert(isequal(add_two_numbers(a,b),c_correct))\r\n\r\n%%\r\na = randi(1e4);\r\nb = -a;\r\nassert(isequal(add_two_numbers(a,b),0))\r\n\r\n%%\r\na = randi(1e3);\r\nb = a;\r\nassert(isequal(add_two_numbers(a,b),2*a))\r\n","published":true,"deleted":false,"likes_count":306,"comments_count":84,"created_by":1,"edited_by":223089,"edited_at":"2022-12-19T10:49:35.000Z","deleted_by":null,"deleted_at":null,"solvers_count":46842,"test_suite_updated_at":"2022-12-19T10:49:47.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:18.000Z","updated_at":"2026-04-05T08:26:29.000Z","published_at":"2012-01-18T01:00:18.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a and b, return the sum a+b in c.\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":44663,"title":"Datetime basics","description":"Generate the datetime scalar representing the current date","description_html":"\u003cp\u003eGenerate the datetime scalar representing the current date\u003c/p\u003e","function_template":"function y = generate_datetime()\r\n  \r\nend","test_suite":"%%\r\ny_correct = datetime('today');\r\nassert(isequal(generate_datetime(),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":135,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T14:59:26.000Z","updated_at":"2026-03-02T09:12:44.000Z","published_at":"2018-05-29T14:59:26.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\u003eGenerate the datetime scalar representing the current date\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":44662,"title":"Check if there are white spaces in the input string","description":"If there are white spaces in the input string, output=1 else 0","description_html":"\u003cp\u003eIf there are white spaces in the input string, output=1 else 0\u003c/p\u003e","function_template":"function y = white_space_tf(x)\r\n  \r\nend","test_suite":"%%\r\nx = '123 test';\r\ny_correct = 1;\r\nassert(isequal(white_space_tf(x),y_correct))\r\n\r\n%%\r\nx = '123';\r\ny_correct = 0;\r\nassert(isequal(white_space_tf(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":57,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T14:24:57.000Z","updated_at":"2026-03-05T10:45:19.000Z","published_at":"2018-05-29T14:24:57.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf there are white spaces in the input string, output=1 else 0\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":44696,"title":"Sum of unique multiples of 3 and 5","description":"If we list all the natural numbers up to 15 that are multiples of 3 or 5, we get 3, 5, 6, 9, 10, 12 and 15. The sum of these multiples is 60. \r\n\r\nWrite a function called _*sum3and5muls*_ that returns the sum of all the unique multiples of 3 or 5 up to n where n is a positive integer and the only input argument of the function.","description_html":"\u003cp\u003eIf we list all the natural numbers up to 15 that are multiples of 3 or 5, we get 3, 5, 6, 9, 10, 12 and 15. The sum of these multiples is 60.\u003c/p\u003e\u003cp\u003eWrite a function called \u003ci\u003e\u003cb\u003esum3and5muls\u003c/b\u003e\u003c/i\u003e that returns the sum of all the unique multiples of 3 or 5 up to n where n is a positive integer and the only input argument of the function.\u003c/p\u003e","function_template":"function sum_mult = sum3and5muls(n)\r\n    sum_mult\r\nend","test_suite":"%%\r\nn = 15;\r\nsm_correct = 60;\r\nassert(isequal(sum3and5muls(n),sm_correct))\r\n\r\n%%\r\nn = 18;\r\nsm_correct = 78;\r\nassert(isequal(sum3and5muls(n),sm_correct))\r\n\r\n%%\r\nn = (2^2)-1;\r\nsm_correct = 3;\r\nassert(isequal(sum3and5muls(n),sm_correct))\r\n\r\n%%\r\nn = randi(25);\r\nsm_correct = sum(3:3:n)+sum(5:5:n)-sum(15:15:n);\r\nassert(isequal(sum3and5muls(n),sm_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":61,"test_suite_updated_at":"2018-07-10T11:40:12.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-07-10T11:35:26.000Z","updated_at":"2026-03-02T14:30:43.000Z","published_at":"2018-07-10T11:40:12.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\u003eIf we list all the natural numbers up to 15 that are multiples of 3 or 5, we get 3, 5, 6, 9, 10, 12 and 15. The sum of these multiples is 60.\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\u003eWrite a function called\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\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003esum3and5muls\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that returns the sum of all the unique multiples of 3 or 5 up to n where n is a positive integer and the only input argument of the function.\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":44671,"title":"find number of times of occurrence of the most frequent number in a row vector","description":"In a given row vector, find the number of times a mode of a row vector has occurred\r\n\r\nexample: in [2 5 5 5 5 3], output is 4\r\n\r\n","description_html":"\u003cp\u003eIn a given row vector, find the number of times a mode of a row vector has occurred\u003c/p\u003e\u003cp\u003eexample: in [2 5 5 5 5 3], output is 4\u003c/p\u003e","function_template":"function y = num_mode(x)\r\n\r\nend","test_suite":"%%\r\nx =[2 3 3 3 5 3 3 5 5 5 5 5 5];\r\ny_correct = 7;\r\nassert(isequal(num_mode(x),y_correct))\r\n\r\n%%\r\nx =[8 8];\r\ny_correct = 2;\r\nassert(isequal(num_mode(x),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-31T15:30:12.000Z","updated_at":"2026-02-18T10:08:10.000Z","published_at":"2018-05-31T15:30:12.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\u003eIn a given row vector, find the number of times a mode of a row vector has occurred\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: in [2 5 5 5 5 3], output is 4\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":44659,"title":"Nth root of a number","description":"Given an input and a number N, find the Nth root of the number(s)","description_html":"\u003cp\u003eGiven an input and a number N, find the Nth root of the number(s)\u003c/p\u003e","function_template":"function y = rootN(a,N)\r\n  y = x;\r\nend","test_suite":"%%\r\na = 1;\r\nN = 100\r\ny_correct = 1;\r\nassert(isequal(rootN(a,N),y_correct))\r\n\r\n%%\r\na = [1 64 216];\r\nN = 3\r\ny_correct = [1    4    6];\r\nassert(isequal(rootN(a,N),y_correct))\r\n\r\n%%\r\na = 1/100;\r\nN = 2\r\ny_correct = 1/10;\r\nassert(isequal(rootN(a,N),y_correct))\r\n\r\n%%\r\na = 826^10;\r\nN = 10\r\ny_correct = 826;\r\nassert(isequal(rootN(a,N),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":59,"test_suite_updated_at":"2018-05-29T13:54:08.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T13:48:03.000Z","updated_at":"2026-02-20T14:32:58.000Z","published_at":"2018-05-29T13:48:03.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven an input and a number N, find the Nth root of the number(s)\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":44624,"title":"Return median of a matrix","description":"Compute median of a matrix of any dimension. Exclude the NaNs if any.","description_html":"\u003cp\u003eCompute median of a matrix of any dimension. Exclude the NaNs if any.\u003c/p\u003e","function_template":"function y = matrix_median(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [2,3,4;4,5,6];\r\ny_correct = 4;\r\nassert(isequal(matrix_median(x),y_correct))\r\n\r\n%%\r\nx = int8(1:4);\r\ny_correct = 3;\r\nassert(isequal(matrix_median(x),y_correct))\r\n\r\n%%\r\nx = [2 6 8 10 NaN 14 NaN 18 NaN];\r\ny_correct = 9;\r\nassert(isequal(matrix_median(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":73,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-21T04:30:24.000Z","updated_at":"2026-02-18T11:12:59.000Z","published_at":"2018-04-21T04:30:24.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\u003eCompute median of a matrix of any dimension. Exclude the NaNs if any.\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":44697,"title":"count upper and lower case characters","description":"In a given input string, count and return the number of upper and lower case characters as u and l respectively.\r\n\r\nFor example:\r\n\r\n_in 'This is a Test Case'_\r\n\r\n_ans= [u,l]= [3,12]_","description_html":"\u003cp\u003eIn a given input string, count and return the number of upper and lower case characters as u and l respectively.\u003c/p\u003e\u003cp\u003eFor example:\u003c/p\u003e\u003cp\u003e\u003ci\u003ein 'This is a Test Case'\u003c/i\u003e\u003c/p\u003e\u003cp\u003e\u003ci\u003eans= [u,l]= [3,12]\u003c/i\u003e\u003c/p\u003e","function_template":"function y = counter_ul(str)\r\n  \r\nend","test_suite":"%%\r\nstr = 'This is a Test Case';\r\nans_corr = [3 12];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'RandoM';\r\nans_corr = [2 4];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'Hello World';\r\nans_corr = [2 8];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'HELLO WORLD';\r\nans_corr = [10 0];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'hello world';\r\nans_corr = [0 10];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\r\nans_corr = [26 0];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'abcdefghijklmnopqrstuvwxyz';\r\nans_corr = [0 26];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = '42';\r\nans_corr = [0 0];\r\nassert(isequal(counter_ul(str),ans_corr))\r\n\r\n%%\r\nstr = 'Matlab';\r\nans_corr = [1 5];\r\nassert(isequal(counter_ul(str),ans_corr))","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":55,"test_suite_updated_at":"2018-07-17T18:33:09.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-07-10T11:53:29.000Z","updated_at":"2026-03-11T08:29:11.000Z","published_at":"2018-07-10T11:53: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\u003eIn a given input string, count and return the number of upper and lower case characters as u and l respectively.\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:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003ein 'This is a Test Case'\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eans= [u,l]= [3,12]\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":1458,"title":"Is it a number?","description":"Determine if input is numeric. If it is,output is 1; if it is not, output is 0.","description_html":"\u003cp\u003eDetermine if input is numeric. If it is,output is 1; if it is not, output is 0.\u003c/p\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = 'a';\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n%%\r\nx = isreal(i);\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":1321,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":531,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-04-25T18:56:35.000Z","updated_at":"2026-02-18T14:34:21.000Z","published_at":"2013-04-25T18:56: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\",\"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\u003eDetermine if input is numeric. If it is,output is 1; if it is not, output is 0.\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":3,"title":"Find the sum of all the numbers of the input vector","description":"Find the sum of all the numbers of the input vector x. \r\n\r\n Examples:\r\n\r\n  Input  x = [1 2 3 5]\r\n  Output y is 11\r\n\r\n  Input  x = [42 -1]\r\n  Output y is 41\r\n ","description_html":"\u003cp\u003eFind the sum of all the numbers of the input vector x.\u003c/p\u003e\u003cpre\u003e Examples:\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eInput  x = [1 2 3 5]\r\nOutput y is 11\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eInput  x = [42 -1]\r\nOutput y is 41\r\n\u003c/pre\u003e","function_template":"function y = vecsum(x)\r\n   y = x\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(vecsum(x),y_correct))\r\n\r\n%%\r\nx = [1 2 3 5];\r\ny_correct = 11;\r\nassert(isequal(vecsum(x),y_correct))\r\n\r\n%%\r\nx = [1 2 3 5];\r\ny_correct = 11;\r\nassert(isequal(vecsum(x),y_correct))\r\n\r\n%%\r\nx = 1:100;\r\ny_correct = 5050;\r\nassert(isequal(vecsum(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":343,"comments_count":85,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54193,"test_suite_updated_at":"2013-07-17T17:49:37.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:17.000Z","updated_at":"2026-04-05T08:18:19.000Z","published_at":"2012-01-18T01:00:17.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\u003eFind the sum of all the numbers of the input vector x.\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[ Examples:\\n\\nInput  x = [1 2 3 5]\\nOutput y is 11\\n\\nInput  x = [42 -1]\\nOutput y is 41]]\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":1838,"title":"Min of a Matrix","description":"Return the minimum value in the given matrix.","description_html":"\u003cp\u003eReturn the minimum value in the given matrix.\u003c/p\u003e","function_template":"function y = matrixMin(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 2 3; 4 5 6; 7 8 9;];\r\ny_correct = 1;\r\nassert(isequal(matrixMin(x),y_correct))\r\n\r\n%%\r\nx = [42 35 18 9; 28 92 11 444; 8 12 9 111];\r\ny_correct = 8;\r\nassert(isequal(matrixMin(x),y_correct));\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":1,"created_by":16420,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":759,"test_suite_updated_at":"2013-08-19T18:54:37.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-08-19T18:50:01.000Z","updated_at":"2026-02-24T00:54:24.000Z","published_at":"2013-08-19T18:50:00.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\u003eReturn the minimum value in the given matrix.\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":44623,"title":"Basic matlab numeric and string manipulations","description":"If entered input (n) is _numeric_ , compute its *log to the base (n+2)* , \r\n\r\nif it is a _lower case_ alphabet, *convert it to its numeric ascii value* , \r\n\r\nif it is an upper case character, create a string with '!' *concatenated* to the value 'n'\r\nExample: 'A' will become 'A!'\r\n\r\nelse return the input as is","description_html":"\u003cp\u003eIf entered input (n) is \u003ci\u003enumeric\u003c/i\u003e , compute its \u003cb\u003elog to the base (n+2)\u003c/b\u003e ,\u003c/p\u003e\u003cp\u003eif it is a \u003ci\u003elower case\u003c/i\u003e alphabet, \u003cb\u003econvert it to its numeric ascii value\u003c/b\u003e ,\u003c/p\u003e\u003cp\u003eif it is an upper case character, create a string with '!' \u003cb\u003econcatenated\u003c/b\u003e to the value 'n'\r\nExample: 'A' will become 'A!'\u003c/p\u003e\u003cp\u003eelse return the input as is\u003c/p\u003e","function_template":"function y = manipulate(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 'p';\r\ny_correct = 112;\r\nassert(isequal(manipulate(x),y_correct))\r\n\r\n%%\r\nx = 5;\r\ny_correct = log(x)/log(7);\r\nassert(isequal(manipulate(x),y_correct))\r\n\r\n%%\r\nx = 'A';\r\ny_correct = 'A!';\r\nassert(isequal(manipulate(x),y_correct))\r\n\r\n%%\r\nx = '!';\r\ny_correct = '!';\r\nassert(isequal(manipulate(x),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":41,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-21T04:14:55.000Z","updated_at":"2026-03-04T14:29:39.000Z","published_at":"2018-04-21T04:14:55.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eIf entered input (n) is\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\u003enumeric\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e , compute its\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\u003elog to the base (n+2)\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\u003eif it is 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:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003elower case\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e alphabet,\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\u003econvert it to its numeric ascii value\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\u003eif it is an upper case character, create a string with '!'\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\u003econcatenated\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e to the value 'n' Example: 'A' will become '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\u003eelse return the input as is\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":44707,"title":"Raise each element to the power of its index in a matrix","description":"In a matrix, A = [1,2;3,4]\r\nraise the power of each element like: 1^1+2^3+3^2+4^4 and add it all to produce the result 274\r\n\r\n","description_html":"\u003cp\u003eIn a matrix, A = [1,2;3,4]\r\nraise the power of each element like: 1^1+2^3+3^2+4^4 and add it all to produce the result 274\u003c/p\u003e","function_template":"function y = matrix_pow(x)\r\n\r\nend","test_suite":"%%\r\nx = [1,2;3,4];\r\ny_correct = 274;\r\nassert(isequal(matrix_pow(x),y_correct))\r\n\r\n%%\r\nx = [1 7 8 -9];\r\ny_correct = 7123;\r\nassert(isequal(matrix_pow(x),y_correct))\r\n\r\n%%\r\nx = eye(3).*8;\r\ny_correct = 134250504;\r\nassert(isequal(matrix_pow(x),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-03T09:00:18.000Z","updated_at":"2026-02-18T14:10:57.000Z","published_at":"2018-08-03T09:18:08.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\u003eIn a matrix, A = [1,2;3,4] raise the power of each element like: 1^1+2^3+3^2+4^4 and add it all to produce the result 274\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":44635,"title":"Repetition of matrices","description":"*A is a bold matrix: [1 2 3; 4 5 6;7 8 9]*\r\n\r\nGiven an integer 'n' , a matrix B exists such that has n copies of A in the row and column dimensions\r\n\r\nexample:\r\nfor n=2; B= [A A; A A]\r\n\r\nFor such a matrix B return the sum of all elements multiplied by the size of B i.e. \r\n\r\n  C=sum (all elements of B) * size(B)\r\n\r\n* _Kindly note you will have to make the matrix A yourself_ *","description_html":"\u003cp\u003e\u003cb\u003eA is a bold matrix: [1 2 3; 4 5 6;7 8 9]\u003c/b\u003e\u003c/p\u003e\u003cp\u003eGiven an integer 'n' , a matrix B exists such that has n copies of A in the row and column dimensions\u003c/p\u003e\u003cp\u003eexample:\r\nfor n=2; B= [A A; A A]\u003c/p\u003e\u003cp\u003eFor such a matrix B return the sum of all elements multiplied by the size of B i.e.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eC=sum (all elements of B) * size(B)\r\n\u003c/pre\u003e\u003cul\u003e\u003cli\u003e\u003ci\u003eKindly note you will have to make the matrix A yourself\u003c/i\u003e *\u003c/li\u003e\u003c/ul\u003e","function_template":"function C = matrix_rep(n)\r\n  y = x;\r\nend","test_suite":"%%\r\nn = 2;\r\nC_correct = [1080,1080];\r\nassert(isequal(matrix_rep(n),C_correct))\r\n\r\n%%\r\nn = 5;\r\nC_correct = [16875,16875];\r\nassert(isequal(matrix_rep(n),C_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":58,"test_suite_updated_at":"2018-05-09T11:43:47.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-09T11:42:39.000Z","updated_at":"2026-03-05T11:04:40.000Z","published_at":"2018-05-09T11:42:39.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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eA is a bold matrix: [1 2 3; 4 5 6;7 8 9]\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 an integer 'n' , a matrix B exists such that has n copies of A in the row and column dimensions\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: for n=2; B= [A A; A 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\u003eFor such a matrix B return the sum of all elements multiplied by the size of B i.e.\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=sum (all elements of B) * size(B)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eKindly note you will have to make the matrix A yourself\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\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":44665,"title":"Percentage of zeros in a matrix of only 1s and 0s","description":"Write a function called _zero_stat_ that takes a matrix as an input that only has 0 and 1 elements. The function needs to compute and return the percentage of 0 elements in the matrix. For example, if there are 10 zeros and 15 ones in a 5-by-5 matrix that is provided as an input to zero_stat, it would return 40 because 40% of the elements are zero.\r\n*Please return the answer rounded to the nearest integer*","description_html":"\u003cp\u003eWrite a function called \u003ci\u003ezero_stat\u003c/i\u003e that takes a matrix as an input that only has 0 and 1 elements. The function needs to compute and return the percentage of 0 elements in the matrix. For example, if there are 10 zeros and 15 ones in a 5-by-5 matrix that is provided as an input to zero_stat, it would return 40 because 40% of the elements are zero. \u003cb\u003ePlease return the answer rounded to the nearest integer\u003c/b\u003e\u003c/p\u003e","function_template":"function pct_zero = zero_stat(inp_matrix)\r\nend","test_suite":"%%\r\ninp_matrix = [1,0,0,1,1;0,1,1,0,0;0,0,0,0,0;1,1,1,1,1;1,1,1,1,1];\r\npct_zero_corr = 40;\r\nassert(isequal(zero_stat(inp_matrix),pct_zero_corr))\r\n\r\n%%\r\ninp_matrix = diag([1,0,1,1,1]);\r\npct_zero_corr = 84;\r\nassert(isequal(zero_stat(inp_matrix),pct_zero_corr))\r\n\r\n%%\r\ninp_matrix = [1,0,1,0,0,0,1]';\r\npct_zero_corr = 57;\r\nassert(isequal(zero_stat(inp_matrix),pct_zero_corr))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":66,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T15:29:49.000Z","updated_at":"2026-04-02T10:26:58.000Z","published_at":"2018-05-29T15:29: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\",\"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 called\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\u003ezero_stat\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e that takes a matrix as an input that only has 0 and 1 elements. The function needs to compute and return the percentage of 0 elements in the matrix. For example, if there are 10 zeros and 15 ones in a 5-by-5 matrix that is provided as an input to zero_stat, it would return 40 because 40% of the elements are zero.\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\u003ePlease return the answer rounded to the nearest integer\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":44660,"title":"Perimeter of a semicircle","description":"Given the diameter d, find the perimeter of a semicircle","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: 21px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 10.5px; transform-origin: 407px 10.5px; 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 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 172.5px 8px; transform-origin: 172.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven the diameter d, find the perimeter of a semicircle\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = perm_semicircle(d)\r\n  d\r\nend","test_suite":"%%\r\nd = 20;\r\ny_correct = 51.4159265358979;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)\r\n\r\n%%\r\nd = 42;\r\ny_correct = 107.973445725386;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)\r\n\r\n%%\r\nd = 50;\r\ny_correct = 128.539816339745;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)\r\n\r\n%%\r\nd = 100;\r\ny_correct = 257.07963267949;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)\r\n\r\n%%\r\nd = 135;\r\ny_correct = 347.057504117311;\r\nassert(abs(perm_semicircle(d) - y_correct) \u003c 1e-10)","published":true,"deleted":false,"likes_count":10,"comments_count":3,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":2178,"test_suite_updated_at":"2021-08-03T16:46:04.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T14:09:07.000Z","updated_at":"2026-04-04T17:46:02.000Z","published_at":"2018-05-29T14:09:07.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven the diameter d, find the perimeter of a semicircle\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":44618,"title":"surface areas of a cylinder","description":"There are 3 inputs: option, radius and height. If option= '1', compute the lateral surface area of the cylinder, for option 2 calculate the total surface area of the cylinder. For any other option, compute the total area of both flat sides of the cylinder.","description_html":"\u003cp\u003eThere are 3 inputs: option, radius and height. If option= '1', compute the lateral surface area of the cylinder, for option 2 calculate the total surface area of the cylinder. For any other option, compute the total area of both flat sides of the cylinder.\u003c/p\u003e","function_template":"function y = surface_area_cyl(optn,r,h)\r\n  y = r*h;\r\nend","test_suite":"%%\r\noptn=1;\r\nr=3;\r\nh=6;\r\ny_correct = 36*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=5;\r\nr=3;\r\nh=6;\r\ny_correct = 18*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=2;\r\nr=2;\r\nh=2;\r\ny_correct = 16*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=0;\r\nr=5;\r\nh=10;\r\ny_correct = 50*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=1;\r\nr=5;\r\nh=10;\r\ny_correct = 100*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=2;\r\nr=5;\r\nh=10;\r\ny_correct = 150*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=42;\r\nr=3;\r\nh=7;\r\ny_correct = 18*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=2;\r\nr=3\r\nh=7;\r\ny_correct = 60*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n\r\n%%\r\noptn=1;\r\nr=3;\r\nh=7;\r\ny_correct = 42*pi;\r\nassert(isequal(surface_area_cyl(optn,r,h),y_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":"2018-07-16T16:54:54.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-04-20T05:49:29.000Z","updated_at":"2026-04-03T06:59:13.000Z","published_at":"2018-04-20T05:49: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\",\"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\u003eThere are 3 inputs: option, radius and height. If option= '1', compute the lateral surface area of the cylinder, for option 2 calculate the total surface area of the cylinder. For any other option, compute the total area of both flat sides of the cylinder.\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":2114,"title":"Factorial Numbers ","description":"Factorial is multiplication of integers. So factorial of 6 is\r\n 720 = 1 * 2 * 3 * 4* 5 *6\r\n\r\nThus 6 factorial  = factorial(720). Given n, return t, the factorial number for n.\r\n\r\nExample: Input n = 6 Output t is 720\r\n","description_html":"\u003cp\u003eFactorial is multiplication of integers. So factorial of 6 is\r\n 720 = 1 * 2 * 3 * 4* 5 *6\u003c/p\u003e\u003cp\u003eThus 6 factorial  = factorial(720). Given n, return t, the factorial number for n.\u003c/p\u003e\u003cp\u003eExample: Input n = 6 Output t is 720\u003c/p\u003e","function_template":"function t = factorial(n)\r\n  t = n;\r\nend\r\n","test_suite":"%%\r\nn = 1;\r\nt = 1;\r\nassert(isequal(factorial(n),t))\r\n%%\r\nn = 2;\r\nt = 2;\r\nassert(isequal(factorial(n),t))\r\n%%\r\nn = 3;\r\nt = 6;\r\nassert(isequal(factorial (n),t))\r\n%%\r\nn = 6;\r\nt = 720;","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":21325,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":447,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2014-01-13T16:39:00.000Z","updated_at":"2026-04-02T10:43:25.000Z","published_at":"2014-01-13T16:39:33.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\u003eFactorial is multiplication of integers. So factorial of 6 is 720 = 1 * 2 * 3 * 4* 5 *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\u003eThus 6 factorial = factorial(720). Given n, return t, the factorial number for n.\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: Input n = 6 Output t is 720\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":44661,"title":"Remove white spaces at the end of the input string","description":"Remove all trailing white spaces at the end of the input strings","description_html":"\u003cp\u003eRemove all trailing white spaces at the end of the input strings\u003c/p\u003e","function_template":"function y = rem_trail_ws(A)\r\n  A\r\nend","test_suite":"%%\r\nA = 'This is a test string.             ';\r\ny_correct = 'This is a test string.';\r\nassert(isequal(rem_trail_ws(A),y_correct))\r\n\r\n%%\r\nA = '          Testing function rem_trail_ws';\r\ny_correct = '          Testing function rem_trail_ws';\r\nassert(isequal(rem_trail_ws(A),y_correct))\r\n\r\n%%\r\nA = {'MATLAB    ','SIMULINK    ';\r\n     'Toolboxes    ','MathWorks    '};\r\ny_correct = {'MATLAB','SIMULINK';\r\n     'Toolboxes','MathWorks'};\r\nassert(isequal(rem_trail_ws(A),y_correct))\r\n\r\n%%\r\nA = sprintf('MATHWORKS \\t');\r\ny_correct = 'MATHWORKS';\r\nassert(isequal(rem_trail_ws(A),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":54,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2018-05-29T14:21:22.000Z","updated_at":"2025-12-07T18:25:49.000Z","published_at":"2018-05-29T14:21:22.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\u003eRemove all trailing white spaces at the end of the input strings\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":42801,"title":"means","description":"Calculate the arithmetic, the geometric and the harmonic mean of a given vector (with positive elements) and return them in a vector!","description_html":"\u003cp\u003eCalculate the arithmetic, the geometric and the harmonic mean of a given vector (with positive elements) and return them in a vector!\u003c/p\u003e","function_template":"function y = means(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1];\r\ny_correct = [1,1,1];\r\nassert(isequal(means(x),y_correct))\r\n\r\n%%\r\nx = [1,4];\r\ny_correct = [2.5,2,8/5];\r\nassert(isequal(means(x),y_correct))\r\n\r\n%%\r\nx = 1:10;\r\ny = means(x);\r\ny_correct = [5.5,nthroot(3628800,10),25200/7381];\r\nfor i = 1:3\r\n assert(abs(y(i)-y_correct(i))\u003c1e-4)\r\nend\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":4,"created_by":73322,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":64,"test_suite_updated_at":"2018-07-24T20:23:10.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2016-04-15T14:30:45.000Z","updated_at":"2025-12-07T20:59:17.000Z","published_at":"2016-04-15T14:30:45.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\u003eCalculate the arithmetic, the geometric and the harmonic mean of a given vector (with positive elements) and return them in a vector!\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":42818,"title":"center of mass","description":"R is a given matrix with size [n,2]. R(i,:) is interpreted as the 2D-position of a mass point with mass i. Calculate the center of mass of all mass points proposed by R. ","description_html":"\u003cp\u003eR is a given matrix with size [n,2]. R(i,:) is interpreted as the 2D-position of a mass point with mass i. Calculate the center of mass of all mass points proposed by R.\u003c/p\u003e","function_template":"function [X,Y] = center_of_mass(R)\r\nX=0;\r\nY=0;\r\nend\r\n","test_suite":"%%\r\nR=[0,0];\r\nX_correct = 0;\r\nY_correct = 0;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);\r\n\r\n%%\r\nR=[0,0;1,1];\r\nX_correct = 2/3;\r\nY_correct = 2/3;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);\r\n\r\n%%\r\nR=[0,0;0,4];\r\nX_correct = 0;\r\nY_correct = 8/3;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);\r\n\r\n%%\r\nR=[1:10;1:10]';\r\nX_correct = 7;\r\nY_correct = 7;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);\r\n\r\n%%\r\nR=[10:(-1):1;0:9]'\r\nX_correct = 4;\r\nY_correct = 6;\r\n[X,Y]=center_of_mass(R);\r\nassert(X==X_correct\u0026Y==Y_correct);","published":true,"deleted":false,"likes_count":3,"comments_count":4,"created_by":73322,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":90,"test_suite_updated_at":"2016-06-20T13:23:20.000Z","rescore_all_solutions":true,"group_id":1,"created_at":"2016-04-24T07:51:53.000Z","updated_at":"2026-02-13T20:02:09.000Z","published_at":"2016-04-24T07:51: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\",\"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\u003eR is a given matrix with size [n,2]. R(i,:) is interpreted as the 2D-position of a mass point with mass i. Calculate the center of mass of all mass points proposed by R.\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":44730,"title":"Substring Extraction","description":"In a given string, find the substring between Start_string and End_string. \r\n\r\nYou will have to include or exclude the Start_string and End_string as a part of the substring depending on the third argument 'include_se'\r\n\r\nIf include_se=1, include the Start_string and End_string as a part of the extracted substring, else exclude them\r\n\r\nExample: \r\n\r\n  input_str: 'This is a test sentence'\r\n  Start_string: 'is'\r\n  End_string: 'sentence'\r\n  include_se=1\r\n  extract_function(input_str,Start_string,End_string, include_se)= 'is a test sentence'\r\n","description_html":"\u003cp\u003eIn a given string, find the substring between Start_string and End_string.\u003c/p\u003e\u003cp\u003eYou will have to include or exclude the Start_string and End_string as a part of the substring depending on the third argument 'include_se'\u003c/p\u003e\u003cp\u003eIf include_se=1, include the Start_string and End_string as a part of the extracted substring, else exclude them\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003einput_str: 'This is a test sentence'\r\nStart_string: 'is'\r\nEnd_string: 'sentence'\r\ninclude_se=1\r\nextract_function(input_str,Start_string,End_string, include_se)= 'is a test sentence'\r\n\u003c/pre\u003e","function_template":"function output_str = extract_function(input_str,Start_string,End_string, include_se)\r\n\r\nend","test_suite":"%%\r\ninput_str= 'This is a test sentence'\r\nStart_string= ' is'\r\nEnd_string= 'sentence'\r\ninclude_se=1\r\noutput_str= {' is a test sentence'}\r\nassert(isequal(extract_function(input_str,Start_string,End_string, include_se),output_str))\r\n\r\n%%\r\ninput_str= 'This is a test sentence'\r\nStart_string= ' is'\r\nEnd_string= 'sentence'\r\ninclude_se=0\r\noutput_str={' a test '}\r\nassert(isequal(extract_function(input_str,Start_string,End_string, include_se),output_str))\r\n\r\n%%\r\ninput_str= 'Right now!I said RIGHT NOW!'\r\nStart_string= 'now!'\r\nEnd_string= '!'\r\ninclude_se=0\r\noutput_str={'I said RIGHT NOW'}\r\nassert(isequal(extract_function(input_str,Start_string,End_string, include_se),output_str))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":171559,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":31,"test_suite_updated_at":"2018-08-16T12:54:54.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2018-08-16T12:52:30.000Z","updated_at":"2025-12-29T13:54:03.000Z","published_at":"2018-08-16T12:52:30.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\u003eIn a given string, find the substring between Start_string and End_string.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will have to include or exclude the Start_string and End_string as a part of the substring depending on the third argument 'include_se'\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 include_se=1, include the Start_string and End_string as a part of the extracted substring, else exclude them\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_str: 'This is a test sentence'\\nStart_string: 'is'\\nEnd_string: 'sentence'\\ninclude_se=1\\nextract_function(input_str,Start_string,End_string, include_se)= 'is a test sentence']]\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":42646,"title":"Matrix FUN","description":"Given a Matrix M, find out the number of elements of matrix that are divisible by 3.\r\n\r\n  \r\n    M = [1 2 3;4 5 6;7 8 9];\r\n    out = 3\r\n\r\n    M = [32 12 15; 2 6 45];\r\n    out = 4\r\n ","description_html":"\u003cp\u003eGiven a Matrix M, find out the number of elements of matrix that are divisible by 3.\u003c/p\u003e\u003cpre\u003e    M = [1 2 3;4 5 6;7 8 9];\r\n    out = 3\u003c/pre\u003e\u003cpre\u003e    M = [32 12 15; 2 6 45];\r\n    out = 4\u003c/pre\u003e","function_template":"function y = mat_fun(m)\r\n  y = x; %think and solve\r\nend","test_suite":"%%\r\nx = 4;\r\ny_correct = 0;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = [3 2 3 2 5 6 2 1 2];\r\ny_correct = 3;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = [999 999 999 2 15 6];\r\ny_correct = 5;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = 3:3:999;\r\ny_correct = 333;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = [1 2 3 4 5 6;6 5 4 3 2 1];\r\ny_correct = 4;\r\nassert(isequal(mat_fun(x),y_correct))\r\n%%\r\nx = [7 8 11 13 14 17];\r\ny_correct = 0;\r\nassert(isequal(mat_fun(x),y_correct))\r\n\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":44015,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":165,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2015-10-03T05:59:11.000Z","updated_at":"2026-03-23T15:33:33.000Z","published_at":"2015-10-03T06:00:26.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 Matrix M, find out the number of elements of matrix that are divisible by 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[    M = [1 2 3;4 5 6;7 8 9];\\n    out = 3\\n\\n    M = [32 12 15; 2 6 45];\\n    out = 4]]\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":233,"title":"Reverse the vector","description":"Reverse the vector elements.\r\n\r\nExample:\r\n\r\n Input  x = [1,2,3,4,5,6,7,8,9] \r\n Output y = [9,8,7,6,5,4,3,2,1]","description_html":"\u003cp\u003eReverse the vector elements.\u003c/p\u003e\u003cp\u003eExample:\u003c/p\u003e\u003cpre\u003e Input  x = [1,2,3,4,5,6,7,8,9] \r\n Output y = [9,8,7,6,5,4,3,2,1]\u003c/pre\u003e","function_template":"function y = reverseVector(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(reverseVector(x),y_correct))\r\n\r\n%%\r\nx = -10:1;\r\ny_correct = 1:-1:-10;\r\nassert(isequal(reverseVector(x),y_correct))\r\n\r\n%%\r\nx = 'able was i ere i saw elba';\r\ny_correct = 'able was i ere i saw elba';\r\nassert(isequal(reverseVector(x),y_correct))\r\n","published":true,"deleted":false,"likes_count":55,"comments_count":9,"created_by":868,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":16481,"test_suite_updated_at":"2016-10-23T02:09:16.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-02T15:28:45.000Z","updated_at":"2026-04-04T14:45:17.000Z","published_at":"2012-02-02T20:11:32.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\u003eReverse the vector elements.\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  x = [1,2,3,4,5,6,7,8,9] \\n Output y = [9,8,7,6,5,4,3,2,1]]]\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":44408,"title":"ゼロでない要素が一番多い行を探そう","description":"行列 a が与えられたとき、行列 a の中で一番ゼロの要素が少ない行のインデクス r を返す関数を作成しましょう。このとき、行列 a には一つだけしかこの条件に当てはまる行がないと仮定します。\r\n\r\n例:\r\n\r\n 入力として、行列  \r\n a = [ 1 2 0 0 0\r\n       0 0 5 0 0 \r\n       2 7 0 0 0\r\n       0 6 9 3 3 ]\r\n が与えられたとき、出力 r は 4 を返します。\r\n\r\n* (英語版) Problem 32. Most nonzero elements in row\r\n\u003chttps://www.mathworks.com/matlabcentral/cody/problems/32\u003e","description_html":"\u003cp\u003e行列 a が与えられたとき、行列 a の中で一番ゼロの要素が少ない行のインデクス r を返す関数を作成しましょう。このとき、行列 a には一つだけしかこの条件に当てはまる行がないと仮定します。\u003c/p\u003e\u003cp\u003e例:\u003c/p\u003e\u003cpre\u003e 入力として、行列  \r\n a = [ 1 2 0 0 0\r\n       0 0 5 0 0 \r\n       2 7 0 0 0\r\n       0 6 9 3 3 ]\r\n が与えられたとき、出力 r は 4 を返します。\u003c/pre\u003e\u003cul\u003e\u003cli\u003e(英語版) Problem 32. Most nonzero elements in row \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/32\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/32\u003c/a\u003e\u003c/li\u003e\u003c/ul\u003e","function_template":"function r = fullest_row(a)\r\n  r = 1\r\nend","test_suite":"%%\r\na = [ ...\r\n 1 2 0 0 0\r\n 0 0 5 0 0 \r\n 2 7 0 0 0\r\n 0 6 9 3 3];\r\nr_correct = 4;\r\nassert(isequal(fullest_row(a),r_correct))\r\n\r\n%%\r\na = [ ...\r\n1 2 0 0 \r\n 0 0 5 0  \r\n 0 6 9 -3\r\n 2 7 0 0 \r\n 0 0 0 0];\r\nr_correct = 3;\r\nassert(isequal(fullest_row(a),r_correct))\r\n%%\r\na = [ ...\r\n 1 0 0 \r\n 0 0 0  \r\n 0 0 0\r\n 0 0 0 \r\n 0 2 3];\r\nr_correct = 5;\r\nassert(isequal(fullest_row(a),r_correct))\r\n%%\r\na = [ ...\r\n 0 \r\n 0  \r\n 0\r\n -3\r\n 0 \r\n 0];\r\nr_correct = 4;\r\nassert(isequal(fullest_row(a),r_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":0,"created_by":11824,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":345,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":36,"created_at":"2017-11-14T23:35:31.000Z","updated_at":"2026-03-18T03:46:35.000Z","published_at":"2017-11-14T23:35:31.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e行列 a が与えられたとき、行列 a の中で一番ゼロの要素が少ない行のインデクス r を返す関数を作成しましょう。このとき、行列 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\u003e例:\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[ 入力として、行列  \\n a = [ 1 2 0 0 0\\n       0 0 5 0 0 \\n       2 7 0 0 0\\n       0 6 9 3 3 ]\\n が与えられたとき、出力 r は 4 を返します。]]\u003e\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(英語版) Problem 32. Most nonzero elements in row\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/32\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/32\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;\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":262,"title":"Swap the input arguments","description":"Write a two-input, two-output function that swaps its two input arguments. For example:\r\n\r\n   [q,r] = swap(5,10)\r\n\r\nreturns q = 10 and r = 5.","description_html":"\u003cp\u003eWrite a two-input, two-output function that swaps its two input arguments. For example:\u003c/p\u003e\u003cpre\u003e   [q,r] = swap(5,10)\u003c/pre\u003e\u003cp\u003ereturns q = 10 and r = 5.\u003c/p\u003e","function_template":"function [q,r] = swapInputs(a,b)\r\n  [q,r] = cart2pol(a,b);\r\nend","test_suite":"%%\r\n[q,r] = swapInputs(5,10);\r\nassert(isequal(q,10));\r\nassert(isequal(r,5));\r\n\r\n%%\r\n[q,r] = swapInputs(magic(3), 'hello, world');\r\nassert(isequal(q,'hello, world'));\r\nassert(isequal(r,magic(3)));\r\n\r\n%%\r\n[q,r] = swapInputs({}, NaN);\r\nassert(isnan(q));\r\nassert(iscell(r) \u0026\u0026 isempty(r));\r\n","published":true,"deleted":false,"likes_count":76,"comments_count":11,"created_by":4303371,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":13325,"test_suite_updated_at":"2012-02-05T05:04:01.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-05T05:04:01.000Z","updated_at":"2026-04-04T14:50:54.000Z","published_at":"2012-02-05T05:04:30.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 two-input, two-output function that swaps its two input arguments. 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[   [q,r] = swap(5,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\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ereturns q = 10 and r = 5.\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":589,"title":"Matrix indexing with two vectors of indices","description":"Given a matrix M and two index vectors a and b, return a row vector x where x(i) = M(a(i),b(i)).","description_html":"\u003cp\u003eGiven a matrix M and two index vectors a and b, return a row vector x where x(i) = M(a(i),b(i)).\u003c/p\u003e","function_template":"function v = twoIndex(M,a,b)\r\n  v = M;\r\nend","test_suite":"%%\r\nM = rand(4);\r\na = [4 3 2 1];\r\nb = [1 2 3 4];\r\nv_correct = M([4 7 10 13]);\r\nassert(isequal(twoIndex(M,a,b),v_correct))\r\n\r\n%%\r\nM = rand(4);\r\na = [3 3 1 3];\r\nb = [1 1 3 1];\r\nv_correct = M([3 3 9 3]);\r\nassert(isequal(twoIndex(M,a,b),v_correct))\r\n\r\n%%\r\nM = rand(100);\r\n[a,b] = size(M);\r\nv_correct = M(end);\r\nassert(isequal(twoIndex(M,a,b),v_correct))\r\n\r\n%%\r\nM = rand(100);\r\na = [];\r\nb = [];\r\nassert(isempty(twoIndex(M,a,b)))\r\n\r\n%%\r\nM = 1;\r\na = [1 1 1 1 1];\r\nb = [1 1 1 1 1];\r\nv_correct = [1 1 1 1 1];\r\nassert(isequal(twoIndex(M,a,b),v_correct))\r\n","published":true,"deleted":false,"likes_count":4,"comments_count":0,"created_by":3117,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":776,"test_suite_updated_at":"2012-04-16T17:43:15.000Z","rescore_all_solutions":false,"group_id":12,"created_at":"2012-04-16T17:43:15.000Z","updated_at":"2026-04-03T18:25:24.000Z","published_at":"2012-04-16T17:43:15.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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 matrix M and two index vectors a and b, return a row vector x where x(i) = M(a(i),b(i)).\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":1702,"title":"Maximum value in a matrix","description":"Find the maximum value in the given matrix.\r\n\r\nFor example, if \r\n\r\n A = [1 2 3; 4 7 8; 0 9 1];\r\n\r\nthen the answer is 9.","description_html":"\u003cdiv style = \"text-align: start; line-height: 20px; 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: normal; text-decoration: none; white-space: normal; \"\u003e\u003cdiv style=\"display: block; min-width: 0px; padding-top: 0px; transform-origin: 332px 56px; vertical-align: baseline; perspective-origin: 332px 56px; \"\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; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFind the maximum value in the given matrix.\u003c/span\u003e\u003c/span\u003e\u003c/div\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; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor example, if\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-bottom: 10px; margin-left: 3px; margin-right: 3px; margin-top: 10px; transform-origin: 329px 10px; perspective-origin: 329px 10px; 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-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-height: 18px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"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-right: 45px; min-height: 0px; padding-left: 0px; tab-size: 4; transform-origin: 0px 0px; white-space: pre; perspective-origin: 0px 0px; margin-right: 45px; \"\u003e\u003cspan style=\"margin-right: 0px; \"\u003e A = [1 2 3; 4 7 8; 0 9 1];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 10px; text-align: left; transform-origin: 309px 10.5px; white-space: pre-wrap; perspective-origin: 309px 10.5px; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; transform-origin: 0px 0px; perspective-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003ethen the answer is 9.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = [1 2 3; 4 5 6; 7 8 9];\r\ny_correct = 9;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = -10:0;\r\ny_correct = 0;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = 17;\r\ny_correct = 17;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = magic(6);\r\ny_correct = 36;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\nx = [5 23 6 2 9 0 -1]';\r\ny_correct = 23;\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":84,"comments_count":25,"created_by":6728,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17774,"test_suite_updated_at":"2013-07-10T18:41:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-07-09T04:08:24.000Z","updated_at":"2026-04-05T08:23:56.000Z","published_at":"2013-07-09T04:08:24.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFind the maximum value in the given matrix.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example, if\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 2 3; 4 7 8; 0 9 1];]]\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\u003ethen the answer is 9.\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":584,"title":"middleAsColumn:  Return all but first and last element as a column vector","description":"Given input A, return all but the first and last elements, arranged as a column vector.  (I.e., all dimensions after the first should be singleton.)\r\n\r\nFor example,\r\n\r\n  \u003e\u003e middleAsColumn(eye(3))\r\nans =\r\n     0\r\n     0\r\n     0\r\n     1\r\n     0\r\n     0\r\n     0","description_html":"\u003cp\u003eGiven input A, return all but the first and last elements, arranged as a column vector.  (I.e., all dimensions after the first should be singleton.)\u003c/p\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u003e\u003e middleAsColumn(eye(3))\r\nans =\r\n   0\r\n   0\r\n   0\r\n   1\r\n   0\r\n   0\r\n   0\r\n\u003c/pre\u003e","function_template":"function y = middleAsColumn(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = zeros(0,1);\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n%%\r\nx = rand(1,4);\r\ny_correct = x(2:3)';\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n\r\n%%\r\nx = rand(4,1);\r\ny_correct = x(2:3);\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n%%\r\nx = rand(2,2);\r\ny_correct = x(2:3)';\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n%%\r\nx = {1 2 3 4};\r\ny_correct = x(2:3)';\r\nassert(isequal(middleAsColumn(x),y_correct))\r\n\r\n%%\r\nx = struct('a',{1 2 3 4},'b',{3 4 5 6});\r\ny_correct = x(2:3)';\r\nassert(isequal(middleAsColumn(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":3117,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":647,"test_suite_updated_at":"2012-04-13T21:04:38.000Z","rescore_all_solutions":false,"group_id":12,"created_at":"2012-04-13T21:04:38.000Z","updated_at":"2026-02-10T12:57:51.000Z","published_at":"2012-04-13T21:04:38.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 input A, return all but the first and last elements, arranged as a column vector. (I.e., all dimensions after the first should be singleton.)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[\u003e\u003e middleAsColumn(eye(3))\\nans =\\n   0\\n   0\\n   0\\n   1\\n   0\\n   0\\n   0]]\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":46588,"title":"i was a mistake","description":null,"description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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=\"block-size: 71.7188px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.989px 35.8523px; transform-origin: 406.996px 35.8594px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 41.8182px; 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.991px 20.9091px; text-align: left; transform-origin: 383.999px 20.9091px; 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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYou start with a Function Template that is only two characters away from working properly. The math itself is fairly simple. The actual problem is understanding the purpose of the function despite the somewhat criminal coding style.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.9091px; 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.991px 10.4545px; text-align: left; transform-origin: 383.999px 10.4545px; 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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYou can pick some ideas to improve your own style \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/fileexchange/46056-matlab-style-guidelines-2-0\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003ehere\u003c/span\u003e\u003c/span\u003e\u003c/a\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function s = ihaveaproblem(a,b,n)\r\n    global i % i is a global variable\r\n    z = a + b*i; % i is an imaginary number\r\n    clear i % i is no longer a global variable\r\n    s = 0;\r\n    for i = 1:n % i for for index\r\n        s = s + z^i;\r\n        i = i + 2; % i steps by 2\r\n    end\r\nend","test_suite":"global i % i for i\r\ni = 1i;\r\n\r\n%%\r\n\r\na = 1;\r\nb = 0;\r\nn = 1;\r\n\r\ns_correct = 1;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 1;\r\nb = 0;\r\nn = 2;\r\n\r\ns_correct = 1;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 1;\r\nb = 0;\r\nn = 3;\r\n\r\ns_correct = 2;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 0;\r\nb = 1;\r\nn = 1;\r\n\r\ns_correct = 1i;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 1;\r\nb = 1;\r\nn = 8;\r\n\r\ns_correct = 3 - 9i;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n\r\n%%\r\n\r\na = 2;\r\nb = 1;\r\nn = 6;\r\n\r\ns_correct = -34 + 53i;\r\nassert(isequal(ihaveaproblem(a,b,n),s_correct))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":1,"created_by":543257,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":17,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-09-15T17:50:42.000Z","updated_at":"2026-03-13T12:16:16.000Z","published_at":"2020-09-16T01:52:51.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 start with a Function Template that is only two characters away from working properly. The math itself is fairly simple. The actual problem is understanding the purpose of the function despite the somewhat criminal coding style.\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 can pick some ideas to improve your own style \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/fileexchange/46056-matlab-style-guidelines-2-0\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehere\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":6,"title":"Select every other element of a vector","description":"Write a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, starting with the first.\r\nExamples:\r\n Input  x = [1 3 2 4 3 5]\r\n Output y is [1 2 3]\r\n\r\n Input  x = [5 9 3 2 2 0 -1]\r\n Output y is [5 3 2 -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: 184.167px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 92.0833px; transform-origin: 407px 92.0833px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 361.5px 8px; transform-origin: 361.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, starting with the first.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 32px 8px; transform-origin: 32px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExamples:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 102.167px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 51.0833px; transform-origin: 404px 51.0833px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 100px 8.5px; tab-size: 4; transform-origin: 100px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 68px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 68px 8.5px; \"\u003ex = [1 3 2 4 3 5]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 80px 8.5px; tab-size: 4; transform-origin: 80px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 48px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 48px 8.5px; \"\u003ey is [1 2 3]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 0px 8.5px; tab-size: 4; transform-origin: 0px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 112px 8.5px; tab-size: 4; transform-origin: 112px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 80px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 80px 8.5px; \"\u003ex = [5 9 3 2 2 0 -1]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 92px 8.5px; tab-size: 4; transform-origin: 92px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 32px 8.5px; transform-origin: 32px 8.5px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 60px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 60px 8.5px; \"\u003ey is [5 3 2 -1]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = everyOther(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('everyOther.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp'); \r\nassert(~illegal)\r\n\r\n%%\r\nx = rand(1,1);\r\nactual = everyOther(x);\r\nassert(isequal(actual, x))\r\n\r\n%%\r\nx = rand(1,10);\r\nactual = everyOther(x);\r\nexpected = [x(1) x(3) x(5) x(7) x(9)];\r\nassert(isequal(actual, expected))\r\n\r\n%%\r\nx = rand(1,100);\r\nactual = everyOther(x);\r\nexpected = [x(1) x(3) x(5) x(7) x(9) x(11) x(13) x(15) x(17) x(19) ...\r\n    x(21) x(23) x(25) x(27) x(29) x(31) x(33) x(35) x(37) x(39) ...\r\n    x(41) x(43) x(45) x(47) x(49) x(51) x(53) x(55) x(57) x(59) ...\r\n    x(61) x(63) x(65) x(67) x(69) x(71) x(73) x(75) x(77) x(79) ...\r\n    x(81) x(83) x(85) x(87) x(89) x(91) x(93) x(95) x(97) x(99)];\r\nassert(isequal(actual, expected))\r\n\r\n%%\r\nx = ['A' 'long' 'time' 'ago' 'in' 'a' 'galaxy' 'far' 'far' 'away'];\r\nactual = everyOther(x);\r\nexpected = 'Aogiegiaaayafrwy';\r\nassert(isequal(actual, expected))\r\n\r\n%%\r\nx = randi(100,10,1);\r\nactual = everyOther(x);\r\nexpected = [x(1);x(3);x(5);x(7);x(9)];\r\nassert(isequal(actual, expected))\r\n\r\n%%\r\nx = primes(20)';\r\nactual = everyOther(x);\r\nexpected = [2 5 11 17]';\r\nassert(isequal(actual, expected))","published":true,"deleted":false,"likes_count":201,"comments_count":55,"created_by":1,"edited_by":223089,"edited_at":"2023-07-12T18:56:59.000Z","deleted_by":null,"deleted_at":null,"solvers_count":36374,"test_suite_updated_at":"2023-07-12T18:56:59.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:17.000Z","updated_at":"2026-04-04T14:44:06.000Z","published_at":"2012-01-18T01:00:17.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\u003eWrite a function which returns every other element of the vector passed in. That is, it returns the all odd-numbered elements, starting with the first.\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\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 = [1 3 2 4 3 5]\\n Output y is [1 2 3]\\n\\n Input  x = [5 9 3 2 2 0 -1]\\n Output y is [5 3 2 -1]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":2031,"title":"Half-Swap","description":"Given a vector with an even number of elements,\r\nrearrange it so that the elements in its first \r\nhalf are switched with those in the second half.\r\n\r\nFor example, given a vector:\r\n\r\n Vec = [23  24  6  15  15  20  22  23  9  21]\r\n\r\nwill result in\r\n\r\n Vec = [20  22  23  9  21  23  24  6  15  15]\r\n","description_html":"\u003cp\u003eGiven a vector with an even number of elements,\r\nrearrange it so that the elements in its first \r\nhalf are switched with those in the second half.\u003c/p\u003e\u003cp\u003eFor example, given a vector:\u003c/p\u003e\u003cpre\u003e Vec = [23  24  6  15  15  20  22  23  9  21]\u003c/pre\u003e\u003cp\u003ewill result in\u003c/p\u003e\u003cpre\u003e Vec = [20  22  23  9  21  23  24  6  15  15]\u003c/pre\u003e","function_template":"function y = your_fcn_name(x)\r\n  y = x;\r\nVec = ceil(6*rand(1,10)); % To test your function\r\nend","test_suite":"%%\r\n\r\nx = [15 42 91 17 7 4];\r\ny_correct = [17 7 4 15 42 91];\r\nassert(isequal(your_fcn_name(x),y_correct))\r\n\r\n%%\r\n\r\nx = [2 10];\r\ny_correct = [10 2];\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = [27 1 13 11 22 23 6 14];\r\ny_correct = [22 23 6 14 27 1 13 11];\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n%%\r\n \r\nx = [13 14 5 13 12 3 3 9 18 7 11 5 14 5];\r\ny_correct = [9 18 7 11 5 14 5 13 14 5 13 12 3 3];\r\ny = your_fcn_name(x);\r\nassert(isequal(y_correct,y))\r\n \r\n","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":16441,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":420,"test_suite_updated_at":"2013-12-04T19:57:51.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-12-02T08:08:35.000Z","updated_at":"2026-02-14T13:03:09.000Z","published_at":"2013-12-02T08:08: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\",\"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 vector with an even number of elements, rearrange it so that the elements in its first half are switched with those in the second half.\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, given a vector:\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[ Vec = [23  24  6  15  15  20  22  23  9  21]]]\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\u003ewill result 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[ Vec = [20  22  23  9  21  23  24  6  15  15]]]\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":649,"title":"Return the first and last characters of a character array","description":"Return the first and last character of a string, concatenated together. If there is only one character in the string, the function should give that character back twice since it is both the first and last character of the string.\r\n\r\nExample:\r\n\r\n   stringfirstandlast('boring example') = 'be'","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: 123.433px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 61.7167px; transform-origin: 407px 61.7167px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 63px; 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 31.5px; text-align: left; transform-origin: 384px 31.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 364px 8px; transform-origin: 364px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn the first and last characters of a character array, concatenated together. If there is only one character in the character array, the function should give that character back twice since it is both the first and last character of the character array.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 184px 8.5px; transform-origin: 184px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 88px 8.5px; transform-origin: 88px 8.5px; \"\u003e   stringfirstandlast(\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: 64px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 64px 8.5px; \"\u003e'boring example'\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 16px 8.5px; transform-origin: 16px 8.5px; \"\u003e) = \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 16px 8.5px; text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 16px 8.5px; \"\u003e'be'\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = stringfirstandlast(x)\r\n  y = x(1);\r\nend","test_suite":"%%\r\nx = 'abcde';\r\ny_correct = 'ae';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = 'a';\r\ny_correct = 'aa';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = 'codyrocks!';\r\ny_correct = 'c!';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = ' ';\r\ny_correct = '  ';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = '  ';\r\ny_correct = '  ';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = 'az';\r\ny_correct = 'az';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = 'abcdefghijklmnopqrstuvwxyz';\r\ny_correct = 'az';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = '0123456789';\r\ny_correct = '09';\r\nassert(isequal(stringfirstandlast(x),y_correct))\r\n\r\n%%\r\nx = '09';\r\ny_correct = '09';\r\nassert(isequal(stringfirstandlast(x),y_correct))","published":true,"deleted":false,"likes_count":44,"comments_count":5,"created_by":134,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11889,"test_suite_updated_at":"2021-01-20T11:13:02.000Z","rescore_all_solutions":false,"group_id":14,"created_at":"2012-05-01T18:41:40.000Z","updated_at":"2026-04-03T02:20:59.000Z","published_at":"2012-05-01T18:41:56.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\u003eReturn the first and last characters of a character array, concatenated together. If there is only one character in the character array, the function should give that character back twice since it is both the first and last character of the character 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\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[   stringfirstandlast('boring example') = 'be']]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":7,"title":"Column Removal","description":"Remove the nth column from input matrix A and return the resulting matrix in output B.\r\n\r\nSo if \r\n\r\n A = [1 2 3;\r\n      4 5 6];\r\n\r\nand \r\n\r\n n = 2 \r\n\r\nthen B is\r\n\r\n [ 1 3  \r\n   4 6 ]\r\n","description_html":"\u003cp\u003eRemove the nth column from input matrix A and return the resulting matrix in output B.\u003c/p\u003e\u003cp\u003eSo if\u003c/p\u003e\u003cpre\u003e A = [1 2 3;\r\n      4 5 6];\u003c/pre\u003e\u003cp\u003eand\u003c/p\u003e\u003cpre\u003e n = 2 \u003c/pre\u003e\u003cp\u003ethen B is\u003c/p\u003e\u003cpre\u003e [ 1 3  \r\n   4 6 ]\u003c/pre\u003e","function_template":"function B = column_removal(A,n)\r\n  B = A;\r\nend","test_suite":"%%\r\nA = [1 2 3; 4 5 6];\r\nn = 2;\r\nB_correct = [1 3; 4 6];\r\nassert(isequal(column_removal(A,n),B_correct))\r\n\r\n%%\r\nA = magic(4);\r\nn = 3;\r\nB = [16     2    13;\r\n      5    11     8;\r\n      9     7    12;\r\n      4    14     1];\r\nB_correct = B;\r\nassert(isequal(column_removal(A,n),B_correct))\r\n\r\n%%\r\nA = 1:10;\r\nn = 7;\r\nB_correct = [1 2 3 4 5 6 8 9 10];\r\nassert(isequal(column_removal(A,n),B_correct))\r\n","published":true,"deleted":false,"likes_count":139,"comments_count":25,"created_by":1,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":27697,"test_suite_updated_at":"2019-07-24T15:11:33.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-01-18T01:00:17.000Z","updated_at":"2026-04-03T18:23:15.000Z","published_at":"2012-01-18T01:00:17.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\u003eRemove the nth column from input matrix A and return the resulting matrix in output B.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[ A = [1 2 3;\\n      4 5 6];]]\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\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[ n = 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\u003ethen B is\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 3  \\n   4 6 ]]]\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":1463,"title":"Pascal's Matrix","description":"Given an integer n \u0026ge; 0, generate the ( _n_+1) \u0026times; ( _n_+1) lower triangular \u003chttp://en.wikipedia.org/wiki/Pascal_matrix Pascal's Matrix\u003e.\r\n\r\n*Examples*:\r\n\r\n pascalMat(0)\r\n ans =\r\n     1\r\n\r\n \r\n pascalMat(1)\r\n ans =\r\n     1     0 \r\n     1     1 \r\n \r\n pascalMat(2)\r\n ans =\r\n     1     0     0\r\n     1     1     0\r\n     1     2     1\r\n\r\nNeither *string operations* nor *interpolations* are allowed!\r\n","description_html":"\u003cp\u003eGiven an integer n \u0026ge; 0, generate the ( \u003ci\u003en\u003c/i\u003e+1) \u0026times; ( \u003ci\u003en\u003c/i\u003e+1) lower triangular \u003ca href = \"http://en.wikipedia.org/wiki/Pascal_matrix\"\u003ePascal's Matrix\u003c/a\u003e.\u003c/p\u003e\u003cp\u003e\u003cb\u003eExamples\u003c/b\u003e:\u003c/p\u003e\u003cpre\u003e pascalMat(0)\r\n ans =\r\n     1\u003c/pre\u003e\u003cpre\u003e pascalMat(1)\r\n ans =\r\n     1     0 \r\n     1     1 \u003c/pre\u003e\u003cpre\u003e pascalMat(2)\r\n ans =\r\n     1     0     0\r\n     1     1     0\r\n     1     2     1\u003c/pre\u003e\u003cp\u003eNeither \u003cb\u003estring operations\u003c/b\u003e nor \u003cb\u003einterpolations\u003c/b\u003e are allowed!\u003c/p\u003e","function_template":"function P = pascalMat(n)\r\n  P = n;\r\nend","test_suite":"%%\r\nuser_solution = fileread('pascalMat.m');\r\nassert(isempty(strfind(user_solution,'regexp')));\r\nassert(isempty(strfind(user_solution,'2str')));\r\nassert(isempty(strfind(user_solution,'str2')));\r\nassert(isempty(strfind(user_solution,'interp')));\r\nassert(isempty(strfind(user_solution,'printf')));\r\nassert(isempty(strfind(user_solution,'assert')));\r\n\r\n%%\r\nn = 0;\r\nP_correct = [\r\n    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 1;\r\nP_correct = [\r\n    1  0\r\n    1  1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 2;\r\nP_correct = [\r\n    1  0  0\r\n    1  1  0\r\n    1  2  1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 3;\r\nP_correct = [\r\n    1  0  0  0\r\n    1  1  0  0\r\n    1  2  1  0\r\n    1  3  3  1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 4;\r\nP_correct = [\r\n    1  0  0  0  0\r\n    1  1  0  0  0\r\n    1  2  1  0  0\r\n    1  3  3  1  0\r\n    1  4  6  4  1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 5;\r\nP_correct = [\r\n    1   0   0   0   0   0\r\n    1   1   0   0   0   0\r\n    1   2   1   0   0   0\r\n    1   3   3   1   0   0\r\n    1   4   6   4   1   0\r\n    1   5  10  10   5   1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 6;\r\nP_correct = [\r\n    1   0   0   0   0   0   0\r\n    1   1   0   0   0   0   0\r\n    1   2   1   0   0   0   0\r\n    1   3   3   1   0   0   0\r\n    1   4   6   4   1   0   0\r\n    1   5  10  10   5   1   0\r\n    1   6  15  20  15   6   1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 7;\r\nP_correct = [\r\n    1   0   0   0   0   0   0   0\r\n    1   1   0   0   0   0   0   0\r\n    1   2   1   0   0   0   0   0\r\n    1   3   3   1   0   0   0   0\r\n    1   4   6   4   1   0   0   0\r\n    1   5  10  10   5   1   0   0\r\n    1   6  15  20  15   6   1   0\r\n    1   7  21  35  35  21   7   1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 8;\r\nP_correct = [\r\n    1   0   0   0   0   0   0   0   0\r\n    1   1   0   0   0   0   0   0   0\r\n    1   2   1   0   0   0   0   0   0\r\n    1   3   3   1   0   0   0   0   0\r\n    1   4   6   4   1   0   0   0   0\r\n    1   5  10  10   5   1   0   0   0\r\n    1   6  15  20  15   6   1   0   0\r\n    1   7  21  35  35  21   7   1   0\r\n    1   8  28  56  70  56  28   8   1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 9;\r\nP_correct = [\r\n    1    0    0    0    0    0    0    0    0    0\r\n    1    1    0    0    0    0    0    0    0    0\r\n    1    2    1    0    0    0    0    0    0    0\r\n    1    3    3    1    0    0    0    0    0    0\r\n    1    4    6    4    1    0    0    0    0    0\r\n    1    5   10   10    5    1    0    0    0    0\r\n    1    6   15   20   15    6    1    0    0    0\r\n    1    7   21   35   35   21    7    1    0    0\r\n    1    8   28   56   70   56   28    8    1    0\r\n    1    9   36   84  126  126   84   36    9    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 10;\r\nP_correct = [\r\n    1    0    0    0    0    0    0    0    0    0    0\r\n    1    1    0    0    0    0    0    0    0    0    0\r\n    1    2    1    0    0    0    0    0    0    0    0\r\n    1    3    3    1    0    0    0    0    0    0    0\r\n    1    4    6    4    1    0    0    0    0    0    0\r\n    1    5   10   10    5    1    0    0    0    0    0\r\n    1    6   15   20   15    6    1    0    0    0    0\r\n    1    7   21   35   35   21    7    1    0    0    0\r\n    1    8   28   56   70   56   28    8    1    0    0\r\n    1    9   36   84  126  126   84   36    9    1    0\r\n    1   10   45  120  210  252  210  120   45   10    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 11;\r\nP_correct = [\r\n    1    0    0    0    0    0    0    0    0    0    0    0\r\n    1    1    0    0    0    0    0    0    0    0    0    0\r\n    1    2    1    0    0    0    0    0    0    0    0    0\r\n    1    3    3    1    0    0    0    0    0    0    0    0\r\n    1    4    6    4    1    0    0    0    0    0    0    0\r\n    1    5   10   10    5    1    0    0    0    0    0    0\r\n    1    6   15   20   15    6    1    0    0    0    0    0\r\n    1    7   21   35   35   21    7    1    0    0    0    0\r\n    1    8   28   56   70   56   28    8    1    0    0    0\r\n    1    9   36   84  126  126   84   36    9    1    0    0\r\n    1   10   45  120  210  252  210  120   45   10    1    0\r\n    1   11   55  165  330  462  462  330  165   55   11    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 12;\r\nP_correct = [\r\n    1    0    0    0    0    0    0    0    0    0    0    0    0\r\n    1    1    0    0    0    0    0    0    0    0    0    0    0\r\n    1    2    1    0    0    0    0    0    0    0    0    0    0\r\n    1    3    3    1    0    0    0    0    0    0    0    0    0\r\n    1    4    6    4    1    0    0    0    0    0    0    0    0\r\n    1    5   10   10    5    1    0    0    0    0    0    0    0\r\n    1    6   15   20   15    6    1    0    0    0    0    0    0\r\n    1    7   21   35   35   21    7    1    0    0    0    0    0\r\n    1    8   28   56   70   56   28    8    1    0    0    0    0\r\n    1    9   36   84  126  126   84   36    9    1    0    0    0\r\n    1   10   45  120  210  252  210  120   45   10    1    0    0\r\n    1   11   55  165  330  462  462  330  165   55   11    1    0\r\n    1   12   66  220  495  792  924  792  495  220   66   12    1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 13;\r\nP_correct = [\r\n    1     0     0     0     0     0     0     0     0     0     0     0     0     0\r\n    1     1     0     0     0     0     0     0     0     0     0     0     0     0\r\n    1     2     1     0     0     0     0     0     0     0     0     0     0     0\r\n    1     3     3     1     0     0     0     0     0     0     0     0     0     0\r\n    1     4     6     4     1     0     0     0     0     0     0     0     0     0\r\n    1     5    10    10     5     1     0     0     0     0     0     0     0     0\r\n    1     6    15    20    15     6     1     0     0     0     0     0     0     0\r\n    1     7    21    35    35    21     7     1     0     0     0     0     0     0\r\n    1     8    28    56    70    56    28     8     1     0     0     0     0     0\r\n    1     9    36    84   126   126    84    36     9     1     0     0     0     0\r\n    1    10    45   120   210   252   210   120    45    10     1     0     0     0\r\n    1    11    55   165   330   462   462   330   165    55    11     1     0     0\r\n    1    12    66   220   495   792   924   792   495   220    66    12     1     0\r\n    1    13    78   286   715  1287  1716  1716  1287   715   286    78    13     1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 14;\r\nP_correct = [\r\n    1              0              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              1              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              2              1              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              3              3              1              0              0              0              0              0              0              0              0              0              0              0\r\n    1              4              6              4              1              0              0              0              0              0              0              0              0              0              0\r\n    1              5             10             10              5              1              0              0              0              0              0              0              0              0              0\r\n    1              6             15             20             15              6              1              0              0              0              0              0              0              0              0\r\n    1              7             21             35             35             21              7              1              0              0              0              0              0              0              0\r\n    1              8             28             56             70             56             28              8              1              0              0              0              0              0              0\r\n    1              9             36             84            126            126             84             36              9              1              0              0              0              0              0\r\n    1             10             45            120            210            252            210            120             45             10              1              0              0              0              0\r\n    1             11             55            165            330            462            462            330            165             55             11              1              0              0              0\r\n    1             12             66            220            495            792            924            792            495            220             66             12              1              0              0\r\n    1             13             78            286            715           1287           1716           1716           1287            715            286             78             13              1              0\r\n    1             14             91            364           1001           2002           3003           3432           3003           2002           1001            364             91             14              1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n%%\r\nn = 15;\r\nP_correct = [\r\n    1              0              0              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              1              0              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              2              1              0              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              3              3              1              0              0              0              0              0              0              0              0              0              0              0              0\r\n    1              4              6              4              1              0              0              0              0              0              0              0              0              0              0              0\r\n    1              5             10             10              5              1              0              0              0              0              0              0              0              0              0              0\r\n    1              6             15             20             15              6              1              0              0              0              0              0              0              0              0              0\r\n    1              7             21             35             35             21              7              1              0              0              0              0              0              0              0              0\r\n    1              8             28             56             70             56             28              8              1              0              0              0              0              0              0              0\r\n    1              9             36             84            126            126             84             36              9              1              0              0              0              0              0              0\r\n    1             10             45            120            210            252            210            120             45             10              1              0              0              0              0              0\r\n    1             11             55            165            330            462            462            330            165             55             11              1              0              0              0              0\r\n    1             12             66            220            495            792            924            792            495            220             66             12              1              0              0              0\r\n    1             13             78            286            715           1287           1716           1716           1287            715            286             78             13              1              0              0\r\n    1             14             91            364           1001           2002           3003           3432           3003           2002           1001            364             91             14              1              0\r\n    1             15            105            455           1365           3003           5005           6435           6435           5005           3003           1365            455            105             15              1\r\n    ];\r\nassert(isequal(pascalMat(n),P_correct));\r\n\r\n","published":true,"deleted":false,"likes_count":6,"comments_count":0,"created_by":10352,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":382,"test_suite_updated_at":"2013-04-28T07:09:30.000Z","rescore_all_solutions":false,"group_id":18,"created_at":"2013-04-27T13:20:43.000Z","updated_at":"2026-03-31T18:04:35.000Z","published_at":"2013-04-27T13:43:22.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 an integer n ≥ 0, generate the (\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\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e+1) × (\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\u003en\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e+1) lower triangular\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://en.wikipedia.org/wiki/Pascal_matrix\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePascal's Matrix\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:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExamples\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=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ pascalMat(0)\\n ans =\\n     1\\n\\n pascalMat(1)\\n ans =\\n     1     0 \\n     1     1 \\n\\n pascalMat(2)\\n ans =\\n     1     0     0\\n     1     1     0\\n     1     2     1]]\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\u003eNeither\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\u003estring operations\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e nor\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\u003einterpolations\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e are allowed!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":19,"title":"Swap the first and last columns","description":"Flip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All other columns should be left intact. Return the result in matrix B.\r\nIf the input has one column, the output should be identical to the input.\r\nExample:\r\n Input  A =  [ 12  4   7\r\n                5  1   4 ];\r\n Output B is [  7  4  12 \r\n                4  1   5 ];","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: 193.733px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 406.5px 96.8667px; transform-origin: 406.5px 96.8667px; 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.642px 7.81667px; transform-origin: 374.642px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFlip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All other columns should be left intact. Return the result in matrix B.\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: 227.242px 7.81667px; transform-origin: 227.242px 7.81667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIf the input has one column, the output should be identical to the input.\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: 30.7083px 7.81667px; transform-origin: 30.7083px 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: 81.7333px; 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 40.8667px; transform-origin: 403.5px 40.8667px; 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: 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: 31.2667px 8.375px; transform-origin: 31.2667px 8.375px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 11.725px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 11.725px 8.375px; \"\u003eA =\u003c/span\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; perspective-origin: 7.81667px 8.375px; transform-origin: 7.81667px 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: 42.9917px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 42.9917px 8.375px; \"\u003e[ 12  4   7\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: 105.525px 8.375px; tab-size: 4; transform-origin: 105.525px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                5  1   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: 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; perspective-origin: 31.2667px 8.375px; transform-origin: 31.2667px 8.375px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); perspective-origin: 66.4417px 8.375px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 66.4417px 8.375px; \"\u003eB is [  7  4  12 \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: 105.525px 8.375px; tab-size: 4; transform-origin: 105.525px 8.375px; unicode-bidi: normal; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                4  1   5 ];\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function B = swap_ends(A)\r\n  B = A;\r\nend","test_suite":"%%\r\nfiletext = fileread('swap_ends.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp');\r\nassert(~illegal)\r\n\r\n%%\r\nA = [ 12  4   7\r\n       5  1   4];\r\nB_correct = [  7  4  12 \r\n               4  1   5 ];\r\nassert(isequal(swap_ends(A),B_correct))\r\n\r\n%%\r\nA = [ 12  7\r\n       5  4];\r\nB_correct = [  7  12 \r\n               4   5 ];\r\nassert(isequal(swap_ends(A),B_correct))\r\n\r\n%%\r\nA = [ 1 5 0 2 3 ];\r\nB_correct = [ 3 5 0 2 1 ];\r\nassert(isequal(swap_ends(A),B_correct))\r\n\r\n%%\r\nA = 1;\r\nB_correct = 1;\r\nassert(isequal(swap_ends(A),B_correct))\r\n\r\n%%\r\nA = randi(100,10,1);\r\nB_correct = A;\r\nassert(isequal(swap_ends(A),B_correct))","published":true,"deleted":false,"likes_count":114,"comments_count":18,"created_by":1,"edited_by":223089,"edited_at":"2024-06-30T13:52:17.000Z","deleted_by":null,"deleted_at":null,"solvers_count":22633,"test_suite_updated_at":"2024-06-30T13:52:17.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:19.000Z","updated_at":"2026-04-04T15:01:07.000Z","published_at":"2012-01-18T01:00:19.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\u003eFlip the outermost columns of matrix A, so that the first column becomes the last and the last column becomes the first. All other columns should be left intact. Return the result in matrix B.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the input has one column, the output should be identical to the input.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  A =  [ 12  4   7\\n                5  1   4 ];\\n Output B is [  7  4  12 \\n                4  1   5 ];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":10,"title":"Determine whether a vector is monotonically increasing","description":"Return true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return false otherwise.\r\nExamples:\r\n Input  x = [-3 0 7]\r\n Output tf is true\r\n\r\n Input  x = [2 2]\r\n Output tf is false","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; 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=\"block-size: 184.188px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407.5px 92.0938px; transform-origin: 407.5px 92.0938px; 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: 384.5px 21px; text-align: left; transform-origin: 384.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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eReturn true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return false otherwise.\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: 384.5px 10.5px; text-align: left; transform-origin: 384.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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eExamples:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 102.188px; 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: 404.5px 51.0938px; transform-origin: 404.5px 51.0938px; 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.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); \"\u003ex = [-3 0 7]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); \"\u003etf is true\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Input  \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); \"\u003ex = [2 2]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4375px; 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: 0.666667px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 0.666667px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 0.666667px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 0.666667px; 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: 404.5px 10.2188px; text-wrap: nowrap; transform-origin: 404.5px 10.2188px; \"\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: 0px 0px; tab-size: 4; transform-origin: 0px 0px; white-space-collapse: preserve; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Output \u003c/span\u003e\u003cspan style=\"border-block-end-color: rgb(170, 4, 249); border-block-start-color: rgb(170, 4, 249); border-bottom-color: rgb(170, 4, 249); border-inline-end-color: rgb(170, 4, 249); border-inline-start-color: rgb(170, 4, 249); border-left-color: rgb(170, 4, 249); border-right-color: rgb(170, 4, 249); border-top-color: rgb(170, 4, 249); caret-color: rgb(170, 4, 249); color: rgb(170, 4, 249); column-rule-color: rgb(170, 4, 249); margin-inline-end: 0px; margin-right: 0px; outline-color: rgb(170, 4, 249); text-decoration: none; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); \"\u003etf is false\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function tf = mono_increase(x)\r\n  tf = false;\r\nend","test_suite":"%%\r\nfiletext = fileread('mono_increase.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'regexp') || ...\r\n          contains(filetext, 'elseif'); \r\nassert(~illegal)\r\n\r\n%%\r\nx = [0 1 2 3 4];\r\nassert(isequal(mono_increase(x),true));\r\n\r\n%%\r\nx = [0 1 2 3 -4];\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = [-3 -4 2 3 4];\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = 1:.1:10;\r\nassert(isequal(mono_increase(x),true));\r\n\r\n%%\r\nx = cumsum(rand(1,100));\r\nx(5) = -1;\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = cumsum(rand(1,50));\r\nassert(isequal(mono_increase(x),true));\r\n\r\n%%\r\nx = ones(1,25);\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = [5 4 3 2 1];\r\nassert(isequal(mono_increase(x),false));\r\n\r\n%%\r\nx = [1 2 3 3 4 5];\r\nassert(isequal(mono_increase(x),false));","published":true,"deleted":false,"likes_count":162,"comments_count":45,"created_by":1,"edited_by":7,"edited_at":"2023-09-11T20:15:05.000Z","deleted_by":null,"deleted_at":null,"solvers_count":22956,"test_suite_updated_at":"2023-09-11T20:15:05.000Z","rescore_all_solutions":false,"group_id":2,"created_at":"2012-01-18T01:00:18.000Z","updated_at":"2026-04-04T15:03:28.000Z","published_at":"2012-01-18T01:00:18.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\u003eReturn true if the elements of the input vector increase monotonically (i.e. each element is larger than the previous). Return false otherwise.\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\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 = [-3 0 7]\\n Output tf is true\\n\\n Input  x = [2 2]\\n Output tf is false]]\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\"}]}"}],"term":"tag:\"matlab 101\"","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:\"matlab 101\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"matlab 101\"","","\"","matlab 101","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f74d85c5bf8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f74d85c5b58\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f74d85c5298\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f74d85c5e78\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f74d85c5dd8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f74d85c5d38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f74d85c5c98\u003e":"tag:\"matlab 101\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f74d85c5c98\u003e":"tag:\"matlab 101\""},"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:\"matlab 101\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"matlab 101\"","","\"","matlab 101","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f74d85c5bf8\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f74d85c5b58\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f74d85c5298\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f74d85c5e78\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f74d85c5dd8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f74d85c5d38\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f74d85c5c98\u003e":"tag:\"matlab 101\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f74d85c5c98\u003e":"tag:\"matlab 101\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44634,"difficulty_rating":"easy"},{"id":44670,"difficulty_rating":"easy"},{"id":42347,"difficulty_rating":"easy"},{"id":42346,"difficulty_rating":"easy"},{"id":44653,"difficulty_rating":"easy"},{"id":44621,"difficulty_rating":"easy"},{"id":44654,"difficulty_rating":"easy"},{"id":44622,"difficulty_rating":"easy"},{"id":44687,"difficulty_rating":"easy"},{"id":42348,"difficulty_rating":"easy"},{"id":1926,"difficulty_rating":"easy"},{"id":44620,"difficulty_rating":"easy"},{"id":1501,"difficulty_rating":"easy"},{"id":8,"difficulty_rating":"easy"},{"id":44663,"difficulty_rating":"easy"},{"id":44662,"difficulty_rating":"easy"},{"id":44696,"difficulty_rating":"easy"},{"id":44671,"difficulty_rating":"easy"},{"id":44659,"difficulty_rating":"easy"},{"id":44624,"difficulty_rating":"easy"},{"id":44697,"difficulty_rating":"easy"},{"id":1458,"difficulty_rating":"easy"},{"id":3,"difficulty_rating":"easy"},{"id":1838,"difficulty_rating":"easy"},{"id":44623,"difficulty_rating":"easy"},{"id":44707,"difficulty_rating":"easy"},{"id":44635,"difficulty_rating":"easy"},{"id":44665,"difficulty_rating":"easy"},{"id":44660,"difficulty_rating":"easy"},{"id":44618,"difficulty_rating":"easy"},{"id":2114,"difficulty_rating":"easy"},{"id":44661,"difficulty_rating":"easy-medium"},{"id":42801,"difficulty_rating":"easy-medium"},{"id":42818,"difficulty_rating":"easy-medium"},{"id":44730,"difficulty_rating":"easy-medium"},{"id":42646,"difficulty_rating":"easy-medium"},{"id":233,"difficulty_rating":"easy-medium"},{"id":44408,"difficulty_rating":"easy-medium"},{"id":262,"difficulty_rating":"easy-medium"},{"id":589,"difficulty_rating":"easy-medium"},{"id":1702,"difficulty_rating":"easy-medium"},{"id":584,"difficulty_rating":"easy-medium"},{"id":46588,"difficulty_rating":"easy-medium"},{"id":6,"difficulty_rating":"easy-medium"},{"id":2031,"difficulty_rating":"easy-medium"},{"id":649,"difficulty_rating":"easy-medium"},{"id":7,"difficulty_rating":"easy-medium"},{"id":1463,"difficulty_rating":"easy-medium"},{"id":19,"difficulty_rating":"medium"},{"id":10,"difficulty_rating":"medium"}]}}