{"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":44531,"title":"2) Are you more familiar with iteration methods or Linear Algebra ? Let's see together.","description":"Referring to problem:\r\n\r\nhttps://www.mathworks.com/matlabcentral/cody/problems/44530-are-you-more-familiar-with-iteration-methods-or-linear-algebra-let-s-see-together\r\n\r\nGiven a sum result *_x_* value of a *_N_* number of addends, build an array of _*N*_ elements _*y*_ such that the following equality is satisfied: _sum(y) = x_ .\r\n\r\nFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or  [8 2].\r\n\r\nMore formally if x = a and N = n it results: \r\n\r\ny = [y_1 y_2 y_3 ... y_n]\r\nwhere:  y_1 + y_2 + y_3 +...+ y_n = a\r\n\r\nImportant notice: All the elements in y must be: *different from zero*, *different from each other* and *strictly positive* . On the other hand I will not take into account if they are _integers or decimal numbers_ .\r\n\r\nHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\r\n\r\nGood luck and enjoy with the solution ;)","description_html":"\u003cp\u003eReferring to problem:\u003c/p\u003e\u003cp\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/44530-are-you-more-familiar-with-iteration-methods-or-linear-algebra-let-s-see-together\u003c/p\u003e\u003cp\u003eGiven a sum result \u003cb\u003e\u003ci\u003ex\u003c/i\u003e\u003c/b\u003e value of a \u003cb\u003e\u003ci\u003eN\u003c/i\u003e\u003c/b\u003e number of addends, build an array of \u003ci\u003e\u003cb\u003eN\u003c/b\u003e\u003c/i\u003e elements \u003ci\u003e\u003cb\u003ey\u003c/b\u003e\u003c/i\u003e such that the following equality is satisfied: \u003ci\u003esum(y) = x\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or  [8 2].\u003c/p\u003e\u003cp\u003eMore formally if x = a and N = n it results:\u003c/p\u003e\u003cp\u003ey = [y_1 y_2 y_3 ... y_n]\r\nwhere:  y_1 + y_2 + y_3 +...+ y_n = a\u003c/p\u003e\u003cp\u003eImportant notice: All the elements in y must be: \u003cb\u003edifferent from zero\u003c/b\u003e, \u003cb\u003edifferent from each other\u003c/b\u003e and \u003cb\u003estrictly positive\u003c/b\u003e . On the other hand I will not take into account if they are \u003ci\u003eintegers or decimal numbers\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\u003c/p\u003e\u003cp\u003eGood luck and enjoy with the solution ;)\u003c/p\u003e","function_template":"function y = buildSumArray(x,N);\r\n  y = sum(1:N);\r\nend","test_suite":"%% Test Case 1\r\nx = 6;\r\nN = 3;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\nassert(isempty(y(y \u003c 0)))\r\n\r\n%% Test Case 2\r\nx = 13;\r\nN = 5;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\nassert(isempty(y(y \u003c 0)))\r\n\r\n%% Test Case 3\r\nx = 78;\r\nN = 11;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\nassert(isempty(y(y \u003c 0)))\r\n\r\n%% Test Case 4\r\nx = 2689;\r\nN = 245;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\nassert(isempty(y(y \u003c 0)))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":181340,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":25,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":677,"created_at":"2018-02-24T14:17:32.000Z","updated_at":"2026-03-05T10:42:37.000Z","published_at":"2018-02-24T14:18: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\u003eReferring to problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44530-are-you-more-familiar-with-iteration-methods-or-linear-algebra-let-s-see-together\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/44530-are-you-more-familiar-with-iteration-methods-or-linear-algebra-let-s-see-together\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a sum result\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\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\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e value of a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e number of addends, build an array of\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e elements\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\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e such that the following equality is satisfied:\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\u003esum(y) = x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or [8 2].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMore formally if x = a and N = n it results:\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\u003ey = [y_1 y_2 y_3 ... y_n] where: y_1 + y_2 + y_3 +...+ y_n = 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\u003eImportant notice: All the elements in y must be:\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\u003edifferent from 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: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\u003edifferent from each other\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estrictly positive\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . On the other hand I will not take into account if they are\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\u003eintegers or decimal numbers\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\u003eHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\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\u003eGood luck and enjoy with the 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":44530,"title":"Are you more familiar with iteration methods or Linear Algebra? Let's see together.","description":"Given a sum result *_x_* value of a *_N_* number of addends, build an array of _*N*_ elements _*y*_ such that the following equality is satisfied: _sum(y) = x_ .\r\n\r\nFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or  [8 2].\r\n\r\nMore formally if x = a and N = n it results: \r\n\r\ny = [y_1 y_2 y_3 ... y_n]\r\nwhere:  y_1 + y_2 + y_3 +...+ y_n = a\r\n\r\nImportant notice: All the elements in y must be *different from zero* and *different from each other* . On the other hand I will not take into account if they are _integers or decimal numbers_ .\r\n\r\nHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\r\n\r\nGood luck and enjoy with the solution ;)\r\n","description_html":"\u003cp\u003eGiven a sum result \u003cb\u003e\u003ci\u003ex\u003c/i\u003e\u003c/b\u003e value of a \u003cb\u003e\u003ci\u003eN\u003c/i\u003e\u003c/b\u003e number of addends, build an array of \u003ci\u003e\u003cb\u003eN\u003c/b\u003e\u003c/i\u003e elements \u003ci\u003e\u003cb\u003ey\u003c/b\u003e\u003c/i\u003e such that the following equality is satisfied: \u003ci\u003esum(y) = x\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or  [8 2].\u003c/p\u003e\u003cp\u003eMore formally if x = a and N = n it results:\u003c/p\u003e\u003cp\u003ey = [y_1 y_2 y_3 ... y_n]\r\nwhere:  y_1 + y_2 + y_3 +...+ y_n = a\u003c/p\u003e\u003cp\u003eImportant notice: All the elements in y must be \u003cb\u003edifferent from zero\u003c/b\u003e and \u003cb\u003edifferent from each other\u003c/b\u003e . On the other hand I will not take into account if they are \u003ci\u003eintegers or decimal numbers\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\u003c/p\u003e\u003cp\u003eGood luck and enjoy with the solution ;)\u003c/p\u003e","function_template":"function y = buildSumArray(x,N)\r\n  y = sum(1:N);\r\nend","test_suite":"%% Test Case 1\r\nx = 6;\r\nN = 3;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\n\r\n%% Test Case 2\r\nx = 13;\r\nN = 5;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\n\r\n\r\n%% Test Case 3\r\nx = 78;\r\nN = 11;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\n\r\n\r\n%% Test Case 4\r\nx = 2689;\r\nN = 245;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":181340,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":30,"test_suite_updated_at":"2018-02-24T12:07:13.000Z","rescore_all_solutions":false,"group_id":677,"created_at":"2018-02-24T11:21:15.000Z","updated_at":"2026-04-02T13:09:38.000Z","published_at":"2018-02-24T11:49: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\u003eGiven a sum result\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\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\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e value of a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e number of addends, build an array of\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e elements\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\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e such that the following equality is satisfied:\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\u003esum(y) = x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or [8 2].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMore formally if x = a and N = n it results:\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\u003ey = [y_1 y_2 y_3 ... y_n] where: y_1 + y_2 + y_3 +...+ y_n = 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\u003eImportant notice: All the elements in y must be\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\u003edifferent from zero\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edifferent from each other\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . On the other hand I will not take into account if they are\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\u003eintegers or decimal numbers\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\u003eHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\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\u003eGood luck and enjoy with the 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":45578,"title":"Create a matrix that counts up diagonally","description":"Given a single input _N_, create a _N_ x _N_ matrix that counts from 1 : _N_ ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\r\n\r\n  1  3  6 10\r\n  2  5  9 13 \r\n  4  8 12 15 \r\n  7 11 14 16\r\n  \r\n\r\nNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u003e= 2).\r\n","description_html":"\u003cp\u003eGiven a single input \u003ci\u003eN\u003c/i\u003e, create a \u003ci\u003eN\u003c/i\u003e x \u003ci\u003eN\u003c/i\u003e matrix that counts from 1 : \u003ci\u003eN\u003c/i\u003e ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1  3  6 10\r\n2  5  9 13 \r\n4  8 12 15 \r\n7 11 14 16\r\n\u003c/pre\u003e\u003cp\u003eNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u0026gt;= 2).\u003c/p\u003e","function_template":"function mx = not_hankel(N)\r\n\r\n    mx = ones(N); %replace with your code\r\n\r\nend","test_suite":"%%\r\nN = 20;\r\n\r\nmx_correct = [...\r\n     1     3     6    10    15    21    28    36    45    55    66    78    91   105   120   136   153   171   190   210\r\n     2     5     9    14    20    27    35    44    54    65    77    90   104   119   135   152   170   189   209   229\r\n     4     8    13    19    26    34    43    53    64    76    89   103   118   134   151   169   188   208   228   247\r\n     7    12    18    25    33    42    52    63    75    88   102   117   133   150   168   187   207   227   246   264\r\n    11    17    24    32    41    51    62    74    87   101   116   132   149   167   186   206   226   245   263   280\r\n    16    23    31    40    50    61    73    86   100   115   131   148   166   185   205   225   244   262   279   295\r\n    22    30    39    49    60    72    85    99   114   130   147   165   184   204   224   243   261   278   294   309\r\n    29    38    48    59    71    84    98   113   129   146   164   183   203   223   242   260   277   293   308   322\r\n    37    47    58    70    83    97   112   128   145   163   182   202   222   241   259   276   292   307   321   334\r\n    46    57    69    82    96   111   127   144   162   181   201   221   240   258   275   291   306   320   333   345\r\n    56    68    81    95   110   126   143   161   180   200   220   239   257   274   290   305   319   332   344   355\r\n    67    80    94   109   125   142   160   179   199   219   238   256   273   289   304   318   331   343   354   364\r\n    79    93   108   124   141   159   178   198   218   237   255   272   288   303   317   330   342   353   363   372\r\n    92   107   123   140   158   177   197   217   236   254   271   287   302   316   329   341   352   362   371   379\r\n   106   122   139   157   176   196   216   235   253   270   286   301   315   328   340   351   361   370   378   385\r\n   121   138   156   175   195   215   234   252   269   285   300   314   327   339   350   360   369   377   384   390\r\n   137   155   174   194   214   233   251   268   284   299   313   326   338   349   359   368   376   383   389   394\r\n   154   173   193   213   232   250   267   283   298   312   325   337   348   358   367   375   382   388   393   397\r\n   172   192   212   231   249   266   282   297   311   324   336   347   357   366   374   381   387   392   396   399\r\n   191   211   230   248   265   281   296   310   323   335   346   356   365   373   380   386   391   395   398   400\r\n   ];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%%\r\nN = 3;\r\n\r\nmx_correct = [...\r\n     1     3     6\r\n     2     5     8\r\n     4     7     9\r\n     ];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%%\r\nrng('shuffle')\r\nN  = randi(99)+5;\r\nr = repmat((0:(N-1))',1,N) + (0:(N-1));\r\np = ((.5.*r.^2 + .5.*r) + (r(1,:)+1));\r\nq = rot90(hankel(fliplr(0:N-1)),2).^2;\r\nmx_correct = p - q;\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%% \r\nN = 2;\r\nmx_correct =...\r\n[...\r\n    1  3\r\n    2  4 \r\n];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":18354,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":"2020-05-22T17:05:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-05-22T16:46:56.000Z","updated_at":"2026-01-20T13:24:26.000Z","published_at":"2020-05-22T16:46:56.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a single input\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, create 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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\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 matrix that counts from 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 ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\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  6 10\\n2  5  9 13 \\n4  8 12 15 \\n7 11 14 16]]\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\u003eNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \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\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":44531,"title":"2) Are you more familiar with iteration methods or Linear Algebra ? Let's see together.","description":"Referring to problem:\r\n\r\nhttps://www.mathworks.com/matlabcentral/cody/problems/44530-are-you-more-familiar-with-iteration-methods-or-linear-algebra-let-s-see-together\r\n\r\nGiven a sum result *_x_* value of a *_N_* number of addends, build an array of _*N*_ elements _*y*_ such that the following equality is satisfied: _sum(y) = x_ .\r\n\r\nFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or  [8 2].\r\n\r\nMore formally if x = a and N = n it results: \r\n\r\ny = [y_1 y_2 y_3 ... y_n]\r\nwhere:  y_1 + y_2 + y_3 +...+ y_n = a\r\n\r\nImportant notice: All the elements in y must be: *different from zero*, *different from each other* and *strictly positive* . On the other hand I will not take into account if they are _integers or decimal numbers_ .\r\n\r\nHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\r\n\r\nGood luck and enjoy with the solution ;)","description_html":"\u003cp\u003eReferring to problem:\u003c/p\u003e\u003cp\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/44530-are-you-more-familiar-with-iteration-methods-or-linear-algebra-let-s-see-together\u003c/p\u003e\u003cp\u003eGiven a sum result \u003cb\u003e\u003ci\u003ex\u003c/i\u003e\u003c/b\u003e value of a \u003cb\u003e\u003ci\u003eN\u003c/i\u003e\u003c/b\u003e number of addends, build an array of \u003ci\u003e\u003cb\u003eN\u003c/b\u003e\u003c/i\u003e elements \u003ci\u003e\u003cb\u003ey\u003c/b\u003e\u003c/i\u003e such that the following equality is satisfied: \u003ci\u003esum(y) = x\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or  [8 2].\u003c/p\u003e\u003cp\u003eMore formally if x = a and N = n it results:\u003c/p\u003e\u003cp\u003ey = [y_1 y_2 y_3 ... y_n]\r\nwhere:  y_1 + y_2 + y_3 +...+ y_n = a\u003c/p\u003e\u003cp\u003eImportant notice: All the elements in y must be: \u003cb\u003edifferent from zero\u003c/b\u003e, \u003cb\u003edifferent from each other\u003c/b\u003e and \u003cb\u003estrictly positive\u003c/b\u003e . On the other hand I will not take into account if they are \u003ci\u003eintegers or decimal numbers\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\u003c/p\u003e\u003cp\u003eGood luck and enjoy with the solution ;)\u003c/p\u003e","function_template":"function y = buildSumArray(x,N);\r\n  y = sum(1:N);\r\nend","test_suite":"%% Test Case 1\r\nx = 6;\r\nN = 3;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\nassert(isempty(y(y \u003c 0)))\r\n\r\n%% Test Case 2\r\nx = 13;\r\nN = 5;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\nassert(isempty(y(y \u003c 0)))\r\n\r\n%% Test Case 3\r\nx = 78;\r\nN = 11;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\nassert(isempty(y(y \u003c 0)))\r\n\r\n%% Test Case 4\r\nx = 2689;\r\nN = 245;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\nassert(isempty(y(y \u003c 0)))\r\n","published":true,"deleted":false,"likes_count":2,"comments_count":3,"created_by":181340,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":25,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":677,"created_at":"2018-02-24T14:17:32.000Z","updated_at":"2026-03-05T10:42:37.000Z","published_at":"2018-02-24T14:18: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\u003eReferring to problem:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44530-are-you-more-familiar-with-iteration-methods-or-linear-algebra-let-s-see-together\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/44530-are-you-more-familiar-with-iteration-methods-or-linear-algebra-let-s-see-together\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a sum result\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\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\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e value of a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e number of addends, build an array of\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e elements\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\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e such that the following equality is satisfied:\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\u003esum(y) = x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or [8 2].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMore formally if x = a and N = n it results:\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\u003ey = [y_1 y_2 y_3 ... y_n] where: y_1 + y_2 + y_3 +...+ y_n = 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\u003eImportant notice: All the elements in y must be:\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\u003edifferent from 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: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\u003edifferent from each other\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003estrictly positive\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . On the other hand I will not take into account if they are\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\u003eintegers or decimal numbers\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\u003eHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\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\u003eGood luck and enjoy with the 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":44530,"title":"Are you more familiar with iteration methods or Linear Algebra? Let's see together.","description":"Given a sum result *_x_* value of a *_N_* number of addends, build an array of _*N*_ elements _*y*_ such that the following equality is satisfied: _sum(y) = x_ .\r\n\r\nFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or  [8 2].\r\n\r\nMore formally if x = a and N = n it results: \r\n\r\ny = [y_1 y_2 y_3 ... y_n]\r\nwhere:  y_1 + y_2 + y_3 +...+ y_n = a\r\n\r\nImportant notice: All the elements in y must be *different from zero* and *different from each other* . On the other hand I will not take into account if they are _integers or decimal numbers_ .\r\n\r\nHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\r\n\r\nGood luck and enjoy with the solution ;)\r\n","description_html":"\u003cp\u003eGiven a sum result \u003cb\u003e\u003ci\u003ex\u003c/i\u003e\u003c/b\u003e value of a \u003cb\u003e\u003ci\u003eN\u003c/i\u003e\u003c/b\u003e number of addends, build an array of \u003ci\u003e\u003cb\u003eN\u003c/b\u003e\u003c/i\u003e elements \u003ci\u003e\u003cb\u003ey\u003c/b\u003e\u003c/i\u003e such that the following equality is satisfied: \u003ci\u003esum(y) = x\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or  [8 2].\u003c/p\u003e\u003cp\u003eMore formally if x = a and N = n it results:\u003c/p\u003e\u003cp\u003ey = [y_1 y_2 y_3 ... y_n]\r\nwhere:  y_1 + y_2 + y_3 +...+ y_n = a\u003c/p\u003e\u003cp\u003eImportant notice: All the elements in y must be \u003cb\u003edifferent from zero\u003c/b\u003e and \u003cb\u003edifferent from each other\u003c/b\u003e . On the other hand I will not take into account if they are \u003ci\u003eintegers or decimal numbers\u003c/i\u003e .\u003c/p\u003e\u003cp\u003eHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\u003c/p\u003e\u003cp\u003eGood luck and enjoy with the solution ;)\u003c/p\u003e","function_template":"function y = buildSumArray(x,N)\r\n  y = sum(1:N);\r\nend","test_suite":"%% Test Case 1\r\nx = 6;\r\nN = 3;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\n\r\n%% Test Case 2\r\nx = 13;\r\nN = 5;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\n\r\n\r\n%% Test Case 3\r\nx = 78;\r\nN = 11;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\n\r\n\r\n%% Test Case 4\r\nx = 2689;\r\nN = 245;\r\ny = buildSumArray(x,N);\r\ny2 = unique(y);\r\n\r\nassert(isequal(round(sum(y)*100)/100,x))\r\nassert(isequal(length(y),N))\r\nassert(isequal(length(y2),N))\r\nassert(sum(y == 0) == 0)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":181340,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":30,"test_suite_updated_at":"2018-02-24T12:07:13.000Z","rescore_all_solutions":false,"group_id":677,"created_at":"2018-02-24T11:21:15.000Z","updated_at":"2026-04-02T13:09:38.000Z","published_at":"2018-02-24T11:49: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\u003eGiven a sum result\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\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\u003ex\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e value of a\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e number of addends, build an array of\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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e elements\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\u003ey\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e such that the following equality is satisfied:\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\u003esum(y) = x\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e .\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example if: x = 10 and N = 2, possible solutions for y are: [7 3], or [8 2].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eMore formally if x = a and N = n it results:\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\u003ey = [y_1 y_2 y_3 ... y_n] where: y_1 + y_2 + y_3 +...+ y_n = 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\u003eImportant notice: All the elements in y must be\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\u003edifferent from zero\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003edifferent from each other\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e . On the other hand I will not take into account if they are\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\u003eintegers or decimal numbers\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\u003eHint: You can use several approaches and the solution is not unique. For example you can think to approach with a iterative method or, if you are more accustomed with Algebra, by solving a linear system. This choice it's up to you.\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\u003eGood luck and enjoy with the 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":45578,"title":"Create a matrix that counts up diagonally","description":"Given a single input _N_, create a _N_ x _N_ matrix that counts from 1 : _N_ ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\r\n\r\n  1  3  6 10\r\n  2  5  9 13 \r\n  4  8 12 15 \r\n  7 11 14 16\r\n  \r\n\r\nNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u003e= 2).\r\n","description_html":"\u003cp\u003eGiven a single input \u003ci\u003eN\u003c/i\u003e, create a \u003ci\u003eN\u003c/i\u003e x \u003ci\u003eN\u003c/i\u003e matrix that counts from 1 : \u003ci\u003eN\u003c/i\u003e ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1  3  6 10\r\n2  5  9 13 \r\n4  8 12 15 \r\n7 11 14 16\r\n\u003c/pre\u003e\u003cp\u003eNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \u0026gt;= 2).\u003c/p\u003e","function_template":"function mx = not_hankel(N)\r\n\r\n    mx = ones(N); %replace with your code\r\n\r\nend","test_suite":"%%\r\nN = 20;\r\n\r\nmx_correct = [...\r\n     1     3     6    10    15    21    28    36    45    55    66    78    91   105   120   136   153   171   190   210\r\n     2     5     9    14    20    27    35    44    54    65    77    90   104   119   135   152   170   189   209   229\r\n     4     8    13    19    26    34    43    53    64    76    89   103   118   134   151   169   188   208   228   247\r\n     7    12    18    25    33    42    52    63    75    88   102   117   133   150   168   187   207   227   246   264\r\n    11    17    24    32    41    51    62    74    87   101   116   132   149   167   186   206   226   245   263   280\r\n    16    23    31    40    50    61    73    86   100   115   131   148   166   185   205   225   244   262   279   295\r\n    22    30    39    49    60    72    85    99   114   130   147   165   184   204   224   243   261   278   294   309\r\n    29    38    48    59    71    84    98   113   129   146   164   183   203   223   242   260   277   293   308   322\r\n    37    47    58    70    83    97   112   128   145   163   182   202   222   241   259   276   292   307   321   334\r\n    46    57    69    82    96   111   127   144   162   181   201   221   240   258   275   291   306   320   333   345\r\n    56    68    81    95   110   126   143   161   180   200   220   239   257   274   290   305   319   332   344   355\r\n    67    80    94   109   125   142   160   179   199   219   238   256   273   289   304   318   331   343   354   364\r\n    79    93   108   124   141   159   178   198   218   237   255   272   288   303   317   330   342   353   363   372\r\n    92   107   123   140   158   177   197   217   236   254   271   287   302   316   329   341   352   362   371   379\r\n   106   122   139   157   176   196   216   235   253   270   286   301   315   328   340   351   361   370   378   385\r\n   121   138   156   175   195   215   234   252   269   285   300   314   327   339   350   360   369   377   384   390\r\n   137   155   174   194   214   233   251   268   284   299   313   326   338   349   359   368   376   383   389   394\r\n   154   173   193   213   232   250   267   283   298   312   325   337   348   358   367   375   382   388   393   397\r\n   172   192   212   231   249   266   282   297   311   324   336   347   357   366   374   381   387   392   396   399\r\n   191   211   230   248   265   281   296   310   323   335   346   356   365   373   380   386   391   395   398   400\r\n   ];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%%\r\nN = 3;\r\n\r\nmx_correct = [...\r\n     1     3     6\r\n     2     5     8\r\n     4     7     9\r\n     ];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%%\r\nrng('shuffle')\r\nN  = randi(99)+5;\r\nr = repmat((0:(N-1))',1,N) + (0:(N-1));\r\np = ((.5.*r.^2 + .5.*r) + (r(1,:)+1));\r\nq = rot90(hankel(fliplr(0:N-1)),2).^2;\r\nmx_correct = p - q;\r\nassert(isequal(not_hankel(N),mx_correct))\r\n\r\n\r\n\r\n%% \r\nN = 2;\r\nmx_correct =...\r\n[...\r\n    1  3\r\n    2  4 \r\n];\r\n\r\nassert(isequal(not_hankel(N),mx_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":18354,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":22,"test_suite_updated_at":"2020-05-22T17:05:13.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-05-22T16:46:56.000Z","updated_at":"2026-01-20T13:24:26.000Z","published_at":"2020-05-22T16:46:56.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a single input\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, create 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\u003eN\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e x\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 matrix that counts from 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 ², (along up-right diagonals, starting with 1 in the top left corner. For example, given N=4...\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  6 10\\n2  5  9 13 \\n4  8 12 15 \\n7 11 14 16]]\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\u003eNotice as you move up a row and right a column (↗) the values always increase by one. The value '1' should always go in the top left corner, with '2' directly below it. From there fill in the upward-rightward diagonals with the next higher integer until the matrix is complete. Assume N will always be a positive integer greater than 1 (N \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\"}]}"}],"term":"tag:\"advanced\"","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:\"advanced\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"advanced\"","","\"","advanced","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4a01bafca0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f4a01bafc00\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4a01baf2a0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4a01baff20\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4a01bafe80\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4a01bafde0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4a01bafd40\u003e":"tag:\"advanced\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4a01bafd40\u003e":"tag:\"advanced\""},"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:\"advanced\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"advanced\"","","\"","advanced","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f4a01bafca0\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f4a01bafc00\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f4a01baf2a0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f4a01baff20\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f4a01bafe80\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f4a01bafde0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f4a01bafd40\u003e":"tag:\"advanced\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f4a01bafd40\u003e":"tag:\"advanced\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":44531,"difficulty_rating":"easy"},{"id":44530,"difficulty_rating":"easy-medium"},{"id":45578,"difficulty_rating":"medium"}]}}