{"group":{"id":1,"name":"Community","lockable":false,"created_at":"2012-01-18T18:02:15.000Z","updated_at":"2026-04-06T14:01:22.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":"2026-04-06T00: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":2597,"title":"Alternative Scoring. Create an incremental spiral.","description":"This problem is created to test an alternative Cody scoring system. It is based on the current one, but few changes are introduced. The main difference is that strings generate nearly same size as other arrays so '12345'-'0' won't be smaller than [1 2 3 4 5]. There is also improvement of scoring when _ans_ is used.\r\n\r\nYour goal is to write a function that *for given n* creates *spiral matrix like in problem \u003chttp://www.mathworks.com/matlabcentral/cody/problems/944 944\u003e.* You can choose one or more ways to do this: \r\n\r\n* Clean Code - without any kind of cheating,\r\n* Small Size - using cheats based on scoring system like _regexp_ or _'chars'-'0'_,\r\n* Hack+100 - if you really want, I can't stop you from hacking this problem, set size to 100 in this case, please.\r\n\r\nEnjoy!\r\n\r\nThis problem is related to problems  \u003chttp://www.mathworks.com/matlabcentral/cody/problems/944 944\u003e, \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2033 2033\u003e, \u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/2390 2390\u003e, ... and others which I don't remember now :-)","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: 256.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 128.15px; transform-origin: 407px 128.15px; 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: 374.5px 8px; transform-origin: 374.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem is created to test an alternative Cody scoring system. It is based on the current one, but few changes are introduced. The main difference is that strings generate nearly same size as other arrays so '12345'-'0' won't be smaller than [1 2 3 4 5]. There is also improvement of scoring when\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 11.5px 8px; transform-origin: 11.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eans\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is used.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 108.5px 8px; transform-origin: 108.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYour goal is to write a function that\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 38.5px 8px; transform-origin: 38.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003efor given n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 25.5px 8px; transform-origin: 25.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e creates\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 97px 8px; transform-origin: 97px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003espiral matrix like in problem\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"http://www.mathworks.com/matlabcentral/cody/problems/944\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"font-weight: 700; \"\u003e944\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e.\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 94.5px 8px; transform-origin: 94.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e You can choose one or more ways to do this:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 30.65px; transform-origin: 391px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 133.5px 8px; transform-origin: 133.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eClean Code - without any kind of cheating,\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 171.5px 8px; transform-origin: 171.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSmall Size - using cheats based on scoring system like\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.5px 8px; transform-origin: 21.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eregexp\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 8.5px 8px; transform-origin: 8.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e or\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 30px 8px; transform-origin: 30px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e'chars'-'0'\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 339px 8px; transform-origin: 339px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHack+100 - if you really want, I can't stop you from hacking this problem, set size to 100 in this case, please.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\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: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eEnjoy!\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: 113px 8px; transform-origin: 113px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem is related to problems \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"http://www.mathworks.com/matlabcentral/cody/problems/944\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e944\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"http://www.mathworks.com/matlabcentral/cody/problems/2033\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e2033\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/2390\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e2390\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: 144px 8px; transform-origin: 144px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, ... and others which I don't remember now :-)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = inv_spiral(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = [1 2\r\n             4 3];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = [1 2 3\r\n             8 9 4\r\n             7 6 5];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 4;\r\ny_correct = [ 1  2  3 4\r\n             12 13 14 5\r\n             11 16 15 6\r\n             10  9  8 7];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = [1  2  3  4  5\r\n             16 17 18 19 6\r\n             15 24 25 20 7\r\n             14 23 22 21 8\r\n             13 12 11 10 9];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 6;\r\ny_correct = [1  2  3  4  5  6\r\n            20 21 22 23 24  7\r\n            19 32 33 34 25  8\r\n            18 31 36 35 26  9\r\n            17 30 29 28 27 10\r\n            16 15 14 13 12 11];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 7;\r\ny_correct = [1  2  3  4  5  6  7\r\n            24 25 26 27 28 29  8\r\n            23 40 41 42 43 30  9\r\n            22 39 48 49 44 31 10\r\n            21 38 47 46 45 32 11\r\n            20 37 36 35 34 33 12\r\n            19 18 17 16 15 14 13];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 8;\r\ny_correct = [1  2  3  4  5  6  7  8\r\n            28 29 30 31 32 33 34  9\r\n            27 48 49 50 51 52 35 10\r\n            26 47 60 61 62 53 36 11\r\n            25 46 59 64 63 54 37 12\r\n            24 45 58 57 56 55 38 13\r\n            23 44 43 42 41 40 39 14\r\n            22 21 20 19 18 17 16 15];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%% \r\n%\r\n%  size_old = feval(@evalin,'caller','score');\r\n%\r\n%\r\n% ________SCORING_SYSTEM___________________\r\n%\r\n%  all_nodes = mtree('inv_spiral.m','-file');\r\n%  str_nodes = mtfind(all_nodes,'Kind','STRING');\r\n%   eq_nodes = mtfind(all_nodes,'Kind','EQUALS');\r\n%print_nodes = mtfind(all_nodes,'Kind','PRINT');\r\n% expr_nodes = mtfind(all_nodes,'Kind','EXPR');\r\n%\r\n%       size = count(all_nodes)           ...\r\n%              +sum(str_nodes.nodesize-1) ...\r\n%              +2*(count(expr_nodes)      ...\r\n%                  +count(print_nodes)    ...\r\n%                  -count(eq_nodes));\r\n%\r\n%\r\n%  feval(@assignin,'caller','score',size);\r\n%\r\n% _________________________________________\r\n%\r\n%\r\n%fprintf('Size in standard cody scoring is %i.\\n',size_old);\r\n%fprintf('Size in proposed cody scoring is %i.\\n',size);\r\n%\r\n%if size==size_old\u0026\u0026size~=100\r\n%  disp('Clean Code!'); % ... or dirty hack\r\n%elseif size\u003esize_old\r\n%  disp('Tried tricks?'); \r\n%elseif size==100\u0026\u0026old_size==100\r\n%  disp('You hacked it! or it is a nice coincidence');\r\n%elseif size\u003csize_old\r\n%  disp('Something went wrong with scoring. (or you hacked it!)');\r\n%else\r\n%  disp('Master of Chaos.');\r\n%end\r\n%\r\n% This testsuite may be improved in the future.\r\n%\r\n%_________RESULT_____________________________","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":19,"test_suite_updated_at":"2020-11-18T11:39:09.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-09-18T16:49:08.000Z","updated_at":"2025-12-08T02:47:55.000Z","published_at":"2014-09-18T16:49:08.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\u003eThis problem is created to test an alternative Cody scoring system. It is based on the current one, but few changes are introduced. The main difference is that strings generate nearly same size as other arrays so '12345'-'0' won't be smaller than [1 2 3 4 5]. There is also improvement of scoring when\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\u003eans\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is used.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour goal is to write a function that\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\u003efor given n\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e creates\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\u003espiral matrix like in problem\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:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/944\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e944\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:t\u003e You can choose one or more ways to do this:\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eClean Code - without any kind of cheating,\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSmall Size - using cheats based on scoring system like\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\u003eregexp\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e'chars'-'0'\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=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHack+100 - if you really want, I can't stop you from hacking this problem, set size to 100 in this case, please.\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\u003eEnjoy!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to problems \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/944\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e944\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2033\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e2033\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/cody/problems/2390\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e2390\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, ... and others which I don't remember now :-)\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":1400,"title":"Spiral Matrix","description":"for a given integer n\u003e=3, generate a matrix of nxn such that the value n^2 is at bottom left and its decreasing towards center  around the corner forming a spiral.{clockwise spiral- starting from bottom left}\r\n\r\nExamples:\r\n\r\n Input  n = 5\r\n Output y is [ 21 20 19 18 17;\r\n               22 7  6  5  16;\r\n               23 8  1  4  15;\r\n               24 9  2  3  14;\r\n               25 10 11 12 13];\r\n\r\n Input  n = 4\r\n Output y is [ 13 12 11 10 \r\n               14 3  2  9\r\n               15 4  1  8\r\n               16 5  6  7]","description_html":"\u003cp\u003efor a given integer n\u003e=3, generate a matrix of nxn such that the value n^2 is at bottom left and its decreasing towards center  around the corner forming a spiral.{clockwise spiral- starting from bottom left}\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e Input  n = 5\r\n Output y is [ 21 20 19 18 17;\r\n               22 7  6  5  16;\r\n               23 8  1  4  15;\r\n               24 9  2  3  14;\r\n               25 10 11 12 13];\u003c/pre\u003e\u003cpre\u003e Input  n = 4\r\n Output y is [ 13 12 11 10 \r\n               14 3  2  9\r\n               15 4  1  8\r\n               16 5  6  7]\u003c/pre\u003e","function_template":"function y = spiralmatrix(x)\r\n  y = x;\r\nend","test_suite":"x=1;\r\n\r\ny_correct=1;\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))\r\n\r\n%%\r\n\r\nx=2;\r\n\r\ny_correct=[3 2\r\n\r\n           4 1];\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))\r\n\r\n%%\r\n\r\nx=3;\r\n\r\ny_correct=[7 6 5\r\n\r\n           8 1 4\r\n\r\n           9 2 3];\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))\r\n\r\n%%\r\n\r\nx=4;\r\n\r\ny_correct=[13 12 11 10\r\n\r\n           14  3  2  9\r\n\r\n           15  4  1  8\r\n\r\n           16  5  6  7];\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))\r\n\r\n%%\r\n\r\nx=5;\r\n\r\ny_correct=[21 20 19 18 17\r\n\r\n           22  7  6  5 16\r\n\r\n           23  8  1  4 15\r\n\r\n           24  9  2  3 14\r\n\r\n           25 10 11 12 13];\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":6312,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":"2013-03-31T05:43:10.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-03-30T10:24:55.000Z","updated_at":"2025-12-08T11:58:40.000Z","published_at":"2013-03-30T10:25: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\u003efor a given integer n\u0026gt;=3, generate a matrix of nxn such that the value n^2 is at bottom left and its decreasing towards center around the corner forming a spiral.{clockwise spiral- starting from bottom left}\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  n = 5\\n Output y is [ 21 20 19 18 17;\\n               22 7  6  5  16;\\n               23 8  1  4  15;\\n               24 9  2  3  14;\\n               25 10 11 12 13];\\n\\n Input  n = 4\\n Output y is [ 13 12 11 10 \\n               14 3  2  9\\n               15 4  1  8\\n               16 5  6  7]]]\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":56383,"title":"Create spiral matrices","description":"Create a matrix of a given size with sequential elements spiraling inward. \r\nFor matrix height m and width n, the output should be an m-by-n matrix with elements ranging from from 1 to m*n in a rectangular spiral pattern with 1 in position (1,1) and the first 'leg' of the spiral progressing down the first column, i.e., the left column of the output has elements 1:m.","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: 93px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 46.5px; transform-origin: 407px 46.5px; 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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eCreate a matrix of a given size with sequential elements spiraling inward. \u003c/span\u003e\u003c/span\u003e\u003c/div\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor matrix height m and width n, the output should be an m-by-n matrix with elements ranging from from 1 to m*n in a rectangular spiral pattern with 1 in position (1,1) and the first 'leg' of the spiral progressing down the first column, i.e., the left column of the output has elements 1:m.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function s = rectangular_spiral(m,n)\r\n  s = m*n;\r\nend","test_suite":"%%\r\nm = 1;\r\nn = 1;\r\ny_correct = 1;\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 3;\r\nn = 5;\r\ny_correct = [\r\n    1 12 11 10 9\r\n    2 13 14 15 8\r\n    3  4  5  6 7];\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 5;\r\nn = 5;\r\ny_correct = rot90(-spiral(5) + 26);\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 9;\r\nn = 9;\r\ny_correct = rot90(-spiral(9) + 82);\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nassert(isequal(rectangular_spiral(0,0),[]))\r\n\r\n%%\r\nm = 7;\r\nn = 4;\r\ny_correct = [\r\n    1 18 17 16\r\n    2 19 28 15\r\n    3 20 27 14\r\n    4 21 26 13\r\n    5 22 25 12\r\n    6 23 24 11\r\n    7  8  9 10];\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 1;\r\nn = 3;\r\ny_correct = [1 2 3];\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 5;\r\nn = 1;\r\ny_correct = [1 2 3 4 5]';\r\nassert(isequal(rectangular_spiral(m,n),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":10139,"edited_by":10139,"edited_at":"2022-10-17T18:02:47.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-10-17T17:41:01.000Z","updated_at":"2022-10-17T18:02:47.000Z","published_at":"2022-10-17T17:41:33.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate a matrix of a given size with sequential elements spiraling inward. \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 matrix height m and width n, the output should be an m-by-n matrix with elements ranging from from 1 to m*n in a rectangular spiral pattern with 1 in position (1,1) and the first 'leg' of the spiral progressing down the first column, i.e., the left column of the output has elements 1:m.\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":2340,"title":"Numbers spiral diagonals (Part 1)","description":"Inspired by Project Euler n°28 et 58.\r\n\r\nA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\r\n\r\nFor exemple with n=5, the spiral matrix is :\r\n\r\n                       21 22 23 24 25\r\n                       20  7  8  9 10\r\n                       19  6  1  2 11\r\n                       18  5  4  3 12\r\n                       17 16 15 14 13\r\n\r\nIn this example, the sum of the numbers on the diagonals is 101.\r\n\r\nWhat is the sum of the numbers on the diagonals in any n by n spiral (n always odd) ?\r\n\r\nHINTS: You want the diagonals, not the whole matrix.","description_html":"\u003cp\u003eInspired by Project Euler n°28 et 58.\u003c/p\u003e\u003cp\u003eA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\u003c/p\u003e\u003cp\u003eFor exemple with n=5, the spiral matrix is :\u003c/p\u003e\u003cpre\u003e                       21 22 23 24 25\r\n                       20  7  8  9 10\r\n                       19  6  1  2 11\r\n                       18  5  4  3 12\r\n                       17 16 15 14 13\u003c/pre\u003e\u003cp\u003eIn this example, the sum of the numbers on the diagonals is 101.\u003c/p\u003e\u003cp\u003eWhat is the sum of the numbers on the diagonals in any n by n spiral (n always odd) ?\u003c/p\u003e\u003cp\u003eHINTS: You want the diagonals, not the whole matrix.\u003c/p\u003e","function_template":"function y = spiral_nb(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 3;\r\ny_correct = 25;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = 101;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 9;\r\ny_correct = 537;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 501;\r\ny_correct = 83960501;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 5001;\r\ny_correct = 83395855001;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 10001;\r\ny_correct = 666916710001;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 10003;\r\ny_correct = 667316890025;\r\nassert(isequal(spiral_nb(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":5390,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":296,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":31,"created_at":"2014-05-30T22:02:51.000Z","updated_at":"2026-02-01T14:00:50.000Z","published_at":"2014-05-30T22:03: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\",\"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\u003eInspired by Project Euler n°28 et 58.\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\u003eA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\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 exemple with n=5, the spiral matrix 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[                       21 22 23 24 25\\n                       20  7  8  9 10\\n                       19  6  1  2 11\\n                       18  5  4  3 12\\n                       17 16 15 14 13]]\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\u003eIn this example, the sum of the numbers on the diagonals is 101.\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\u003eWhat is the sum of the numbers on the diagonals in any n by n spiral (n always odd) ?\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\u003eHINTS: You want the diagonals, not the whole 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":45452,"title":"Spiral Out - 01","description":"Create a spiral matrix ( clock-wise direction ) of size n.\r\n\r\nTry to do that without using the built-in function.","description_html":"\u003cp\u003eCreate a spiral matrix ( clock-wise direction ) of size n.\u003c/p\u003e\u003cp\u003eTry to do that without using the built-in function.\u003c/p\u003e","function_template":"function y = spi_out_2(n)","test_suite":"%%\r\nassert(isequal(spi_out_2(5),spiral(5)))\r\n%%\r\nassert(isequal(spi_out_2(3),spiral(3)))\r\n%%\r\nassert(isequal(spi_out_2(30),spiral(30)))\r\n%%\r\nassert(isequal(spi_out_2(15),spiral(15)))\r\n%%\r\nassert(isequal(spi_out_2(100),spiral(100)))\r\n%%\r\nassert(isequal(spi_out_2(2555),spiral(2555)))\r\n%%\r\nfiletext = fileread('spi_out_2.m');\r\nassert(isempty(strfind(filetext, 'spiral')),'spiral() forbidden')\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":21,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-04-14T02:37:04.000Z","updated_at":"2026-01-21T13:05:44.000Z","published_at":"2020-04-14T02:37: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\u003eCreate a spiral matrix ( clock-wise direction ) of size 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\u003eTry to do that without using the built-in 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":45404,"title":"ZigZag - 04","description":"Given a matrix, print all its elements in the spiral form (clockwise direction).\r\n\r\nFor example,\r\n\r\n a=[16     2     3    13\r\n     5    11    10     8\r\n     9     7     6    12\r\n     4    14    15     1]\r\noutput = [16 2 3 13 8 12 1 15 14 4 9 5 11 10 6 7] ","description_html":"\u003cp\u003eGiven a matrix, print all its elements in the spiral form (clockwise direction).\u003c/p\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre\u003e a=[16     2     3    13\r\n     5    11    10     8\r\n     9     7     6    12\r\n     4    14    15     1]\r\noutput = [16 2 3 13 8 12 1 15 14 4 9 5 11 10 6 7] \u003c/pre\u003e","function_template":"function y = spiral_pattern(x)","test_suite":"%%\r\nx = magic(4);\r\ny=[16\t2\t3\t13\t8\t12\t1\t15\t14\t4\t9\t5\t11\t10\t6\t7]\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n%%\r\nx=reshape([89:124],3,[]);\r\ny=[89\t92\t95\t98\t101\t104\t107\t110\t113\t116\t119\t122\t123\t124\t121\t118\t115\t112\t109\t106\t103\t100\t97\t94\t91\t90\t93\t96\t99\t102\t105\t108\t111\t114\t117\t120]\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n\r\n%%\r\nx = ones(8,2);\r\ny=ones(1,16);\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n\r\n%%\r\nx = [17    24     1\r\n    23     5     1\r\n     4     6     1\r\n    10    12     1\r\n    11    18     1]\r\ny=[17    24     1     1     1     1     1    18    11    10     4    23     5 6    12]\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n\r\n%%\r\nx = magic(9);\r\ny=[47\t58\t69\t80\t1\t12\t23\t34\t45\t46\t56\t66\t76\t5\t15\t25\t35\t24\t13\t2\t81\t70\t59\t48\t37\t36\t26\t16\t6\t77\t67\t57\t68\t79\t9\t11\t22\t33\t44\t54\t55\t65\t75\t4\t14\t3\t73\t71\t60\t49\t38\t28\t27\t17\t7\t78\t8\t10\t21\t32\t43\t53\t63\t64\t74\t72\t61\t50\t39\t29\t19\t18\t20\t31\t42\t52\t62\t51\t40\t30\t41]\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2020-04-01T00:24:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-30T18:33:34.000Z","updated_at":"2025-03-01T10:13:38.000Z","published_at":"2020-03-30T18:33:34.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a matrix, print all its elements in the spiral form (clockwise direction).\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[ a=[16     2     3    13\\n     5    11    10     8\\n     9     7     6    12\\n     4    14    15     1]\\noutput = [16 2 3 13 8 12 1 15 14 4 9 5 11 10 6 7]]]\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":255,"title":"Spiraling out of control....","description":"Imagine a square with corners at the origin and at (1,1).  An interesting spiral can be created by tracing the path of a moving point that starts at the origin and intersects the leftmost opposite edge at a point (F,1), where F is the fraction of the length of the intersected edge.  The point then continues on in this way, always heading for the leftmost opposite side of its path and intersecting the segment at a point which is fraction F of its length.  For example, if F = 1/2, the first few points are:\r\n\r\n  P = [0 0;0.5 1;1 0.5;0.5 0;0.25 0.5;.75 .75];\r\n  plot(P(:,1),P(:,2),'*-') \r\n  axis equal\r\n\r\nIf F = 1/3, then the first few positions of the particle are:\r\n\r\n  P = [0 0;1/3 1;1 2/3;2/3 0;1/9 1/3;5/9 8/9];\r\n\r\nWrite a function that takes two inputs and returns two outputs. The first input argument, N, is the Nth location of the particle. The second input argument is the fraction F, where F is on (0,1). The first returned argument is a two element row vector that has the coordinates of the Nth location of the particle as [x,y]. The second returned argument is the limiting value of the particles location as N--\u003einfinity. For example,\r\n\r\n  [P,L] = my_spiral(3,1/2)\r\n\r\nreturns\r\n\r\n  P = [1 0.5] \r\n\r\nand\r\n\r\n  L = [?x? ?y?] \r\n\r\nWhere both values of L are doubles accurate to 100*eps.\r\n","description_html":"\u003cp\u003eImagine a square with corners at the origin and at (1,1).  An interesting spiral can be created by tracing the path of a moving point that starts at the origin and intersects the leftmost opposite edge at a point (F,1), where F is the fraction of the length of the intersected edge.  The point then continues on in this way, always heading for the leftmost opposite side of its path and intersecting the segment at a point which is fraction F of its length.  For example, if F = 1/2, the first few points are:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eP = [0 0;0.5 1;1 0.5;0.5 0;0.25 0.5;.75 .75];\r\nplot(P(:,1),P(:,2),'*-') \r\naxis equal\r\n\u003c/pre\u003e\u003cp\u003eIf F = 1/3, then the first few positions of the particle are:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eP = [0 0;1/3 1;1 2/3;2/3 0;1/9 1/3;5/9 8/9];\r\n\u003c/pre\u003e\u003cp\u003eWrite a function that takes two inputs and returns two outputs. The first input argument, N, is the Nth location of the particle. The second input argument is the fraction F, where F is on (0,1). The first returned argument is a two element row vector that has the coordinates of the Nth location of the particle as [x,y]. The second returned argument is the limiting value of the particles location as N--\u003einfinity. For example,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e[P,L] = my_spiral(3,1/2)\r\n\u003c/pre\u003e\u003cp\u003ereturns\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eP = [1 0.5] \r\n\u003c/pre\u003e\u003cp\u003eand\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eL = [?x? ?y?] \r\n\u003c/pre\u003e\u003cp\u003eWhere both values of L are doubles accurate to 100*eps.\u003c/p\u003e","function_template":"function [y,z] = my_spiral(x)\r\n  y = x;\r\n  z = x;\r\nend","test_suite":"%%\r\n[P,L] = my_spiral(20,1/2);\r\nassert(all(abs(P-[0.5859375,0.484375])\u003c100*eps))\r\nassert(all(abs(L-[0.571428571428571,0.428571428571429])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(11,2/7);\r\nassert(all(abs(P-[0.80841316118284,0.387755102040816])\u003c100*eps))\r\nassert(all(abs(L-[0.538461538461538,0.461538461538462])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(88,9999/11111);\r\nassert(all(abs(P-[0.652150333541218,0.358838287231673])\u003c100*eps))\r\nassert(all(abs(L-[0.645144433154304,0.354855566845696])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(901,987654/1000000);\r\nassert(all(abs(P-[0.666383724185262,0.337637121736288])\u003c100*eps))\r\nassert(all(abs(L-[0.663934355482405,0.336065644517595])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(3,eps);\r\nassert(all(abs(L-[1/2,1/2])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(2,1-eps);\r\nassert(all(abs(L-[2/3,1/3])\u003c100*eps))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":459,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2012-02-05T05:13:12.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-04T00:47:43.000Z","updated_at":"2012-02-05T05:14:10.000Z","published_at":"2012-02-05T05:14:10.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eImagine a square with corners at the origin and at (1,1). An interesting spiral can be created by tracing the path of a moving point that starts at the origin and intersects the leftmost opposite edge at a point (F,1), where F is the fraction of the length of the intersected edge. The point then continues on in this way, always heading for the leftmost opposite side of its path and intersecting the segment at a point which is fraction F of its length. For example, if F = 1/2, the first few points are:\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[P = [0 0;0.5 1;1 0.5;0.5 0;0.25 0.5;.75 .75];\\nplot(P(:,1),P(:,2),'*-') \\naxis equal]]\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 F = 1/3, then the first few positions of the particle are:\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[P = [0 0;1/3 1;1 2/3;2/3 0;1/9 1/3;5/9 8/9];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that takes two inputs and returns two outputs. The first input argument, N, is the Nth location of the particle. The second input argument is the fraction F, where F is on (0,1). The first returned argument is a two element row vector that has the coordinates of the Nth location of the particle as [x,y]. The second returned argument is the limiting value of the particles location as N--\u0026gt;infinity. 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[[P,L] = my_spiral(3,1/2)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ereturns\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[P = [1 0.5]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[L = [?x? ?y?]]]\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\u003eWhere both values of L are doubles accurate to 100*eps.\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":659,"title":"How long is the longest prime diagonal?","description":"Stanislaw Ulam once observed that if the counting numbers are arranged in a spiral, the prime numbers contained in it form a surprising pattern. They appear to cluster along diagonals of the spiral matrix.\r\nGiven n, return the length of the longest diagonal sequence of primes in spiral(n).\r\nExample:\r\n Input  n = 7\r\n Output d = 4\r\nSince isprime(spiral(n)) is\r\n     1     0     0     0     1     0     0\r\n     0     0     0     1     0     0     0\r\n     1     0     1     0     0     0     0\r\n     0     1     0     0     1     1     0\r\n     0     0     1     0     1     0     1\r\n     0     1     0     0     0     1     0\r\n     1     0     0     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: 336.9px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 168.45px; transform-origin: 407px 168.45px; 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: 198.5px 8px; transform-origin: 198.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eStanislaw Ulam once observed that if the counting numbers are\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003earranged in a spiral\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: 111px 8px; transform-origin: 111px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, the prime numbers contained in it form a surprising pattern. They appear to cluster along diagonals of the spiral 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: 256.5px 8px; transform-origin: 256.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven n, return the length of the longest diagonal sequence of primes in spiral(n).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 52px 8.5px; tab-size: 4; transform-origin: 52px 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: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003en = 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: 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: 52px 8.5px; tab-size: 4; transform-origin: 52px 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: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003ed = 4\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: 80px 8px; transform-origin: 80px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSince isprime(spiral(n)) is\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 143.033px; 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 71.5167px; transform-origin: 404px 71.5167px; 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: 168px 8.5px; tab-size: 4; transform-origin: 168px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     1     0     0     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 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     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     1     0     1     0     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 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     1     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 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     1     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 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     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     1     0     0     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 d = prime_spiral(n)\r\n  d = 1;\r\nend","test_suite":"%%\r\nn = 4;\r\nd = 2;\r\n%p = isprime(spiral(n));imagesc(p)\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 7;\r\nd = 4;\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 13;\r\nd = 5;\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 29;\r\nd = 5;\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 52;\r\nd = 6;\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 81;\r\nd = 9;\r\nassert(isequal(prime_spiral(n),d))","published":true,"deleted":false,"likes_count":14,"comments_count":10,"created_by":7,"edited_by":223089,"edited_at":"2022-06-05T19:47:54.000Z","deleted_by":null,"deleted_at":null,"solvers_count":410,"test_suite_updated_at":"2022-06-05T19:47:54.000Z","rescore_all_solutions":false,"group_id":6,"created_at":"2012-05-04T19:16:30.000Z","updated_at":"2026-02-19T11:54:08.000Z","published_at":"2012-06-08T19:08:22.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\u003eStanislaw Ulam once observed that if the counting numbers are\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=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003earranged in a spiral\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, the prime numbers contained in it form a surprising pattern. They appear to cluster along diagonals of the spiral 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\u003eGiven n, return the length of the longest diagonal sequence of primes in spiral(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:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  n = 7\\n Output d = 4]]\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\u003eSince isprime(spiral(n)) 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     0     0     0     1     0     0\\n     0     0     0     1     0     0     0\\n     1     0     1     0     0     0     0\\n     0     1     0     0     1     1     0\\n     0     0     1     0     1     0     1\\n     0     1     0     0     0     1     0\\n     1     0     0     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":2455,"title":"Diagonal of a Spiral Matrix","description":"Write a function that will return same output as diag(spiral(n)). The only exception is that spiral and diag functions are not allowed in your function. Also, loops are not allowed.","description_html":"\u003cp\u003eWrite a function that will return same output as diag(spiral(n)). The only exception is that spiral and diag functions are not allowed in your function. Also, loops are not allowed.\u003c/p\u003e","function_template":"function y=digSpi(n)\r\n\r\n\r\n\r\n\r\nend","test_suite":"s = evalc('type digSpi');\r\n\r\nif ~isempty(regexp(s,'error'))\r\n    error('error using error');\r\nend\r\n\r\nif ~isempty(regexp(s,'assert'))\r\n    error('error using assert');\r\nend\r\n\r\nif ~isempty(regexp(s,'diag'))\r\n    error('error using diag');\r\nend\r\n\r\nif ~isempty(regexp(s,'spiral'))\r\n    error('error using spiral');\r\nend\r\n\r\nif ~isempty(regexp(s,'for'))\r\n    error('error using for');\r\nend\r\n\r\nif ~isempty(regexp(s,'while'))\r\n    error('error using while');\r\nend\r\n\r\n%%\r\n\r\na = diag(spiral(4));\r\nb = digSpi(4);\r\nassert(isequal(a,b));\r\n\r\n%%\r\n\r\na = diag(spiral(5));\r\nb = digSpi(5);\r\nassert(isequal(a,b));\r\n\r\n%%\r\n\r\na = diag(spiral(6));\r\nb = digSpi(6);\r\nassert(isequal(a,b));\r\n\r\n%%\r\n\r\na = diag(spiral(7));\r\nb = digSpi(7);\r\nassert(isequal(a,b));\r\n\r\n%%\r\n\r\na = diag(spiral(8));\r\nb = digSpi(8);\r\nassert(isequal(a,b));","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":111,"test_suite_updated_at":"2014-07-21T18:30:07.000Z","rescore_all_solutions":false,"group_id":31,"created_at":"2014-07-20T08:15:09.000Z","updated_at":"2026-03-04T17:27:33.000Z","published_at":"2014-07-20T08:15:09.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\u003eWrite a function that will return same output as diag(spiral(n)). The only exception is that spiral and diag functions are not allowed in your function. Also, loops are not allowed.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":54780,"title":"Trap a knight","description":"Consider a knight on an infinite chessboard labeled with numbers spiraling outward. A knight starting on the square labeled 1 can reach 8 squares, marked in green below (i.e., squares 10, 12, 14, 16, 18, 20, 22, and 24). Take the smallest of these numbers, or 10. Repeating the step while avoiding squares already visited puts the knight at squares 3, 6, 9, 4, 7, 2, 5, etc. This tour continues until step 2016, when the knight reaches square 2084. At that point the knight is trapped: it has visited all eight possible squares. \r\nWrite a function that takes the starting square and returns the sequence of squares visited by the knight on the tour. \r\n","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: 415.7px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 207.85px; transform-origin: 407px 207.85px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 105px; 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 52.5px; text-align: left; transform-origin: 384px 52.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: 35.7917px 8px; transform-origin: 35.7917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eConsider a \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Knight_(chess)#Movement\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eknight\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: 327.942px 8px; transform-origin: 327.942px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e on an infinite chessboard labeled with numbers spiraling outward. A knight starting on the square labeled 1 can reach 8 squares, marked in green below (i.e., squares 10, 12, 14, 16, 18, 20, 22, and 24). Take the smallest of these numbers, or 10. Repeating the step while avoiding squares already visited puts the knight at squares 3, 6, 9, 4, 7, 2, 5, etc. This tour continues until step 2016, when the knight reaches square 2084. At that point the knight is trapped: it has visited all eight possible squares. \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: 358.867px 8px; transform-origin: 358.867px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that takes the starting square and returns the sequence of squares visited by the knight on the tour. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 271.7px; 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 135.85px; text-align: left; transform-origin: 384px 135.85px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cimg class=\"imageNode\" style=\"vertical-align: baseline;width: 275px;height: 266px\" src=\"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PU3BKcC1HBjMyn/2daxkLiBz/2x4QopCFNCtich/swebCab2JD2NPBj/0rI+hsjh/7D71C2f/2PPUejvfa/O7qTW4/QmKbwD2TqJFpzxg1Mu0ZowbtHy6x9kwIIScmFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixAsWEEGIFigkhxAoUE0KIFSgmhBArUEwIIVagmBBCrEAxIYRYwcoSBISQ+GJrCYIqiwkhhAAOcwghVqCYEEKsQDEhhFiBYkIIsQLFhBBiBYoJIcQKFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixgMj/B1CYpZlf1IqYAAAAAElFTkSuQmCC\" data-image-state=\"image-loaded\" width=\"275\" height=\"266\"\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = trappedKnight(n)\r\n  y = randi(n^2,1,2016);\r\nend","test_suite":"%%\r\nn = 1;\r\ny = trappedKnight(n);\r\ny_correct = [1 10 3 6 9 4 7 2 5 8 11 14 29 32 15 12 27 24 45 20 23 44 41 18 35 38 19 16 33 30 53 26 47 22 43 70 21 40 17 34 13 28 25 46 75 42 69 104 37 62 95 58 55 86 51 48 77 114 73 108 151 68 103 64 67 36 39 66 63 96 59 56 87 52 49 78 115 74 71 106 149 102 99 140 61 94 31 54 85 50 79 116 161 76 113 72 107 150 201 146 65 98 139 60 93 90 129 176 125 82 119 164 217 160 111 154 205 264 331 200 101 142 97 138 187 92 89 128 175 84 81 118 163 216 159 110 153 204 105 148 199 144 147 100 141 190 137 186 91 130 57 88 127 174 83 80 117 162 215 112 109 152 203 262 329 198 195 252 143 192 249 188 135 132 179 234 297 230 123 120 165 218 279 214 157 208 267 334 263 330 259 196 253 318 191 248 313 244 133 180 235 298 177 126 173 122 167 220 281 350 277 158 155 206 265 202 261 328 197 254 145 194 251 316 189 136 185 182 131 134 181 184 239 242 305 238 183 304 237 178 233 296 229 124 121 166 219 280 349 276 211 156 207 266 333 408 491 404 257 322 395 476 317 390 247 312 243 240 303 236 299 232 295 172 169 222 283 352 429 278 213 210 269 336 411 332 407 260 327 256 321 394 475 564 389 246 311 384 241 310 245 314 387 468 309 306 377 302 373 452 369 294 171 168 221 282 351 428 347 212 209 268 335 410 493 406 489 326 323 258 255 320 193 250 315 388 469 558 383 380 459 376 301 372 451 368 231 370 449 366 227 224 285 354 431 516 427 346 273 340 415 270 337 412 495 586 409 492 405 488 325 398 479 568 393 474 563 470 385 308 379 382 461 378 307 460 381 466 555 462 465 554 551 464 553 648 463 550 645 458 375 300 371 450 367 228 225 286 355 432 517 610 513 348 275 272 339 414 497 588 687 494 585 490 403 324 397 478 319 392 473 562 659 764 557 654 759 650 653 552 647 548 457 374 453 540 635 448 293 170 223 284 353 430 515 426 345 342 271 274 341 344 419 422 505 418 343 424 509 420 423 508 599 504 417 338 413 496 587 686 583 682 487 400 481 396 477 566 391 472 561 386 467 556 657 560 471 660 559 656 761 652 649 752 549 644 545 454 541 636 537 446 291 288 357 434 519 612 713 514 425 510 421 598 503 416 499 590 689 796 685 582 681 486 483 402 399 480 569 666 565 662 767 658 763 876 655 760 651 754 865 646 547 456 543 638 539 634 447 292 289 358 435 520 613 714 609 512 605 706 507 604 511 608 709 818 603 506 597 502 593 498 589 688 795 584 683 580 401 482 571 668 567 664 769 882 661 766 879 762 875 758 755 866 751 862 643 544 639 742 853 738 535 364 361 226 287 356 433 518 611 712 607 708 817 602 701 704 811 600 699 596 501 592 691 798 913 794 909 684 581 680 485 574 671 570 667 772 663 768 881 1002 765 878 999 874 757 868 753 864 749 546 455 542 637 538 633 534 363 360 437 522 615 716 825 942 711 606 707 816 601 700 807 696 803 594 693 500 591 690 797 912 793 908 789 578 575 672 777 572 669 774 665 770 883 1004 1133 880 1001 1130 877 998 873 756 867 986 863 748 641 744 855 740 851 632 445 290 359 436 521 614 715 824 941 710 819 936 705 702 809 698 595 694 801 916 1039 1170 911 792 907 788 577 484 573 670 775 888 771 884 1005 1134 1271 1000 1129 996 871 990 1117 1252 985 750 861 642 745 856 741 852 737 536 365 444 441 526 619 438 523 616 717 826 943 822 939 1064 935 814 929 810 703 928 813 934 1059 930 933 812 815 932 1055 1058 1189 1054 927 808 697 804 919 692 799 914 1037 910 791 906 679 576 579 678 675 780 893 776 889 1010 773 886 1007 1136 1003 1132 1269 1128 995 870 989 1116 1251 984 1111 860 979 746 857 640 743 854 739 850 631 532 529 362 439 524 617 718 827 944 823 940 1065 820 937 1062 1195 1336 1057 1188 931 1060 1193 1056 1187 1052 925 806 695 802 917 1040 1171 1036 1167 1032 905 786 783 674 779 892 1013 1142 887 1008 1137 1274 1419 1270 1415 1266 997 872 869 988 1115 1250 983 1110 859 978 1105 974 1101 970 735 628 443 440 525 618 719 828 945 1070 1203 1066 821 938 1063 1196 1337 1192 1331 1334 1481 1190 1329 1186 1051 924 805 920 1043 800 915 1038 1169 1034 1165 1030 787 676 781 894 673 778 891 1012 1141 1278 1009 1138 885 1006 1135 1272 1131 1268 1127 994 991 1118 987 1114 1249 982 747 858 977 1104 973 1100 849 630 531 528 621 722 831 948 1073 1206 1069 1202 1343 1198 1061 1194 1335 1332 1479 1328 1053 926 1049 922 1045 918 1041 1172 1311 1168 1033 790 1031 904 677 782 895 1016 1145 890 1011 1140 1277 1422 1273 1418 1571 1414 1265 1124 1121 1256 1399 1550 1253 1396 1113 1248 981 1108 1243 976 1103 972 1099 848 629 442 527 620 721 830 947 1072 1205 1068 1201 1342 1197 1338 1487 1644 1333 1480 1191 1330 1477 1326 1183 1048 921 1044 1175 1314 1461 1310 1035 1166 1305 1162 903 784 897 1018 1147 1014 1143 1280 1139 1276 1421 1574 1417 1570 1267 1126 993 1120 1255 1398 1549 1394 1247 980 1107 1242 975 1102 971 736 533 734 627 624 725 834 951 720 829 946 1071 1204 1067 1200 1341 1490 1647 1486 1643 1482 1485 1642 1639 1484 1641 1804 1483 1638 1801 1478 1327 1184 1323 1050 923 1046 1177 1042 1173 1312 1459 1308 1455 1164 1029 902 899 1020 1149 896 1017 1146 1283 1428 1279 1424 1275 1420 1573 1416 1569 1412 1125 992 1119 1254 1397 1548 1393 1112 1395 1546 1391 1244 1109 1390 1541 1386 1239 1382 1235 968 733 530 623 724 833 950 1075 1208 1349 1498 1345 1494 1199 1340 1489 1646 1811 1984 1807 1640 1803 1636 1799 1476 1185 1324 1181 1320 1047 1178 1317 1174 1313 1460 1309 1456 1611 1304 1161 1026 785 898 1019 1148 1015 1144 1281 1426 1579 1740 1423 1576 1737 1572 1733 1568 1411 1262 1259 1402 1553 1712 1879 1708 1545 1246 1389 1106 1241 1384 1237 1098 847 732 625 726 835 622 723 832 949 1074 1207 1348 1497 1344 1493 1650 1339 1488 1645 1810 1983 1806 1809 1982 1979 1808 1805 1976 1637 1800 1633 1474 1629 1322 1179 1318 1465 1176 1315 1462 1617 1458 1307 1454 1163 1028 901 1022 1151 1288 1433 1284 1429 1582 1425 1578 1739 1908 1575 1736 1905 1732 1413 1264 1123 1258 1401 1552 1711 1878 1547 1392 1245 1388 1539 1240 1383 1236 969 846 731 728 837 954 1079 1212 1353 1076 1209 1350 1499 1346 1495 1652 1491 1648 1813 1986 2167 2356 1981 2160 1977 1802 1635 1798 1475 1630 1325 1182 1321 1468 1623 1316 1463 1618 1781 1614 1777 1610 1303 1160 1025 900 1021 1150 1287 1432 1585 1282 1427 1580 1741 1910 1577 1738 1907 1734 1903 1730 1565 1408 1263 1122 1257 1400 1551 1710 1877 1706 1543 1702 1387 1538 1697 1534 1379 1096 845 626 727 836 953 1078 1211 1352 1501 1658 1347 1496 1653 1492 1649 1814 1987 2168 2357 2164 2161 1978 2157 1974 2153 1970 1631 1472 1627 1790 1467 1622 1785 1464 1619 1782 1615 1778 1457 1306 1453 1302 1027 1024 1153 1290 1435 1286 1431 1584 1745 1914 1581 1742 1911 2088 2273 1906 2083 1902 1567 1410 1261 1404 1555 1714 1881 2056 1709 1876 1705 1542 1701 1868 1537 1238 1381 1234 967 844 729 838 955 1080 1213 952 1077 1210 1351 1500 1657 1822 1995 1654 1819 1992 1651 1816 1989 1812 1985 2166 2355 2162 2165 1980 2159 2346 1975 2154 1971 1632 1473 1628 1469 1180 1319 1466 1621 1784 1955 1616 1779 1612 1775 1452 1301 1158 1155 1292 1023 1152 1289 1434 1285 1430 1583 1744 1913 2090 1909 2086 1735 1904 1731 1566 1409 1260 1403 1554 1713 1880 2055 2238 1875 1544 1703 1540 1385 1536 1695 1380 1097 966 843 840 957 1082 1215 1356 1505 1662 1827 1502 1659 1824 1655 1820 1993 2174 1815 1988 2169 2358 2555 2354 2351 2546 2347 2156 1973 1634 1797 1968 1793 1470 1625 1788 1959 1620 1783 1954 2133 1780 1613 1776 1609 1450 1159 1156 1293 1438 1591 1752 1587 1748 1917 2094 1743 1912 2089 2274 2085 2270 2081 1900 1727 1562 1559 1718 1405 1556 1715 1882 2057 2240 2053 1874 1707 2052 1873 2048 1869 1698 1535 1694 1531 1232 965 730 839 956 1081 1214 1355 1504 1661 1826 1999 1656 1821 1994 1817 1990 2171 2360 2557 2762 2553 2352 2547 2348 2543 2158 2345 2540 2155 1972 2151 1796 1967 1792 1471 1626 1789 1960 2139 1786 1957 2136 1953 2132 1949 1774 1451 1300 1157 1294 1439 1154 1291 1436 1589 1750 1919 1586 1747 1916 2093 2278 2471 2672 2275 2468 2087 2272 2465 2082 1901 1728 1563 1406 1557 1716 1883 2058 2241 2054 2237 2050 1871 1700 1867 1696 1533 1378 1095 964 841 958 1083 1216 1357 1506 1663 1354 1503 1660 1825 1998 2179 2368 2175 1818 1991 2172 2361 2558 2763 2554 2163 2350 2545 2748 2541 2342 2537 2150 1795 1966 1791 1624 1787 1958 2137 2324 2519 2134 1951 2130 1947 1608 1449 1298 1295 1440 1593 1754 1437 1590 1751 1920 2097 1746 1915 2092 2277 2470 2671 2466 2269 2080 1729 1564 1407 1558 1717 1884 2059 2242 2433 2632 2239 2430 2051 1704 2049 1870 1699 1866 2041 1862 1691 1376 1093 842 959 1084 1217 1358 1507 1664 1829 2002 2183 2372 1997 2178 2367 2564 2173 2362 2559 2170 2359 2556 2761 2552 2549 2752 2349 2544 2747 2344 2539 2152 1969 1794 1965 2144 1961 2140 2327 1956 2135 1952 2131 1948 1773 1606 1299 1296 1441 1594 1755 1924 2101 2286 1921 1588 1749 1918 2095 2280 2091 2276 2469 2670 2271 2464 2267 2078 1897 1724 1721 1888 2063 2246 1885 2060 2243 2434 2633 2840 2429 2234 2047 1872 2233 2046 2229 2042 1863 1532 1233 1094 963 960 1085 1218 1359 1508 1665 1830 2003 2184 2373 2000 1823 1996 2177 2366 2563 2768 2363 2560 2765 2978 3199 2760 2353 2548 2751 2962 3181 2746 2343 2538 2339 2148 2335 1964 2143 2330 2525 2138 2325 2520 2321 1950 2129 1946 1607 1448 1297 1442 1595 1756 1925 1592 1753 1922 2099 2284 2477 2096 2281 2474 2675 2884 3101 2880 2467 2084];\r\nlen_correct = 2016;\r\nyend_correct = 2084;\r\nassert(isequal(y,y_correct) \u0026\u0026 isequal(length(y),len_correct) \u0026\u0026 isequal(y(end),yend_correct))\r\n\r\n%%\r\nY = NaN(1,100); len = NaN(1,100);\r\nfor n = 1:100\r\n    y = trappedKnight(n);\r\n    Y(n) = y(end);\r\n    len(n) = length(y);\r\nend\r\nY_correct = [2084 711 3915 556 3915 556 3915 3380 2086 1339 1464 1572 4772 582 3959 682 2309 385 330 1142 706 2750 4256 4322 1413 1488 1685 6335 5214 906 2616 1038 582 1608 2675 6266 1120 3955 936 2773 1861 2213 2223 262 1147 4428 1126 3319 1040 1693 3614 1647 4122 2121 3496 2555 2508 5174 2961 1338 1607 4252 2826 1731 3915 2130 938 762 835 3437 708 1653 1133 4168 3918 150 1204 3087 1438 445 3104 969 906 822 3404 2922 125 329 3214 6185 3912 2181 1093 1379 4586 5335 790 3038 5262 3141];\r\nlen_correct = [2016 880 2741 857 2741 857 2741 3611 2590 1540 1846 2061 4892 1047 4139 753 3559 590 426 1205 1140 2759 3830 4687 1839 2101 2861 5892 5500 1295 2674 1213 890 1839 2749 6531 1118 3632 1496 2888 1995 2574 2713 495 1479 5509 1414 3926 1078 2344 4244 1932 4054 3382 4084 3410 4144 4079 2223 1151 1799 4863 3162 2292 2741 2271 840 1087 1397 2752 990 1664 1775 3915 5704 263 1658 2840 1510 486 3620 1146 1288 969 3688 3745 311 586 3146 5480 5116 2472 1473 1910 5128 5938 1128 4367 4412 5036];\r\nassert(isequal(len,len_correct) \u0026\u0026 isequal(Y,Y_correct))\r\n\r\n%%\r\nY = NaN(1,800); len = NaN(1,800);\r\nfor n = 200:1000\r\n    y = trappedKnight(n);\r\n    Y(n-199) = y(end);\r\n    len(n-199) = length(y);\r\nend\r\n[lensort,isortlen] = sort(len,'descend');\r\n[Ysort,isortY] = sort(Y,'descend');\r\nisortlen_correct = [396 662 246 49 125 462 267 336 683 797];\r\nlenmax10_correct = [12072 11058 10654 10553 10337 10031 9552 9469 9292 9259];\r\nisortY_correct = [662 683 267 246 396 497 49 443 541 462];\r\nYmax10_correct = [14176 12571 12303 11858 11802 11456 11168 10624 9594 8857];\r\nassert(isequal(lensort(1:10),lenmax10_correct) \u0026\u0026 isequal(Ysort(1:10),Ymax10_correct) \u0026\u0026 isequal(isortlen(1:10),isortlen_correct) \u0026\u0026 isequal(isortY(1:10),isortY_correct))\r\n\r\n%%\r\nn = 9999;\r\ny = trappedKnight(n);\r\nsum_correct = 77968774;\r\nassert(isequal(sum(y),sum_correct))\r\n\r\n%%\r\nn = 11509;\r\ny = trappedKnight(n);\r\nlen_correct = 21346;\r\nassert(isequal(length(y),len_correct))\r\n\r\n%%\r\nfiletext = fileread('trappedKnight.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'switch') || contains(filetext,'regexp'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":46909,"edited_by":46909,"edited_at":"2024-01-04T14:21:04.000Z","deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-07-07T04:01:20.000Z","updated_at":"2026-02-03T16:00:59.000Z","published_at":"2022-07-07T04:03:44.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\u003eConsider a \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Knight_(chess)#Movement\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eknight\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e on an infinite chessboard labeled with numbers spiraling outward. A knight starting on the square labeled 1 can reach 8 squares, marked in green below (i.e., squares 10, 12, 14, 16, 18, 20, 22, and 24). Take the smallest of these numbers, or 10. Repeating the step while avoiding squares already visited puts the knight at squares 3, 6, 9, 4, 7, 2, 5, etc. This tour continues until step 2016, when the knight reaches square 2084. At that point the knight is trapped: it has visited all eight possible squares. \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\u003eWrite a function that takes the starting square and returns the sequence of squares visited by the knight on the tour. \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:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"266\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"275\\\"/\u003e\u003cw:attr w:name=\\\"verticalAlign\\\" w:val=\\\"baseline\\\"/\u003e\u003cw:attr w:name=\\\"altText\\\" w:val=\\\"\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"target\":\"/media/image1.png\",\"relationshipId\":\"rId1\"}]},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARMAAAEKCAYAAAAxcLHrAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAACakSURBVHhe7Z0JlBVFlvcvgoCg1ZSAgrLaNKAgwijDSNsfwkGwWz7E+pByBXWAUUBpFWRxoMRqUWRxRJFulpHNBcpWx6UFsS2X07YMMtCArSAqCN0igiB7Idpf/jMiqrKer+q9lxUvF+b/OydPRObLfLy6GfmPG/dGBtX+4SCEEFJFTtIlIYRUCYoJIcQKFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixAsWEEGIFigkhxAoUE0KIFar8bk6nDj+TdRu26L34UeuUmlJy5Jjeix91a4scOqp3YgjtHy4dz28la9d/oveqRpXFpFq1anJshd6JITV7iyz9ywy9Fz/yL7iL9g+RE8H+tt715TCHEGIFigkhxAoUE0KIFSgmhBArUEwIIVagmBBCrEAxIYRYgWJCCLECxYQQYgWKCSHEChQTQogVKCaEECtQTAghVqCYEEKsEMoSBMXrRKY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vafznHLoKjqPAcwaZEqwxhyprJ/q/bNSl9XSLZdfu0v3PPyhvR09xHLCjJ1b8P+i1aqEnOtEuNaQRK6mGQ6Zpz/miphuDzVDkIlHc8EjbPHVSpW8tR/vCLbNv3drQOkLKff+aQbTMY7OxCToFxskI798S7JjQ8ln0+CdKUZchp3O0iqGvMIO5uTjv1h4/6TkgdYpxWV2d87tT4Mqv2jiv8FerVq1dzIcrpgbsh8z9ve3qCdeRMSnun04T8ewqAxY04DwJTkxHcV/IB8PXqkdEG25eUFxVL3J8p99rrKSPUeP3ZcatSsIbfed0259z4gEMN6TSodv0M4cnLruu62Ae+aYIp4JmCeSrbtj8ZsvEFgzvNe6/d+BGX/ikCMBN8JzyR/xK/00fQJwv64ZoSauOuSzP541wdT9DMF9q+iBJQSuGeSOOnJizn29vrk7xm8s1GViF6HNUkNc0YQ+0AjTjbmNmPxI2aOswOEBN7J7/44yW209XPU3BKcC1HBjMyn/2daxkLiBz/2x4QopCFNCtich/swebCab2JD2NPBj/0rI+hsjh/7D71C2f/2PPUejvfa/O7qTW4/QmKbwD2TqJFpzxg1Mu0ZowbtHy6x9kwIIScmFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixAsWEEGIFigkhxAoUE0KIFSgmhBArUEwIIVagmBBCrEAxIYRYwcoSBISQ+GJrCYIqiwkhhAAOcwghVqCYEEKsQDEhhFiBYkIIsQLFhBBiBYoJIcQKFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixgMj/B1CYpZlf1IqYAAAAAElFTkSuQmCC\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":45453,"title":"Spiral Out - 02","description":"An array is given. Convert it into a spiral matrix.\r\nFor example, a=1:27;\r\n out=[21    22    23    24    25    26\r\n      20     7     8     9    10    27\r\n      19     6     1     2    11     0\r\n      18     5     4     3    12     0\r\n      17    16    15    14    13     0\r\n       0     0     0     0     0     0]\r\nadd necessary amount of zeros to fill in the remaining positions.\r\nNote - spiral() is forbidden.","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: 244.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 122.3px; transform-origin: 407px 122.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: 148.5px 8px; transform-origin: 148.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAn array is given. Convert it into a spiral 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: 67px 8px; transform-origin: 67px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example, a=1:27;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; 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 61.3px; transform-origin: 404px 61.3px; 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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e out=[21    22    23    24    25    26\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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e      20     7     8     9    10    27\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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e      19     6     1     2    11     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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e      18     5     4     3    12     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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e      17    16    15    14    13     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: 156px 8.5px; tab-size: 4; transform-origin: 156px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0     0     0     0     0     0]\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: 200px 8px; transform-origin: 200px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eadd necessary amount of zeros to fill in the remaining positions.\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: 84px 8px; transform-origin: 84px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote - spiral() is forbidden.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = spi_out_3(p)","test_suite":"%%\r\np= 1:27;\r\ny= [21    22    23    24    25    26\r\n      20     7     8     9    10    27\r\n      19     6     1     2    11     0\r\n      18     5     4     3    12     0\r\n      17    16    15    14    13     0\r\n       0     0     0     0     0     0];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np= 49:-1:1;\r\ny= [7     6     5     4     3     2     1\r\n     8    29    28    27    26    25    24\r\n     9    30    43    42    41    40    23\r\n    10    31    44    49    48    39    22\r\n    11    32    45    46    47    38    21\r\n    12    33    34    35    36    37    20\r\n    13    14    15    16    17    18    19];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np=[4074\t4529\t635\t4567\t3162\t488\t1393\t2735\t4788\t4825\t789\t4853\t4786\t2427\t4002\t710\t2109\t4579\t3962\t4798\t3279\t179\t4246\t4670\t3394\t3789\t3716\t1962\t3278\t856\t3531\t160\t1385\t231\t486\t4118\t3475\t1586\t4752\t173\t2194\t1908\t3828\t3976\t935\t2449\t2228\t3232\t3547\t3774\t1381\t3399\t3276\t814\t595\t2492\t4799\t1702\t2927\t1120\t3757\t1276\t2530\t3496\t4455\t4797\t2737\t694\t747\t1288\t4204\t1272\t4072\t1218\t4647\t1750\t983\t1256\t3081\t2367\t1759\t4155\t2927\t2749\t4586\t1430\t3787\t3769\t1903\t2840\t380\t270\t2654\t3896\t4671\t650\t2845\t2347\t60\t1686\t811\t3972\t1557\t2643\t829\t3010\t1315\t3271\t3447\t3741\t2253\t420\t1145\t4567\t762\t4130\t2692\t4981\t391\t2214\t534\t4810\t24\t3875\t4087\t4344\t423\t1999\t1300\t4001\t2158\t4554\t910\t1320\t728\t681\t4347\t2899\t2750\t725\t4266\t3111\t1755\t2567\t2010\t380\t1200\t617\t920\t1200\t2087\t249\t4514\t4724\t2455\t2447\t1689\t4501\t1847\t557\t3902\t1949\t1209\t2020\t483\t660\t4711\t4781\t2877\t299\t1174\t1766\t4106\t78\t216\t845\t3246\t3659\t3239\t2255\t2736\t1482\t3724\t945\t3434\t918\t1843\t3129\t3902\t406\t4647\t3879\t2434\t2180\t2234\t1532\t2543\t2554\t4089\t3975];\r\ny= [0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\r\n0\t1689\t4501\t1847\t557\t3902\t1949\t1209\t2020\t483\t660\t4711\t4781\t2877\t299\r\n0\t2447\t2253\t420\t1145\t4567\t762\t4130\t2692\t4981\t391\t2214\t534\t4810\t1174\r\n0\t2455\t3741\t4072\t1218\t4647\t1750\t983\t1256\t3081\t2367\t1759\t4155\t24\t1766\r\n0\t4724\t3447\t1272\t3828\t3976\t935\t2449\t2228\t3232\t3547\t3774\t2927\t3875\t4106\r\n0\t4514\t3271\t4204\t1908\t3279\t179\t4246\t4670\t3394\t3789\t1381\t2749\t4087\t78\r\n0\t249\t1315\t1288\t2194\t4798\t1393\t2735\t4788\t4825\t3716\t3399\t4586\t4344\t216\r\n0\t2087\t3010\t747\t173\t3962\t488\t4074\t4529\t789\t1962\t3276\t1430\t423\t845\r\n0\t1200\t829\t694\t4752\t4579\t3162\t4567\t635\t4853\t3278\t814\t3787\t1999\t3246\r\n0\t920\t2643\t2737\t1586\t2109\t710\t4002\t2427\t4786\t856\t595\t3769\t1300\t3659\r\n0\t617\t1557\t4797\t3475\t4118\t486\t231\t1385\t160\t3531\t2492\t1903\t4001\t3239\r\n3975\t1200\t3972\t4455\t3496\t2530\t1276\t3757\t1120\t2927\t1702\t4799\t2840\t2158\t2255\r\n4089\t380\t811\t1686\t60\t2347\t2845\t650\t4671\t3896\t2654\t270\t380\t4554\t2736\r\n2554\t2010\t2567\t1755\t3111\t4266\t725\t2750\t2899\t4347\t681\t728\t1320\t910\t1482\r\n2543\t1532\t2234\t2180\t2434\t3879\t4647\t406\t3902\t3129\t1843\t918\t3434\t945\t3724];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np= pascal(6);\r\np=p(:)';\r\ny= [10    20    35    56     1     5\r\n     4     1     2     3     4    15\r\n     1     1     1     1     5    35\r\n    21     1     1     1     6    70\r\n    15    10     6     3     1   126\r\n   252   126    56    21     6     1];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np= eye(6);\r\np=p(:)'\r\ny= [0     1     0     0     0     0\r\n     0     0     1     0     0     0\r\n     0     0     1     0     0     0\r\n     0     0     0     0     0     1\r\n     0     0     1     0     0     0\r\n     1     0     0     0     0     0];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np= [-84  -132   -54  -104  -137   -31   -42  -101   -88   -94  -163  -146  -115,-159   -48];\r\ny= [-42  -101   -88   -94\r\n   -31   -84  -132  -163\r\n  -137  -104   -54  -146\r\n     0   -48  -159  -115];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\nfiletext = fileread('spi_out_3.m');\r\nassert(isempty(strfind(filetext, 'spiral')),'spiral() forbidden')","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":363598,"edited_by":223089,"edited_at":"2022-07-02T18:04:44.000Z","deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-04-14T02:57:42.000Z","updated_at":"2022-07-02T18:04:44.000Z","published_at":"2020-04-14T02:57:42.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\u003eAn array is given. Convert it into a spiral 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, a=1:27;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ out=[21    22    23    24    25    26\\n      20     7     8     9    10    27\\n      19     6     1     2    11     0\\n      18     5     4     3    12     0\\n      17    16    15    14    13     0\\n       0     0     0     0     0     0]]]\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\u003eadd necessary amount of zeros to fill in the remaining positions.\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\u003eNote - spiral() is forbidden.\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":2342,"title":"Numbers spiral diagonals (Part 2)","description":"Inspired by Project Euler n°28 and 58.\r\nA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\r\nFor example with n=5, the spiral matrix is :\r\n                       21 22 23 24 25\r\n                       20  7  8  9 10\r\n                       19  6  1  2 11\r\n                       18  5  4  3 12\r\n                       17 16 15 14 13\r\nThe sum of the numbers on the diagonals is 101 (See problem 2340) and you have 5 primes (3, 5, 7, 13, 17) out of the 9 numbers lying along both diagonals. So the prime ratio is 5/9 ≈ 55%.\r\nWith a 7x7 spiral matrix, the ratio is 62% (8 primes out of the 13 diagonal numbers).\r\nWhat is the side length (always odd and greater than 1) of the square spiral for which the ratio of primes along both diagonals FIRST falls below p% ? (0\u003cp\u003c1)","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: 326.167px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 163.083px; transform-origin: 407px 163.083px; 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: 120px 8px; transform-origin: 120px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInspired by Project Euler n°28 and 58.\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: 341px 8px; transform-origin: 341px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\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: 131.5px 8px; transform-origin: 131.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example with n=5, the spiral matrix is :\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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       21 22 23 24 25\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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       20  7  8  9 10\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       19  6  1  2 11\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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       18  5  4  3 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: 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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       17 16 15 14 13\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; 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: 382.5px 8px; transform-origin: 382.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe sum of the numbers on the diagonals is 101 (See problem 2340) and you have 5 primes (3, 5, 7, 13, 17) out of the 9 numbers lying along both diagonals. So the prime ratio is 5/9 ≈ 55%.\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: 262px 8px; transform-origin: 262px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWith a 7x7 spiral matrix, the ratio is 62% (8 primes out of the 13 diagonal numbers).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 364.5px 8px; transform-origin: 364.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"perspective-origin: 74px 8px; transform-origin: 74px 8px; \"\u003eWhat is the side length \u003c/span\u003e\u003cspan style=\"border-block-end-style: solid; border-block-end-width: 1px; border-bottom-style: solid; border-bottom-width: 1px; perspective-origin: 2.5px 8.5px; transform-origin: 2.5px 8.5px; \"\u003e(\u003c/span\u003e\u003cspan style=\"perspective-origin: 96px 8px; transform-origin: 96px 8px; \"\u003ealways odd and greater than 1\u003c/span\u003e\u003cspan style=\"border-block-end-style: solid; border-block-end-width: 1px; border-bottom-style: solid; border-bottom-width: 1px; perspective-origin: 2.5px 8.5px; transform-origin: 2.5px 8.5px; \"\u003e)\u003c/span\u003e\u003cspan style=\"perspective-origin: 189.5px 8px; transform-origin: 189.5px 8px; \"\u003e of the square spiral for which the ratio of primes along both diagonals FIRST falls below p% ? (0\u0026lt;p\u0026lt;1)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function res=spiral_ratio(pourcentage)\r\nres=pourcentage*2;\r\nend","test_suite":"%%\r\nx = 0.8;\r\ny_correct = 3;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.5;\r\ny_correct = 11;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.4;\r\ny_correct = 31;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.3;\r\ny_correct = 49;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.25;\r\ny_correct = 99;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.2;\r\ny_correct = 309;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.15;\r\ny_correct = 981;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.14;\r\ny_correct = 1883;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.13;\r\ny_correct = 3593;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.12;\r\ny_correct = 6523;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.11;\r\ny_correct = 12201;\r\nassert(isequal(spiral_ratio(x),y_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":5,"created_by":5390,"edited_by":223089,"edited_at":"2022-09-26T17:42:20.000Z","deleted_by":null,"deleted_at":null,"solvers_count":196,"test_suite_updated_at":"2022-07-09T19:28:50.000Z","rescore_all_solutions":false,"group_id":31,"created_at":"2014-05-31T18:36:25.000Z","updated_at":"2026-03-04T11:06:42.000Z","published_at":"2014-05-31T18:53:35.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\u003eInspired by Project Euler n°28 and 58.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\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 with n=5, the spiral matrix 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[                       21 22 23 24 25\\n                       20  7  8  9 10\\n                       19  6  1  2 11\\n                       18  5  4  3 12\\n                       17 16 15 14 13]]\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\u003eThe sum of the numbers on the diagonals is 101 (See problem 2340) and you have 5 primes (3, 5, 7, 13, 17) out of the 9 numbers lying along both diagonals. So the prime ratio is 5/9 ≈ 55%.\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\u003eWith a 7x7 spiral matrix, the ratio is 62% (8 primes out of the 13 diagonal numbers).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhat is the side length (always odd and greater than 1) of the square spiral for which the ratio of primes along both diagonals FIRST falls below p% ? (0\u0026lt;p\u0026lt;1)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":2597,"title":"Alternative Scoring. Create an incremental spiral.","description":"This problem is created to test an alternative Cody scoring system. It is based on the current one, but few changes are introduced. The main difference is that strings generate nearly same size as other arrays so '12345'-'0' won't be smaller than [1 2 3 4 5]. There is also improvement of scoring when _ans_ is used.\r\n\r\nYour goal is to write a function that *for given n* creates *spiral matrix like in problem \u003chttp://www.mathworks.com/matlabcentral/cody/problems/944 944\u003e.* You can choose one or more ways to do this: \r\n\r\n* Clean Code - without any kind of cheating,\r\n* Small Size - using cheats based on scoring system like _regexp_ or _'chars'-'0'_,\r\n* Hack+100 - if you really want, I can't stop you from hacking this problem, set size to 100 in this case, please.\r\n\r\nEnjoy!\r\n\r\nThis problem is related to problems  \u003chttp://www.mathworks.com/matlabcentral/cody/problems/944 944\u003e, \u003chttp://www.mathworks.com/matlabcentral/cody/problems/2033 2033\u003e, \u003chttp://www.mathworks.co.uk/matlabcentral/cody/problems/2390 2390\u003e, ... and others which I don't remember now :-)","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: 256.3px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 128.15px; transform-origin: 407px 128.15px; 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: 374.5px 8px; transform-origin: 374.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem is created to test an alternative Cody scoring system. It is based on the current one, but few changes are introduced. The main difference is that strings generate nearly same size as other arrays so '12345'-'0' won't be smaller than [1 2 3 4 5]. There is also improvement of scoring when\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 11.5px 8px; transform-origin: 11.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eans\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e is used.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 108.5px 8px; transform-origin: 108.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYour goal is to write a function that\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 38.5px 8px; transform-origin: 38.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003efor given n\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 25.5px 8px; transform-origin: 25.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e creates\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 97px 8px; transform-origin: 97px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003espiral matrix like in problem\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"http://www.mathworks.com/matlabcentral/cody/problems/944\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"font-weight: 700; \"\u003e944\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e.\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 94.5px 8px; transform-origin: 94.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e You can choose one or more ways to do this:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 61.3px; counter-reset: list-item 0; font-family: Helvetica, Arial, sans-serif; list-style-type: square; margin-block-end: 20px; margin-block-start: 10px; margin-bottom: 20px; margin-top: 10px; perspective-origin: 391px 30.65px; transform-origin: 391px 30.65px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 133.5px 8px; transform-origin: 133.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eClean Code - without any kind of cheating,\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 171.5px 8px; transform-origin: 171.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSmall Size - using cheats based on scoring system like\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 21.5px 8px; transform-origin: 21.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eregexp\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 8.5px 8px; transform-origin: 8.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e or\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 30px 8px; transform-origin: 30px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"font-style: italic; \"\u003e'chars'-'0'\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4333px; counter-reset: none; display: list-item; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-start: 56px; margin-left: 56px; margin-top: 0px; perspective-origin: 363px 10.2167px; text-align: left; transform-origin: 363px 10.2167px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 339px 8px; transform-origin: 339px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eHack+100 - if you really want, I can't stop you from hacking this problem, set size to 100 in this case, please.\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003c/ul\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: 20px 8px; transform-origin: 20px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eEnjoy!\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: 113px 8px; transform-origin: 113px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis problem is related to problems \u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"http://www.mathworks.com/matlabcentral/cody/problems/944\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e944\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"http://www.mathworks.com/matlabcentral/cody/problems/2033\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e2033\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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e,\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"http://www.mathworks.co.uk/matlabcentral/cody/problems/2390\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003e2390\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: 144px 8px; transform-origin: 144px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, ... and others which I don't remember now :-)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = inv_spiral(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nx = 1;\r\ny_correct = 1;\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 2;\r\ny_correct = [1 2\r\n             4 3];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 3;\r\ny_correct = [1 2 3\r\n             8 9 4\r\n             7 6 5];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 4;\r\ny_correct = [ 1  2  3 4\r\n             12 13 14 5\r\n             11 16 15 6\r\n             10  9  8 7];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = [1  2  3  4  5\r\n             16 17 18 19 6\r\n             15 24 25 20 7\r\n             14 23 22 21 8\r\n             13 12 11 10 9];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 6;\r\ny_correct = [1  2  3  4  5  6\r\n            20 21 22 23 24  7\r\n            19 32 33 34 25  8\r\n            18 31 36 35 26  9\r\n            17 30 29 28 27 10\r\n            16 15 14 13 12 11];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 7;\r\ny_correct = [1  2  3  4  5  6  7\r\n            24 25 26 27 28 29  8\r\n            23 40 41 42 43 30  9\r\n            22 39 48 49 44 31 10\r\n            21 38 47 46 45 32 11\r\n            20 37 36 35 34 33 12\r\n            19 18 17 16 15 14 13];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%%\r\nx = 8;\r\ny_correct = [1  2  3  4  5  6  7  8\r\n            28 29 30 31 32 33 34  9\r\n            27 48 49 50 51 52 35 10\r\n            26 47 60 61 62 53 36 11\r\n            25 46 59 64 63 54 37 12\r\n            24 45 58 57 56 55 38 13\r\n            23 44 43 42 41 40 39 14\r\n            22 21 20 19 18 17 16 15];\r\nassert(isequal(inv_spiral(x),y_correct))\r\n%% \r\n%\r\n%  size_old = feval(@evalin,'caller','score');\r\n%\r\n%\r\n% ________SCORING_SYSTEM___________________\r\n%\r\n%  all_nodes = mtree('inv_spiral.m','-file');\r\n%  str_nodes = mtfind(all_nodes,'Kind','STRING');\r\n%   eq_nodes = mtfind(all_nodes,'Kind','EQUALS');\r\n%print_nodes = mtfind(all_nodes,'Kind','PRINT');\r\n% expr_nodes = mtfind(all_nodes,'Kind','EXPR');\r\n%\r\n%       size = count(all_nodes)           ...\r\n%              +sum(str_nodes.nodesize-1) ...\r\n%              +2*(count(expr_nodes)      ...\r\n%                  +count(print_nodes)    ...\r\n%                  -count(eq_nodes));\r\n%\r\n%\r\n%  feval(@assignin,'caller','score',size);\r\n%\r\n% _________________________________________\r\n%\r\n%\r\n%fprintf('Size in standard cody scoring is %i.\\n',size_old);\r\n%fprintf('Size in proposed cody scoring is %i.\\n',size);\r\n%\r\n%if size==size_old\u0026\u0026size~=100\r\n%  disp('Clean Code!'); % ... or dirty hack\r\n%elseif size\u003esize_old\r\n%  disp('Tried tricks?'); \r\n%elseif size==100\u0026\u0026old_size==100\r\n%  disp('You hacked it! or it is a nice coincidence');\r\n%elseif size\u003csize_old\r\n%  disp('Something went wrong with scoring. (or you hacked it!)');\r\n%else\r\n%  disp('Master of Chaos.');\r\n%end\r\n%\r\n% This testsuite may be improved in the future.\r\n%\r\n%_________RESULT_____________________________","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":14358,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":19,"test_suite_updated_at":"2020-11-18T11:39:09.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2014-09-18T16:49:08.000Z","updated_at":"2025-12-08T02:47:55.000Z","published_at":"2014-09-18T16:49:08.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\u003eThis problem is created to test an alternative Cody scoring system. It is based on the current one, but few changes are introduced. The main difference is that strings generate nearly same size as other arrays so '12345'-'0' won't be smaller than [1 2 3 4 5]. There is also improvement of scoring when\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\u003eans\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e is used.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYour goal is to write a function that\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\u003efor given n\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e creates\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\u003espiral matrix like in problem\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:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/944\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e944\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\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:t\u003e You can choose one or more ways to do this:\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eClean Code - without any kind of cheating,\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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eSmall Size - using cheats based on scoring system like\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\u003eregexp\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e or\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e'chars'-'0'\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=\\\"ListParagraph\\\"/\u003e\u003cw:numPr\u003e\u003cw:numId w:val=\\\"1\\\"/\u003e\u003c/w:numPr\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHack+100 - if you really want, I can't stop you from hacking this problem, set size to 100 in this case, please.\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\u003eEnjoy!\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is related to problems \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/944\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e944\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.com/matlabcentral/cody/problems/2033\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e2033\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"http://www.mathworks.co.uk/matlabcentral/cody/problems/2390\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e2390\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, ... and others which I don't remember now :-)\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":1400,"title":"Spiral Matrix","description":"for a given integer n\u003e=3, generate a matrix of nxn such that the value n^2 is at bottom left and its decreasing towards center  around the corner forming a spiral.{clockwise spiral- starting from bottom left}\r\n\r\nExamples:\r\n\r\n Input  n = 5\r\n Output y is [ 21 20 19 18 17;\r\n               22 7  6  5  16;\r\n               23 8  1  4  15;\r\n               24 9  2  3  14;\r\n               25 10 11 12 13];\r\n\r\n Input  n = 4\r\n Output y is [ 13 12 11 10 \r\n               14 3  2  9\r\n               15 4  1  8\r\n               16 5  6  7]","description_html":"\u003cp\u003efor a given integer n\u003e=3, generate a matrix of nxn such that the value n^2 is at bottom left and its decreasing towards center  around the corner forming a spiral.{clockwise spiral- starting from bottom left}\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e Input  n = 5\r\n Output y is [ 21 20 19 18 17;\r\n               22 7  6  5  16;\r\n               23 8  1  4  15;\r\n               24 9  2  3  14;\r\n               25 10 11 12 13];\u003c/pre\u003e\u003cpre\u003e Input  n = 4\r\n Output y is [ 13 12 11 10 \r\n               14 3  2  9\r\n               15 4  1  8\r\n               16 5  6  7]\u003c/pre\u003e","function_template":"function y = spiralmatrix(x)\r\n  y = x;\r\nend","test_suite":"x=1;\r\n\r\ny_correct=1;\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))\r\n\r\n%%\r\n\r\nx=2;\r\n\r\ny_correct=[3 2\r\n\r\n           4 1];\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))\r\n\r\n%%\r\n\r\nx=3;\r\n\r\ny_correct=[7 6 5\r\n\r\n           8 1 4\r\n\r\n           9 2 3];\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))\r\n\r\n%%\r\n\r\nx=4;\r\n\r\ny_correct=[13 12 11 10\r\n\r\n           14  3  2  9\r\n\r\n           15  4  1  8\r\n\r\n           16  5  6  7];\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))\r\n\r\n%%\r\n\r\nx=5;\r\n\r\ny_correct=[21 20 19 18 17\r\n\r\n           22  7  6  5 16\r\n\r\n           23  8  1  4 15\r\n\r\n           24  9  2  3 14\r\n\r\n           25 10 11 12 13];\r\n\r\nassert(isequal(spiralmatrix(x),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":1,"created_by":6312,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":82,"test_suite_updated_at":"2013-03-31T05:43:10.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2013-03-30T10:24:55.000Z","updated_at":"2025-12-08T11:58:40.000Z","published_at":"2013-03-30T10:25: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\u003efor a given integer n\u0026gt;=3, generate a matrix of nxn such that the value n^2 is at bottom left and its decreasing towards center around the corner forming a spiral.{clockwise spiral- starting from bottom left}\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  n = 5\\n Output y is [ 21 20 19 18 17;\\n               22 7  6  5  16;\\n               23 8  1  4  15;\\n               24 9  2  3  14;\\n               25 10 11 12 13];\\n\\n Input  n = 4\\n Output y is [ 13 12 11 10 \\n               14 3  2  9\\n               15 4  1  8\\n               16 5  6  7]]]\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":56383,"title":"Create spiral matrices","description":"Create a matrix of a given size with sequential elements spiraling inward. \r\nFor matrix height m and width n, the output should be an m-by-n matrix with elements ranging from from 1 to m*n in a rectangular spiral pattern with 1 in position (1,1) and the first 'leg' of the spiral progressing down the first column, i.e., the left column of the output has elements 1:m.","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: 93px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 46.5px; transform-origin: 407px 46.5px; 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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eCreate a matrix of a given size with sequential elements spiraling inward. \u003c/span\u003e\u003c/span\u003e\u003c/div\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor matrix height m and width n, the output should be an m-by-n matrix with elements ranging from from 1 to m*n in a rectangular spiral pattern with 1 in position (1,1) and the first 'leg' of the spiral progressing down the first column, i.e., the left column of the output has elements 1:m.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function s = rectangular_spiral(m,n)\r\n  s = m*n;\r\nend","test_suite":"%%\r\nm = 1;\r\nn = 1;\r\ny_correct = 1;\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 3;\r\nn = 5;\r\ny_correct = [\r\n    1 12 11 10 9\r\n    2 13 14 15 8\r\n    3  4  5  6 7];\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 5;\r\nn = 5;\r\ny_correct = rot90(-spiral(5) + 26);\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 9;\r\nn = 9;\r\ny_correct = rot90(-spiral(9) + 82);\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nassert(isequal(rectangular_spiral(0,0),[]))\r\n\r\n%%\r\nm = 7;\r\nn = 4;\r\ny_correct = [\r\n    1 18 17 16\r\n    2 19 28 15\r\n    3 20 27 14\r\n    4 21 26 13\r\n    5 22 25 12\r\n    6 23 24 11\r\n    7  8  9 10];\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 1;\r\nn = 3;\r\ny_correct = [1 2 3];\r\nassert(isequal(rectangular_spiral(m,n),y_correct))\r\n\r\n%%\r\nm = 5;\r\nn = 1;\r\ny_correct = [1 2 3 4 5]';\r\nassert(isequal(rectangular_spiral(m,n),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":1,"created_by":10139,"edited_by":10139,"edited_at":"2022-10-17T18:02:47.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-10-17T17:41:01.000Z","updated_at":"2022-10-17T18:02:47.000Z","published_at":"2022-10-17T17:41:33.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eCreate a matrix of a given size with sequential elements spiraling inward. \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 matrix height m and width n, the output should be an m-by-n matrix with elements ranging from from 1 to m*n in a rectangular spiral pattern with 1 in position (1,1) and the first 'leg' of the spiral progressing down the first column, i.e., the left column of the output has elements 1:m.\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":2340,"title":"Numbers spiral diagonals (Part 1)","description":"Inspired by Project Euler n°28 et 58.\r\n\r\nA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\r\n\r\nFor exemple with n=5, the spiral matrix is :\r\n\r\n                       21 22 23 24 25\r\n                       20  7  8  9 10\r\n                       19  6  1  2 11\r\n                       18  5  4  3 12\r\n                       17 16 15 14 13\r\n\r\nIn this example, the sum of the numbers on the diagonals is 101.\r\n\r\nWhat is the sum of the numbers on the diagonals in any n by n spiral (n always odd) ?\r\n\r\nHINTS: You want the diagonals, not the whole matrix.","description_html":"\u003cp\u003eInspired by Project Euler n°28 et 58.\u003c/p\u003e\u003cp\u003eA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\u003c/p\u003e\u003cp\u003eFor exemple with n=5, the spiral matrix is :\u003c/p\u003e\u003cpre\u003e                       21 22 23 24 25\r\n                       20  7  8  9 10\r\n                       19  6  1  2 11\r\n                       18  5  4  3 12\r\n                       17 16 15 14 13\u003c/pre\u003e\u003cp\u003eIn this example, the sum of the numbers on the diagonals is 101.\u003c/p\u003e\u003cp\u003eWhat is the sum of the numbers on the diagonals in any n by n spiral (n always odd) ?\u003c/p\u003e\u003cp\u003eHINTS: You want the diagonals, not the whole matrix.\u003c/p\u003e","function_template":"function y = spiral_nb(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nx = 3;\r\ny_correct = 25;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 5;\r\ny_correct = 101;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 9;\r\ny_correct = 537;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 501;\r\ny_correct = 83960501;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 5001;\r\ny_correct = 83395855001;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 10001;\r\ny_correct = 666916710001;\r\nassert(isequal(spiral_nb(x),y_correct))\r\n%%\r\nx = 10003;\r\ny_correct = 667316890025;\r\nassert(isequal(spiral_nb(x),y_correct))","published":true,"deleted":false,"likes_count":4,"comments_count":1,"created_by":5390,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":296,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":31,"created_at":"2014-05-30T22:02:51.000Z","updated_at":"2026-02-01T14:00:50.000Z","published_at":"2014-05-30T22:03: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\",\"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\u003eInspired by Project Euler n°28 et 58.\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\u003eA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\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 exemple with n=5, the spiral matrix 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[                       21 22 23 24 25\\n                       20  7  8  9 10\\n                       19  6  1  2 11\\n                       18  5  4  3 12\\n                       17 16 15 14 13]]\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\u003eIn this example, the sum of the numbers on the diagonals is 101.\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\u003eWhat is the sum of the numbers on the diagonals in any n by n spiral (n always odd) ?\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\u003eHINTS: You want the diagonals, not the whole 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":45452,"title":"Spiral Out - 01","description":"Create a spiral matrix ( clock-wise direction ) of size n.\r\n\r\nTry to do that without using the built-in function.","description_html":"\u003cp\u003eCreate a spiral matrix ( clock-wise direction ) of size n.\u003c/p\u003e\u003cp\u003eTry to do that without using the built-in function.\u003c/p\u003e","function_template":"function y = spi_out_2(n)","test_suite":"%%\r\nassert(isequal(spi_out_2(5),spiral(5)))\r\n%%\r\nassert(isequal(spi_out_2(3),spiral(3)))\r\n%%\r\nassert(isequal(spi_out_2(30),spiral(30)))\r\n%%\r\nassert(isequal(spi_out_2(15),spiral(15)))\r\n%%\r\nassert(isequal(spi_out_2(100),spiral(100)))\r\n%%\r\nassert(isequal(spi_out_2(2555),spiral(2555)))\r\n%%\r\nfiletext = fileread('spi_out_2.m');\r\nassert(isempty(strfind(filetext, 'spiral')),'spiral() forbidden')\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":21,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-04-14T02:37:04.000Z","updated_at":"2026-01-21T13:05:44.000Z","published_at":"2020-04-14T02:37: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\u003eCreate a spiral matrix ( clock-wise direction ) of size 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\u003eTry to do that without using the built-in 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":45404,"title":"ZigZag - 04","description":"Given a matrix, print all its elements in the spiral form (clockwise direction).\r\n\r\nFor example,\r\n\r\n a=[16     2     3    13\r\n     5    11    10     8\r\n     9     7     6    12\r\n     4    14    15     1]\r\noutput = [16 2 3 13 8 12 1 15 14 4 9 5 11 10 6 7] ","description_html":"\u003cp\u003eGiven a matrix, print all its elements in the spiral form (clockwise direction).\u003c/p\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre\u003e a=[16     2     3    13\r\n     5    11    10     8\r\n     9     7     6    12\r\n     4    14    15     1]\r\noutput = [16 2 3 13 8 12 1 15 14 4 9 5 11 10 6 7] \u003c/pre\u003e","function_template":"function y = spiral_pattern(x)","test_suite":"%%\r\nx = magic(4);\r\ny=[16\t2\t3\t13\t8\t12\t1\t15\t14\t4\t9\t5\t11\t10\t6\t7]\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n%%\r\nx=reshape([89:124],3,[]);\r\ny=[89\t92\t95\t98\t101\t104\t107\t110\t113\t116\t119\t122\t123\t124\t121\t118\t115\t112\t109\t106\t103\t100\t97\t94\t91\t90\t93\t96\t99\t102\t105\t108\t111\t114\t117\t120]\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n\r\n%%\r\nx = ones(8,2);\r\ny=ones(1,16);\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n\r\n%%\r\nx = [17    24     1\r\n    23     5     1\r\n     4     6     1\r\n    10    12     1\r\n    11    18     1]\r\ny=[17    24     1     1     1     1     1    18    11    10     4    23     5 6    12]\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n\r\n%%\r\nx = magic(9);\r\ny=[47\t58\t69\t80\t1\t12\t23\t34\t45\t46\t56\t66\t76\t5\t15\t25\t35\t24\t13\t2\t81\t70\t59\t48\t37\t36\t26\t16\t6\t77\t67\t57\t68\t79\t9\t11\t22\t33\t44\t54\t55\t65\t75\t4\t14\t3\t73\t71\t60\t49\t38\t28\t27\t17\t7\t78\t8\t10\t21\t32\t43\t53\t63\t64\t74\t72\t61\t50\t39\t29\t19\t18\t20\t31\t42\t52\t62\t51\t40\t30\t41]\r\nassert(isequal(spiral_pattern(x),y))\r\n\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":363598,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":"2020-04-01T00:24:59.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-03-30T18:33:34.000Z","updated_at":"2025-03-01T10:13:38.000Z","published_at":"2020-03-30T18:33:34.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a matrix, print all its elements in the spiral form (clockwise direction).\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[ a=[16     2     3    13\\n     5    11    10     8\\n     9     7     6    12\\n     4    14    15     1]\\noutput = [16 2 3 13 8 12 1 15 14 4 9 5 11 10 6 7]]]\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":255,"title":"Spiraling out of control....","description":"Imagine a square with corners at the origin and at (1,1).  An interesting spiral can be created by tracing the path of a moving point that starts at the origin and intersects the leftmost opposite edge at a point (F,1), where F is the fraction of the length of the intersected edge.  The point then continues on in this way, always heading for the leftmost opposite side of its path and intersecting the segment at a point which is fraction F of its length.  For example, if F = 1/2, the first few points are:\r\n\r\n  P = [0 0;0.5 1;1 0.5;0.5 0;0.25 0.5;.75 .75];\r\n  plot(P(:,1),P(:,2),'*-') \r\n  axis equal\r\n\r\nIf F = 1/3, then the first few positions of the particle are:\r\n\r\n  P = [0 0;1/3 1;1 2/3;2/3 0;1/9 1/3;5/9 8/9];\r\n\r\nWrite a function that takes two inputs and returns two outputs. The first input argument, N, is the Nth location of the particle. The second input argument is the fraction F, where F is on (0,1). The first returned argument is a two element row vector that has the coordinates of the Nth location of the particle as [x,y]. The second returned argument is the limiting value of the particles location as N--\u003einfinity. For example,\r\n\r\n  [P,L] = my_spiral(3,1/2)\r\n\r\nreturns\r\n\r\n  P = [1 0.5] \r\n\r\nand\r\n\r\n  L = [?x? ?y?] \r\n\r\nWhere both values of L are doubles accurate to 100*eps.\r\n","description_html":"\u003cp\u003eImagine a square with corners at the origin and at (1,1).  An interesting spiral can be created by tracing the path of a moving point that starts at the origin and intersects the leftmost opposite edge at a point (F,1), where F is the fraction of the length of the intersected edge.  The point then continues on in this way, always heading for the leftmost opposite side of its path and intersecting the segment at a point which is fraction F of its length.  For example, if F = 1/2, the first few points are:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eP = [0 0;0.5 1;1 0.5;0.5 0;0.25 0.5;.75 .75];\r\nplot(P(:,1),P(:,2),'*-') \r\naxis equal\r\n\u003c/pre\u003e\u003cp\u003eIf F = 1/3, then the first few positions of the particle are:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eP = [0 0;1/3 1;1 2/3;2/3 0;1/9 1/3;5/9 8/9];\r\n\u003c/pre\u003e\u003cp\u003eWrite a function that takes two inputs and returns two outputs. The first input argument, N, is the Nth location of the particle. The second input argument is the fraction F, where F is on (0,1). The first returned argument is a two element row vector that has the coordinates of the Nth location of the particle as [x,y]. The second returned argument is the limiting value of the particles location as N--\u003einfinity. For example,\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e[P,L] = my_spiral(3,1/2)\r\n\u003c/pre\u003e\u003cp\u003ereturns\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eP = [1 0.5] \r\n\u003c/pre\u003e\u003cp\u003eand\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003eL = [?x? ?y?] \r\n\u003c/pre\u003e\u003cp\u003eWhere both values of L are doubles accurate to 100*eps.\u003c/p\u003e","function_template":"function [y,z] = my_spiral(x)\r\n  y = x;\r\n  z = x;\r\nend","test_suite":"%%\r\n[P,L] = my_spiral(20,1/2);\r\nassert(all(abs(P-[0.5859375,0.484375])\u003c100*eps))\r\nassert(all(abs(L-[0.571428571428571,0.428571428571429])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(11,2/7);\r\nassert(all(abs(P-[0.80841316118284,0.387755102040816])\u003c100*eps))\r\nassert(all(abs(L-[0.538461538461538,0.461538461538462])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(88,9999/11111);\r\nassert(all(abs(P-[0.652150333541218,0.358838287231673])\u003c100*eps))\r\nassert(all(abs(L-[0.645144433154304,0.354855566845696])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(901,987654/1000000);\r\nassert(all(abs(P-[0.666383724185262,0.337637121736288])\u003c100*eps))\r\nassert(all(abs(L-[0.663934355482405,0.336065644517595])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(3,eps);\r\nassert(all(abs(L-[1/2,1/2])\u003c100*eps))\r\n%%\r\n[P,L] = my_spiral(2,1-eps);\r\nassert(all(abs(L-[2/3,1/3])\u003c100*eps))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":459,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":11,"test_suite_updated_at":"2012-02-05T05:13:12.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-02-04T00:47:43.000Z","updated_at":"2012-02-05T05:14:10.000Z","published_at":"2012-02-05T05:14:10.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eImagine a square with corners at the origin and at (1,1). An interesting spiral can be created by tracing the path of a moving point that starts at the origin and intersects the leftmost opposite edge at a point (F,1), where F is the fraction of the length of the intersected edge. The point then continues on in this way, always heading for the leftmost opposite side of its path and intersecting the segment at a point which is fraction F of its length. For example, if F = 1/2, the first few points are:\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[P = [0 0;0.5 1;1 0.5;0.5 0;0.25 0.5;.75 .75];\\nplot(P(:,1),P(:,2),'*-') \\naxis equal]]\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 F = 1/3, then the first few positions of the particle are:\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[P = [0 0;1/3 1;1 2/3;2/3 0;1/9 1/3;5/9 8/9];]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWrite a function that takes two inputs and returns two outputs. The first input argument, N, is the Nth location of the particle. The second input argument is the fraction F, where F is on (0,1). The first returned argument is a two element row vector that has the coordinates of the Nth location of the particle as [x,y]. The second returned argument is the limiting value of the particles location as N--\u0026gt;infinity. 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[[P,L] = my_spiral(3,1/2)]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ereturns\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[P = [1 0.5]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\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[L = [?x? ?y?]]]\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\u003eWhere both values of L are doubles accurate to 100*eps.\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":659,"title":"How long is the longest prime diagonal?","description":"Stanislaw Ulam once observed that if the counting numbers are arranged in a spiral, the prime numbers contained in it form a surprising pattern. They appear to cluster along diagonals of the spiral matrix.\r\nGiven n, return the length of the longest diagonal sequence of primes in spiral(n).\r\nExample:\r\n Input  n = 7\r\n Output d = 4\r\nSince isprime(spiral(n)) is\r\n     1     0     0     0     1     0     0\r\n     0     0     0     1     0     0     0\r\n     1     0     1     0     0     0     0\r\n     0     1     0     0     1     1     0\r\n     0     0     1     0     1     0     1\r\n     0     1     0     0     0     1     0\r\n     1     0     0     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: 336.9px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 168.45px; transform-origin: 407px 168.45px; 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: 198.5px 8px; transform-origin: 198.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eStanislaw Ulam once observed that if the counting numbers are\u003c/span\u003e\u003c/span\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003earranged in a spiral\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: 111px 8px; transform-origin: 111px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, the prime numbers contained in it form a surprising pattern. They appear to cluster along diagonals of the spiral 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: 256.5px 8px; transform-origin: 256.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eGiven n, return the length of the longest diagonal sequence of primes in spiral(n).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 28.5px 8px; transform-origin: 28.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 40.8667px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 20.4333px; transform-origin: 404px 20.4333px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 52px 8.5px; tab-size: 4; transform-origin: 52px 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: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003en = 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: 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: 52px 8.5px; tab-size: 4; transform-origin: 52px 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: 20px 8.5px; text-decoration-color: rgb(170, 4, 249); text-emphasis-color: rgb(170, 4, 249); transform-origin: 20px 8.5px; \"\u003ed = 4\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: 80px 8px; transform-origin: 80px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSince isprime(spiral(n)) is\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 143.033px; 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 71.5167px; transform-origin: 404px 71.5167px; 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: 168px 8.5px; tab-size: 4; transform-origin: 168px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     1     0     0     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 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     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     1     0     1     0     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 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     1     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 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     1     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 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     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: 168px 8.5px; tab-size: 4; transform-origin: 168px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e     1     0     0     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 d = prime_spiral(n)\r\n  d = 1;\r\nend","test_suite":"%%\r\nn = 4;\r\nd = 2;\r\n%p = isprime(spiral(n));imagesc(p)\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 7;\r\nd = 4;\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 13;\r\nd = 5;\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 29;\r\nd = 5;\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 52;\r\nd = 6;\r\nassert(isequal(prime_spiral(n),d))\r\n\r\n%%\r\nn = 81;\r\nd = 9;\r\nassert(isequal(prime_spiral(n),d))","published":true,"deleted":false,"likes_count":14,"comments_count":10,"created_by":7,"edited_by":223089,"edited_at":"2022-06-05T19:47:54.000Z","deleted_by":null,"deleted_at":null,"solvers_count":410,"test_suite_updated_at":"2022-06-05T19:47:54.000Z","rescore_all_solutions":false,"group_id":6,"created_at":"2012-05-04T19:16:30.000Z","updated_at":"2026-02-19T11:54:08.000Z","published_at":"2012-06-08T19:08:22.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\u003eStanislaw Ulam once observed that if the counting numbers are\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=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003earranged in a spiral\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, the prime numbers contained in it form a surprising pattern. They appear to cluster along diagonals of the spiral 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\u003eGiven n, return the length of the longest diagonal sequence of primes in spiral(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:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input  n = 7\\n Output d = 4]]\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\u003eSince isprime(spiral(n)) 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     0     0     0     1     0     0\\n     0     0     0     1     0     0     0\\n     1     0     1     0     0     0     0\\n     0     1     0     0     1     1     0\\n     0     0     1     0     1     0     1\\n     0     1     0     0     0     1     0\\n     1     0     0     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":2455,"title":"Diagonal of a Spiral Matrix","description":"Write a function that will return same output as diag(spiral(n)). The only exception is that spiral and diag functions are not allowed in your function. Also, loops are not allowed.","description_html":"\u003cp\u003eWrite a function that will return same output as diag(spiral(n)). The only exception is that spiral and diag functions are not allowed in your function. Also, loops are not allowed.\u003c/p\u003e","function_template":"function y=digSpi(n)\r\n\r\n\r\n\r\n\r\nend","test_suite":"s = evalc('type digSpi');\r\n\r\nif ~isempty(regexp(s,'error'))\r\n    error('error using error');\r\nend\r\n\r\nif ~isempty(regexp(s,'assert'))\r\n    error('error using assert');\r\nend\r\n\r\nif ~isempty(regexp(s,'diag'))\r\n    error('error using diag');\r\nend\r\n\r\nif ~isempty(regexp(s,'spiral'))\r\n    error('error using spiral');\r\nend\r\n\r\nif ~isempty(regexp(s,'for'))\r\n    error('error using for');\r\nend\r\n\r\nif ~isempty(regexp(s,'while'))\r\n    error('error using while');\r\nend\r\n\r\n%%\r\n\r\na = diag(spiral(4));\r\nb = digSpi(4);\r\nassert(isequal(a,b));\r\n\r\n%%\r\n\r\na = diag(spiral(5));\r\nb = digSpi(5);\r\nassert(isequal(a,b));\r\n\r\n%%\r\n\r\na = diag(spiral(6));\r\nb = digSpi(6);\r\nassert(isequal(a,b));\r\n\r\n%%\r\n\r\na = diag(spiral(7));\r\nb = digSpi(7);\r\nassert(isequal(a,b));\r\n\r\n%%\r\n\r\na = diag(spiral(8));\r\nb = digSpi(8);\r\nassert(isequal(a,b));","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":17203,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":111,"test_suite_updated_at":"2014-07-21T18:30:07.000Z","rescore_all_solutions":false,"group_id":31,"created_at":"2014-07-20T08:15:09.000Z","updated_at":"2026-03-04T17:27:33.000Z","published_at":"2014-07-20T08:15:09.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\u003eWrite a function that will return same output as diag(spiral(n)). The only exception is that spiral and diag functions are not allowed in your function. Also, loops are not allowed.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":54780,"title":"Trap a knight","description":"Consider a knight on an infinite chessboard labeled with numbers spiraling outward. A knight starting on the square labeled 1 can reach 8 squares, marked in green below (i.e., squares 10, 12, 14, 16, 18, 20, 22, and 24). Take the smallest of these numbers, or 10. Repeating the step while avoiding squares already visited puts the knight at squares 3, 6, 9, 4, 7, 2, 5, etc. This tour continues until step 2016, when the knight reaches square 2084. At that point the knight is trapped: it has visited all eight possible squares. \r\nWrite a function that takes the starting square and returns the sequence of squares visited by the knight on the tour. \r\n","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: 415.7px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 207.85px; transform-origin: 407px 207.85px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 105px; 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 52.5px; text-align: left; transform-origin: 384px 52.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: 35.7917px 8px; transform-origin: 35.7917px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eConsider a \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Knight_(chess)#Movement\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eknight\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: 327.942px 8px; transform-origin: 327.942px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e on an infinite chessboard labeled with numbers spiraling outward. A knight starting on the square labeled 1 can reach 8 squares, marked in green below (i.e., squares 10, 12, 14, 16, 18, 20, 22, and 24). Take the smallest of these numbers, or 10. Repeating the step while avoiding squares already visited puts the knight at squares 3, 6, 9, 4, 7, 2, 5, etc. This tour continues until step 2016, when the knight reaches square 2084. At that point the knight is trapped: it has visited all eight possible squares. \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: 358.867px 8px; transform-origin: 358.867px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function that takes the starting square and returns the sequence of squares visited by the knight on the tour. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 271.7px; 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 135.85px; text-align: left; transform-origin: 384px 135.85px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cimg class=\"imageNode\" style=\"vertical-align: baseline;width: 275px;height: 266px\" src=\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARMAAAEKCAYAAAAxcLHrAA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+hsjh/7D71C2f/2PPUejvfa/O7qTW4/QmKbwD2TqJFpzxg1Mu0ZowbtHy6x9kwIIScmFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixAsWEEGIFigkhxAoUE0KIFSgmhBArUEwIIVagmBBCrEAxIYRYwcoSBISQ+GJrCYIqiwkhhAAOcwghVqCYEEKsQDEhhFiBYkIIsQLFhBBiBYoJIcQKFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixgMj/B1CYpZlf1IqYAAAAAElFTkSuQmCC\" data-image-state=\"image-loaded\" width=\"275\" height=\"266\"\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = trappedKnight(n)\r\n  y = randi(n^2,1,2016);\r\nend","test_suite":"%%\r\nn = 1;\r\ny = trappedKnight(n);\r\ny_correct = [1 10 3 6 9 4 7 2 5 8 11 14 29 32 15 12 27 24 45 20 23 44 41 18 35 38 19 16 33 30 53 26 47 22 43 70 21 40 17 34 13 28 25 46 75 42 69 104 37 62 95 58 55 86 51 48 77 114 73 108 151 68 103 64 67 36 39 66 63 96 59 56 87 52 49 78 115 74 71 106 149 102 99 140 61 94 31 54 85 50 79 116 161 76 113 72 107 150 201 146 65 98 139 60 93 90 129 176 125 82 119 164 217 160 111 154 205 264 331 200 101 142 97 138 187 92 89 128 175 84 81 118 163 216 159 110 153 204 105 148 199 144 147 100 141 190 137 186 91 130 57 88 127 174 83 80 117 162 215 112 109 152 203 262 329 198 195 252 143 192 249 188 135 132 179 234 297 230 123 120 165 218 279 214 157 208 267 334 263 330 259 196 253 318 191 248 313 244 133 180 235 298 177 126 173 122 167 220 281 350 277 158 155 206 265 202 261 328 197 254 145 194 251 316 189 136 185 182 131 134 181 184 239 242 305 238 183 304 237 178 233 296 229 124 121 166 219 280 349 276 211 156 207 266 333 408 491 404 257 322 395 476 317 390 247 312 243 240 303 236 299 232 295 172 169 222 283 352 429 278 213 210 269 336 411 332 407 260 327 256 321 394 475 564 389 246 311 384 241 310 245 314 387 468 309 306 377 302 373 452 369 294 171 168 221 282 351 428 347 212 209 268 335 410 493 406 489 326 323 258 255 320 193 250 315 388 469 558 383 380 459 376 301 372 451 368 231 370 449 366 227 224 285 354 431 516 427 346 273 340 415 270 337 412 495 586 409 492 405 488 325 398 479 568 393 474 563 470 385 308 379 382 461 378 307 460 381 466 555 462 465 554 551 464 553 648 463 550 645 458 375 300 371 450 367 228 225 286 355 432 517 610 513 348 275 272 339 414 497 588 687 494 585 490 403 324 397 478 319 392 473 562 659 764 557 654 759 650 653 552 647 548 457 374 453 540 635 448 293 170 223 284 353 430 515 426 345 342 271 274 341 344 419 422 505 418 343 424 509 420 423 508 599 504 417 338 413 496 587 686 583 682 487 400 481 396 477 566 391 472 561 386 467 556 657 560 471 660 559 656 761 652 649 752 549 644 545 454 541 636 537 446 291 288 357 434 519 612 713 514 425 510 421 598 503 416 499 590 689 796 685 582 681 486 483 402 399 480 569 666 565 662 767 658 763 876 655 760 651 754 865 646 547 456 543 638 539 634 447 292 289 358 435 520 613 714 609 512 605 706 507 604 511 608 709 818 603 506 597 502 593 498 589 688 795 584 683 580 401 482 571 668 567 664 769 882 661 766 879 762 875 758 755 866 751 862 643 544 639 742 853 738 535 364 361 226 287 356 433 518 611 712 607 708 817 602 701 704 811 600 699 596 501 592 691 798 913 794 909 684 581 680 485 574 671 570 667 772 663 768 881 1002 765 878 999 874 757 868 753 864 749 546 455 542 637 538 633 534 363 360 437 522 615 716 825 942 711 606 707 816 601 700 807 696 803 594 693 500 591 690 797 912 793 908 789 578 575 672 777 572 669 774 665 770 883 1004 1133 880 1001 1130 877 998 873 756 867 986 863 748 641 744 855 740 851 632 445 290 359 436 521 614 715 824 941 710 819 936 705 702 809 698 595 694 801 916 1039 1170 911 792 907 788 577 484 573 670 775 888 771 884 1005 1134 1271 1000 1129 996 871 990 1117 1252 985 750 861 642 745 856 741 852 737 536 365 444 441 526 619 438 523 616 717 826 943 822 939 1064 935 814 929 810 703 928 813 934 1059 930 933 812 815 932 1055 1058 1189 1054 927 808 697 804 919 692 799 914 1037 910 791 906 679 576 579 678 675 780 893 776 889 1010 773 886 1007 1136 1003 1132 1269 1128 995 870 989 1116 1251 984 1111 860 979 746 857 640 743 854 739 850 631 532 529 362 439 524 617 718 827 944 823 940 1065 820 937 1062 1195 1336 1057 1188 931 1060 1193 1056 1187 1052 925 806 695 802 917 1040 1171 1036 1167 1032 905 786 783 674 779 892 1013 1142 887 1008 1137 1274 1419 1270 1415 1266 997 872 869 988 1115 1250 983 1110 859 978 1105 974 1101 970 735 628 443 440 525 618 719 828 945 1070 1203 1066 821 938 1063 1196 1337 1192 1331 1334 1481 1190 1329 1186 1051 924 805 920 1043 800 915 1038 1169 1034 1165 1030 787 676 781 894 673 778 891 1012 1141 1278 1009 1138 885 1006 1135 1272 1131 1268 1127 994 991 1118 987 1114 1249 982 747 858 977 1104 973 1100 849 630 531 528 621 722 831 948 1073 1206 1069 1202 1343 1198 1061 1194 1335 1332 1479 1328 1053 926 1049 922 1045 918 1041 1172 1311 1168 1033 790 1031 904 677 782 895 1016 1145 890 1011 1140 1277 1422 1273 1418 1571 1414 1265 1124 1121 1256 1399 1550 1253 1396 1113 1248 981 1108 1243 976 1103 972 1099 848 629 442 527 620 721 830 947 1072 1205 1068 1201 1342 1197 1338 1487 1644 1333 1480 1191 1330 1477 1326 1183 1048 921 1044 1175 1314 1461 1310 1035 1166 1305 1162 903 784 897 1018 1147 1014 1143 1280 1139 1276 1421 1574 1417 1570 1267 1126 993 1120 1255 1398 1549 1394 1247 980 1107 1242 975 1102 971 736 533 734 627 624 725 834 951 720 829 946 1071 1204 1067 1200 1341 1490 1647 1486 1643 1482 1485 1642 1639 1484 1641 1804 1483 1638 1801 1478 1327 1184 1323 1050 923 1046 1177 1042 1173 1312 1459 1308 1455 1164 1029 902 899 1020 1149 896 1017 1146 1283 1428 1279 1424 1275 1420 1573 1416 1569 1412 1125 992 1119 1254 1397 1548 1393 1112 1395 1546 1391 1244 1109 1390 1541 1386 1239 1382 1235 968 733 530 623 724 833 950 1075 1208 1349 1498 1345 1494 1199 1340 1489 1646 1811 1984 1807 1640 1803 1636 1799 1476 1185 1324 1181 1320 1047 1178 1317 1174 1313 1460 1309 1456 1611 1304 1161 1026 785 898 1019 1148 1015 1144 1281 1426 1579 1740 1423 1576 1737 1572 1733 1568 1411 1262 1259 1402 1553 1712 1879 1708 1545 1246 1389 1106 1241 1384 1237 1098 847 732 625 726 835 622 723 832 949 1074 1207 1348 1497 1344 1493 1650 1339 1488 1645 1810 1983 1806 1809 1982 1979 1808 1805 1976 1637 1800 1633 1474 1629 1322 1179 1318 1465 1176 1315 1462 1617 1458 1307 1454 1163 1028 901 1022 1151 1288 1433 1284 1429 1582 1425 1578 1739 1908 1575 1736 1905 1732 1413 1264 1123 1258 1401 1552 1711 1878 1547 1392 1245 1388 1539 1240 1383 1236 969 846 731 728 837 954 1079 1212 1353 1076 1209 1350 1499 1346 1495 1652 1491 1648 1813 1986 2167 2356 1981 2160 1977 1802 1635 1798 1475 1630 1325 1182 1321 1468 1623 1316 1463 1618 1781 1614 1777 1610 1303 1160 1025 900 1021 1150 1287 1432 1585 1282 1427 1580 1741 1910 1577 1738 1907 1734 1903 1730 1565 1408 1263 1122 1257 1400 1551 1710 1877 1706 1543 1702 1387 1538 1697 1534 1379 1096 845 626 727 836 953 1078 1211 1352 1501 1658 1347 1496 1653 1492 1649 1814 1987 2168 2357 2164 2161 1978 2157 1974 2153 1970 1631 1472 1627 1790 1467 1622 1785 1464 1619 1782 1615 1778 1457 1306 1453 1302 1027 1024 1153 1290 1435 1286 1431 1584 1745 1914 1581 1742 1911 2088 2273 1906 2083 1902 1567 1410 1261 1404 1555 1714 1881 2056 1709 1876 1705 1542 1701 1868 1537 1238 1381 1234 967 844 729 838 955 1080 1213 952 1077 1210 1351 1500 1657 1822 1995 1654 1819 1992 1651 1816 1989 1812 1985 2166 2355 2162 2165 1980 2159 2346 1975 2154 1971 1632 1473 1628 1469 1180 1319 1466 1621 1784 1955 1616 1779 1612 1775 1452 1301 1158 1155 1292 1023 1152 1289 1434 1285 1430 1583 1744 1913 2090 1909 2086 1735 1904 1731 1566 1409 1260 1403 1554 1713 1880 2055 2238 1875 1544 1703 1540 1385 1536 1695 1380 1097 966 843 840 957 1082 1215 1356 1505 1662 1827 1502 1659 1824 1655 1820 1993 2174 1815 1988 2169 2358 2555 2354 2351 2546 2347 2156 1973 1634 1797 1968 1793 1470 1625 1788 1959 1620 1783 1954 2133 1780 1613 1776 1609 1450 1159 1156 1293 1438 1591 1752 1587 1748 1917 2094 1743 1912 2089 2274 2085 2270 2081 1900 1727 1562 1559 1718 1405 1556 1715 1882 2057 2240 2053 1874 1707 2052 1873 2048 1869 1698 1535 1694 1531 1232 965 730 839 956 1081 1214 1355 1504 1661 1826 1999 1656 1821 1994 1817 1990 2171 2360 2557 2762 2553 2352 2547 2348 2543 2158 2345 2540 2155 1972 2151 1796 1967 1792 1471 1626 1789 1960 2139 1786 1957 2136 1953 2132 1949 1774 1451 1300 1157 1294 1439 1154 1291 1436 1589 1750 1919 1586 1747 1916 2093 2278 2471 2672 2275 2468 2087 2272 2465 2082 1901 1728 1563 1406 1557 1716 1883 2058 2241 2054 2237 2050 1871 1700 1867 1696 1533 1378 1095 964 841 958 1083 1216 1357 1506 1663 1354 1503 1660 1825 1998 2179 2368 2175 1818 1991 2172 2361 2558 2763 2554 2163 2350 2545 2748 2541 2342 2537 2150 1795 1966 1791 1624 1787 1958 2137 2324 2519 2134 1951 2130 1947 1608 1449 1298 1295 1440 1593 1754 1437 1590 1751 1920 2097 1746 1915 2092 2277 2470 2671 2466 2269 2080 1729 1564 1407 1558 1717 1884 2059 2242 2433 2632 2239 2430 2051 1704 2049 1870 1699 1866 2041 1862 1691 1376 1093 842 959 1084 1217 1358 1507 1664 1829 2002 2183 2372 1997 2178 2367 2564 2173 2362 2559 2170 2359 2556 2761 2552 2549 2752 2349 2544 2747 2344 2539 2152 1969 1794 1965 2144 1961 2140 2327 1956 2135 1952 2131 1948 1773 1606 1299 1296 1441 1594 1755 1924 2101 2286 1921 1588 1749 1918 2095 2280 2091 2276 2469 2670 2271 2464 2267 2078 1897 1724 1721 1888 2063 2246 1885 2060 2243 2434 2633 2840 2429 2234 2047 1872 2233 2046 2229 2042 1863 1532 1233 1094 963 960 1085 1218 1359 1508 1665 1830 2003 2184 2373 2000 1823 1996 2177 2366 2563 2768 2363 2560 2765 2978 3199 2760 2353 2548 2751 2962 3181 2746 2343 2538 2339 2148 2335 1964 2143 2330 2525 2138 2325 2520 2321 1950 2129 1946 1607 1448 1297 1442 1595 1756 1925 1592 1753 1922 2099 2284 2477 2096 2281 2474 2675 2884 3101 2880 2467 2084];\r\nlen_correct = 2016;\r\nyend_correct = 2084;\r\nassert(isequal(y,y_correct) \u0026\u0026 isequal(length(y),len_correct) \u0026\u0026 isequal(y(end),yend_correct))\r\n\r\n%%\r\nY = NaN(1,100); len = NaN(1,100);\r\nfor n = 1:100\r\n    y = trappedKnight(n);\r\n    Y(n) = y(end);\r\n    len(n) = length(y);\r\nend\r\nY_correct = [2084 711 3915 556 3915 556 3915 3380 2086 1339 1464 1572 4772 582 3959 682 2309 385 330 1142 706 2750 4256 4322 1413 1488 1685 6335 5214 906 2616 1038 582 1608 2675 6266 1120 3955 936 2773 1861 2213 2223 262 1147 4428 1126 3319 1040 1693 3614 1647 4122 2121 3496 2555 2508 5174 2961 1338 1607 4252 2826 1731 3915 2130 938 762 835 3437 708 1653 1133 4168 3918 150 1204 3087 1438 445 3104 969 906 822 3404 2922 125 329 3214 6185 3912 2181 1093 1379 4586 5335 790 3038 5262 3141];\r\nlen_correct = [2016 880 2741 857 2741 857 2741 3611 2590 1540 1846 2061 4892 1047 4139 753 3559 590 426 1205 1140 2759 3830 4687 1839 2101 2861 5892 5500 1295 2674 1213 890 1839 2749 6531 1118 3632 1496 2888 1995 2574 2713 495 1479 5509 1414 3926 1078 2344 4244 1932 4054 3382 4084 3410 4144 4079 2223 1151 1799 4863 3162 2292 2741 2271 840 1087 1397 2752 990 1664 1775 3915 5704 263 1658 2840 1510 486 3620 1146 1288 969 3688 3745 311 586 3146 5480 5116 2472 1473 1910 5128 5938 1128 4367 4412 5036];\r\nassert(isequal(len,len_correct) \u0026\u0026 isequal(Y,Y_correct))\r\n\r\n%%\r\nY = NaN(1,800); len = NaN(1,800);\r\nfor n = 200:1000\r\n    y = trappedKnight(n);\r\n    Y(n-199) = y(end);\r\n    len(n-199) = length(y);\r\nend\r\n[lensort,isortlen] = sort(len,'descend');\r\n[Ysort,isortY] = sort(Y,'descend');\r\nisortlen_correct = [396 662 246 49 125 462 267 336 683 797];\r\nlenmax10_correct = [12072 11058 10654 10553 10337 10031 9552 9469 9292 9259];\r\nisortY_correct = [662 683 267 246 396 497 49 443 541 462];\r\nYmax10_correct = [14176 12571 12303 11858 11802 11456 11168 10624 9594 8857];\r\nassert(isequal(lensort(1:10),lenmax10_correct) \u0026\u0026 isequal(Ysort(1:10),Ymax10_correct) \u0026\u0026 isequal(isortlen(1:10),isortlen_correct) \u0026\u0026 isequal(isortY(1:10),isortY_correct))\r\n\r\n%%\r\nn = 9999;\r\ny = trappedKnight(n);\r\nsum_correct = 77968774;\r\nassert(isequal(sum(y),sum_correct))\r\n\r\n%%\r\nn = 11509;\r\ny = trappedKnight(n);\r\nlen_correct = 21346;\r\nassert(isequal(length(y),len_correct))\r\n\r\n%%\r\nfiletext = fileread('trappedKnight.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert') || contains(filetext,'switch') || contains(filetext,'regexp'); \r\nassert(~illegal)\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":2,"created_by":46909,"edited_by":46909,"edited_at":"2024-01-04T14:21:04.000Z","deleted_by":null,"deleted_at":null,"solvers_count":7,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-07-07T04:01:20.000Z","updated_at":"2026-02-03T16:00:59.000Z","published_at":"2022-07-07T04:03:44.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\u003eConsider a \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Knight_(chess)#Movement\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eknight\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e on an infinite chessboard labeled with numbers spiraling outward. A knight starting on the square labeled 1 can reach 8 squares, marked in green below (i.e., squares 10, 12, 14, 16, 18, 20, 22, and 24). Take the smallest of these numbers, or 10. Repeating the step while avoiding squares already visited puts the knight at squares 3, 6, 9, 4, 7, 2, 5, etc. This tour continues until step 2016, when the knight reaches square 2084. At that point the knight is trapped: it has visited all eight possible squares. \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\u003eWrite a function that takes the starting square and returns the sequence of squares visited by the knight on the tour. \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:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"266\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"275\\\"/\u003e\u003cw:attr w:name=\\\"verticalAlign\\\" w:val=\\\"baseline\\\"/\u003e\u003cw:attr w:name=\\\"altText\\\" w:val=\\\"\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"target\":\"/media/image1.png\",\"relationshipId\":\"rId1\"}]},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAARMAAAEKCAYAAAAxcLHrAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAAEnQAABJ0Ad5mH3gAACakSURBVHhe7Z0JlBVFlvcvgoCg1ZSAgrLaNKAgwijDSNsfwkGwWz7E+pByBXWAUUBpFWRxoMRqUWRxRJFulpHNBcpWx6UFsS2X07YMMtCArSAqCN0igiB7Idpf/jMiqrKer+q9lxUvF+b/OydPRObLfLy6GfmPG/dGBtX+4SCEEFJFTtIlIYRUCYoJIcQKFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixAsWEEGIFigkhxAoUE0KIFar8bk6nDj+TdRu26L34UeuUmlJy5Jjeix91a4scOqp3YgjtHy4dz28la9d/oveqRpXFpFq1anJshd6JITV7iyz9ywy9Fz/yL7iL9g+RE8H+tt715TCHEGIFigkhxAoUE0KIFSgmhBArUEwIIVagmBBCrEAxIYRYgWJCCLECxYQQYgWKCSHEChQTQogVKCaEECtQTAghVqCYEEKsEMoSBMXrRKYXibz+gT7g0KmVyNzRIh1a6AOVcLhEZMD96vpeF4m88oD+wAeZvgL//fc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CjJ1b8P+i1aqEnOtEuNaQRK6mGQ6Zpz/miphuDzVDkIlHc8EjbPHVSpW8tR/vCLbNv3drQOkLKff+aQbTMY7OxCToFxskI798S7JjQ8ln0+CdKUZchp3O0iqGvMIO5uTjv1h4/6TkgdYpxWV2d87tT4Mqv2jiv8FerVq1dzIcrpgbsh8z9ve3qCdeRMSnun04T8ewqAxY04DwJTkxHcV/IB8PXqkdEG25eUFxVL3J8p99rrKSPUeP3ZcatSsIbfed0259z4gEMN6TSodv0M4cnLruu62Ae+aYIp4JmCeSrbtj8ZsvEFgzvNe6/d+BGX/ikCMBN8JzyR/xK/00fQJwv64ZoSauOuSzP541wdT9DMF9q+iBJQSuGeSOOnJizn29vrk7xm8s1GViF6HNUkNc0YQ+0AjTjbmNmPxI2aOswOEBN7J7/44yW209XPU3BKcC1HBjMyn/2daxkLiBz/2x4QopCFNCtich/swebCab2JD2NPBj/0rI+hsjh/7D71C2f/2PPUejvfa/O7qTW4/QmKbwD2TqJFpzxg1Mu0ZowbtHy6x9kwIIScmFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixAsWEEGIFigkhxAoUE0KIFSgmhBArUEwIIVagmBBCrEAxIYRYwcoSBISQ+GJrCYIqiwkhhAAOcwghVqCYEEKsQDEhhFiBYkIIsQLFhBBiBYoJIcQKFBNCiBUoJoQQK1BMCCFWoJgQQqxAMSGEWIFiQgixgMj/B1CYpZlf1IqYAAAAAElFTkSuQmCC\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"},{"id":45453,"title":"Spiral Out - 02","description":"An array is given. Convert it into a spiral matrix.\r\nFor example, a=1:27;\r\n out=[21    22    23    24    25    26\r\n      20     7     8     9    10    27\r\n      19     6     1     2    11     0\r\n      18     5     4     3    12     0\r\n      17    16    15    14    13     0\r\n       0     0     0     0     0     0]\r\nadd necessary amount of zeros to fill in the remaining positions.\r\nNote - spiral() is forbidden.","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: 244.6px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 122.3px; transform-origin: 407px 122.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: 148.5px 8px; transform-origin: 148.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eAn array is given. Convert it into a spiral 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: 67px 8px; transform-origin: 67px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example, a=1:27;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 122.6px; 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 61.3px; transform-origin: 404px 61.3px; 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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e out=[21    22    23    24    25    26\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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e      20     7     8     9    10    27\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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e      19     6     1     2    11     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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e      18     5     4     3    12     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: 152px 8.5px; tab-size: 4; transform-origin: 152px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e      17    16    15    14    13     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: 156px 8.5px; tab-size: 4; transform-origin: 156px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e       0     0     0     0     0     0]\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: 200px 8px; transform-origin: 200px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eadd necessary amount of zeros to fill in the remaining positions.\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: 84px 8px; transform-origin: 84px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eNote - spiral() is forbidden.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = spi_out_3(p)","test_suite":"%%\r\np= 1:27;\r\ny= [21    22    23    24    25    26\r\n      20     7     8     9    10    27\r\n      19     6     1     2    11     0\r\n      18     5     4     3    12     0\r\n      17    16    15    14    13     0\r\n       0     0     0     0     0     0];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np= 49:-1:1;\r\ny= [7     6     5     4     3     2     1\r\n     8    29    28    27    26    25    24\r\n     9    30    43    42    41    40    23\r\n    10    31    44    49    48    39    22\r\n    11    32    45    46    47    38    21\r\n    12    33    34    35    36    37    20\r\n    13    14    15    16    17    18    19];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np=[4074\t4529\t635\t4567\t3162\t488\t1393\t2735\t4788\t4825\t789\t4853\t4786\t2427\t4002\t710\t2109\t4579\t3962\t4798\t3279\t179\t4246\t4670\t3394\t3789\t3716\t1962\t3278\t856\t3531\t160\t1385\t231\t486\t4118\t3475\t1586\t4752\t173\t2194\t1908\t3828\t3976\t935\t2449\t2228\t3232\t3547\t3774\t1381\t3399\t3276\t814\t595\t2492\t4799\t1702\t2927\t1120\t3757\t1276\t2530\t3496\t4455\t4797\t2737\t694\t747\t1288\t4204\t1272\t4072\t1218\t4647\t1750\t983\t1256\t3081\t2367\t1759\t4155\t2927\t2749\t4586\t1430\t3787\t3769\t1903\t2840\t380\t270\t2654\t3896\t4671\t650\t2845\t2347\t60\t1686\t811\t3972\t1557\t2643\t829\t3010\t1315\t3271\t3447\t3741\t2253\t420\t1145\t4567\t762\t4130\t2692\t4981\t391\t2214\t534\t4810\t24\t3875\t4087\t4344\t423\t1999\t1300\t4001\t2158\t4554\t910\t1320\t728\t681\t4347\t2899\t2750\t725\t4266\t3111\t1755\t2567\t2010\t380\t1200\t617\t920\t1200\t2087\t249\t4514\t4724\t2455\t2447\t1689\t4501\t1847\t557\t3902\t1949\t1209\t2020\t483\t660\t4711\t4781\t2877\t299\t1174\t1766\t4106\t78\t216\t845\t3246\t3659\t3239\t2255\t2736\t1482\t3724\t945\t3434\t918\t1843\t3129\t3902\t406\t4647\t3879\t2434\t2180\t2234\t1532\t2543\t2554\t4089\t3975];\r\ny= [0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\t0\r\n0\t1689\t4501\t1847\t557\t3902\t1949\t1209\t2020\t483\t660\t4711\t4781\t2877\t299\r\n0\t2447\t2253\t420\t1145\t4567\t762\t4130\t2692\t4981\t391\t2214\t534\t4810\t1174\r\n0\t2455\t3741\t4072\t1218\t4647\t1750\t983\t1256\t3081\t2367\t1759\t4155\t24\t1766\r\n0\t4724\t3447\t1272\t3828\t3976\t935\t2449\t2228\t3232\t3547\t3774\t2927\t3875\t4106\r\n0\t4514\t3271\t4204\t1908\t3279\t179\t4246\t4670\t3394\t3789\t1381\t2749\t4087\t78\r\n0\t249\t1315\t1288\t2194\t4798\t1393\t2735\t4788\t4825\t3716\t3399\t4586\t4344\t216\r\n0\t2087\t3010\t747\t173\t3962\t488\t4074\t4529\t789\t1962\t3276\t1430\t423\t845\r\n0\t1200\t829\t694\t4752\t4579\t3162\t4567\t635\t4853\t3278\t814\t3787\t1999\t3246\r\n0\t920\t2643\t2737\t1586\t2109\t710\t4002\t2427\t4786\t856\t595\t3769\t1300\t3659\r\n0\t617\t1557\t4797\t3475\t4118\t486\t231\t1385\t160\t3531\t2492\t1903\t4001\t3239\r\n3975\t1200\t3972\t4455\t3496\t2530\t1276\t3757\t1120\t2927\t1702\t4799\t2840\t2158\t2255\r\n4089\t380\t811\t1686\t60\t2347\t2845\t650\t4671\t3896\t2654\t270\t380\t4554\t2736\r\n2554\t2010\t2567\t1755\t3111\t4266\t725\t2750\t2899\t4347\t681\t728\t1320\t910\t1482\r\n2543\t1532\t2234\t2180\t2434\t3879\t4647\t406\t3902\t3129\t1843\t918\t3434\t945\t3724];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np= pascal(6);\r\np=p(:)';\r\ny= [10    20    35    56     1     5\r\n     4     1     2     3     4    15\r\n     1     1     1     1     5    35\r\n    21     1     1     1     6    70\r\n    15    10     6     3     1   126\r\n   252   126    56    21     6     1];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np= eye(6);\r\np=p(:)'\r\ny= [0     1     0     0     0     0\r\n     0     0     1     0     0     0\r\n     0     0     1     0     0     0\r\n     0     0     0     0     0     1\r\n     0     0     1     0     0     0\r\n     1     0     0     0     0     0];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\np= [-84  -132   -54  -104  -137   -31   -42  -101   -88   -94  -163  -146  -115,-159   -48];\r\ny= [-42  -101   -88   -94\r\n   -31   -84  -132  -163\r\n  -137  -104   -54  -146\r\n     0   -48  -159  -115];\r\nassert(isequal(spi_out_3(p),y))\r\n\r\n%%\r\nfiletext = fileread('spi_out_3.m');\r\nassert(isempty(strfind(filetext, 'spiral')),'spiral() forbidden')","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":363598,"edited_by":223089,"edited_at":"2022-07-02T18:04:44.000Z","deleted_by":null,"deleted_at":null,"solvers_count":10,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-04-14T02:57:42.000Z","updated_at":"2022-07-02T18:04:44.000Z","published_at":"2020-04-14T02:57:42.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\u003eAn array is given. Convert it into a spiral 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, a=1:27;\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ out=[21    22    23    24    25    26\\n      20     7     8     9    10    27\\n      19     6     1     2    11     0\\n      18     5     4     3    12     0\\n      17    16    15    14    13     0\\n       0     0     0     0     0     0]]]\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\u003eadd necessary amount of zeros to fill in the remaining positions.\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\u003eNote - spiral() is forbidden.\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":2342,"title":"Numbers spiral diagonals (Part 2)","description":"Inspired by Project Euler n°28 and 58.\r\nA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\r\nFor example with n=5, the spiral matrix is :\r\n                       21 22 23 24 25\r\n                       20  7  8  9 10\r\n                       19  6  1  2 11\r\n                       18  5  4  3 12\r\n                       17 16 15 14 13\r\nThe sum of the numbers on the diagonals is 101 (See problem 2340) and you have 5 primes (3, 5, 7, 13, 17) out of the 9 numbers lying along both diagonals. So the prime ratio is 5/9 ≈ 55%.\r\nWith a 7x7 spiral matrix, the ratio is 62% (8 primes out of the 13 diagonal numbers).\r\nWhat is the side length (always odd and greater than 1) of the square spiral for which the ratio of primes along both diagonals FIRST falls below p% ? (0\u003cp\u003c1)","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: 326.167px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 163.083px; transform-origin: 407px 163.083px; 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: 120px 8px; transform-origin: 120px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInspired by Project Euler n°28 and 58.\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: 341px 8px; transform-origin: 341px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\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: 131.5px 8px; transform-origin: 131.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eFor example with n=5, the spiral matrix is :\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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       21 22 23 24 25\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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       20  7  8  9 10\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       19  6  1  2 11\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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       18  5  4  3 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: 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: 148px 8.5px; tab-size: 4; transform-origin: 148px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e                       17 16 15 14 13\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; 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: 382.5px 8px; transform-origin: 382.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThe sum of the numbers on the diagonals is 101 (See problem 2340) and you have 5 primes (3, 5, 7, 13, 17) out of the 9 numbers lying along both diagonals. So the prime ratio is 5/9 ≈ 55%.\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: 262px 8px; transform-origin: 262px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWith a 7x7 spiral matrix, the ratio is 62% (8 primes out of the 13 diagonal numbers).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 364.5px 8px; transform-origin: 364.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"perspective-origin: 74px 8px; transform-origin: 74px 8px; \"\u003eWhat is the side length \u003c/span\u003e\u003cspan style=\"border-block-end-style: solid; border-block-end-width: 1px; border-bottom-style: solid; border-bottom-width: 1px; perspective-origin: 2.5px 8.5px; transform-origin: 2.5px 8.5px; \"\u003e(\u003c/span\u003e\u003cspan style=\"perspective-origin: 96px 8px; transform-origin: 96px 8px; \"\u003ealways odd and greater than 1\u003c/span\u003e\u003cspan style=\"border-block-end-style: solid; border-block-end-width: 1px; border-bottom-style: solid; border-bottom-width: 1px; perspective-origin: 2.5px 8.5px; transform-origin: 2.5px 8.5px; \"\u003e)\u003c/span\u003e\u003cspan style=\"perspective-origin: 189.5px 8px; transform-origin: 189.5px 8px; \"\u003e of the square spiral for which the ratio of primes along both diagonals FIRST falls below p% ? (0\u0026lt;p\u0026lt;1)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function res=spiral_ratio(pourcentage)\r\nres=pourcentage*2;\r\nend","test_suite":"%%\r\nx = 0.8;\r\ny_correct = 3;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.5;\r\ny_correct = 11;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.4;\r\ny_correct = 31;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.3;\r\ny_correct = 49;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.25;\r\ny_correct = 99;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.2;\r\ny_correct = 309;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.15;\r\ny_correct = 981;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.14;\r\ny_correct = 1883;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.13;\r\ny_correct = 3593;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.12;\r\ny_correct = 6523;\r\nassert(isequal(spiral_ratio(x),y_correct))\r\n%%\r\nx = 0.11;\r\ny_correct = 12201;\r\nassert(isequal(spiral_ratio(x),y_correct))","published":true,"deleted":false,"likes_count":7,"comments_count":5,"created_by":5390,"edited_by":223089,"edited_at":"2022-09-26T17:42:20.000Z","deleted_by":null,"deleted_at":null,"solvers_count":196,"test_suite_updated_at":"2022-07-09T19:28:50.000Z","rescore_all_solutions":false,"group_id":31,"created_at":"2014-05-31T18:36:25.000Z","updated_at":"2026-03-04T11:06:42.000Z","published_at":"2014-05-31T18:53:35.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\u003eInspired by Project Euler n°28 and 58.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eA n x n spiral matrix is obtained by starting with the number 1 and moving to the right in a clockwise direction.\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 with n=5, the spiral matrix 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[                       21 22 23 24 25\\n                       20  7  8  9 10\\n                       19  6  1  2 11\\n                       18  5  4  3 12\\n                       17 16 15 14 13]]\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\u003eThe sum of the numbers on the diagonals is 101 (See problem 2340) and you have 5 primes (3, 5, 7, 13, 17) out of the 9 numbers lying along both diagonals. So the prime ratio is 5/9 ≈ 55%.\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\u003eWith a 7x7 spiral matrix, the ratio is 62% (8 primes out of the 13 diagonal numbers).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhat is the side length (always odd and greater than 1) of the square spiral for which the ratio of primes along both diagonals FIRST falls below p% ? (0\u0026lt;p\u0026lt;1)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"term":"tag:\"spiral\"","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:\"spiral\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"spiral\"","","\"","spiral","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f03d1b0b040\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f03d1b0afa0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f03d1b0a6e0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f03d1b0b2c0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f03d1b0b220\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f03d1b0b180\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f03d1b0b0e0\u003e":"tag:\"spiral\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f03d1b0b0e0\u003e":"tag:\"spiral\""},"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":"cody-search","password":"78X075ddcV44","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:\"spiral\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"spiral\"","","\"","spiral","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f03d1b0b040\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f03d1b0afa0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f03d1b0a6e0\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f03d1b0b2c0\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f03d1b0b220\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f03d1b0b180\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f03d1b0b0e0\u003e":"tag:\"spiral\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f03d1b0b0e0\u003e":"tag:\"spiral\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2597,"difficulty_rating":"easy-medium"},{"id":1400,"difficulty_rating":"easy-medium"},{"id":56383,"difficulty_rating":"easy-medium"},{"id":2340,"difficulty_rating":"medium"},{"id":45452,"difficulty_rating":"medium"},{"id":45404,"difficulty_rating":"medium"},{"id":255,"difficulty_rating":"medium"},{"id":659,"difficulty_rating":"medium"},{"id":2455,"difficulty_rating":"medium"},{"id":54780,"difficulty_rating":"medium"},{"id":45453,"difficulty_rating":"medium"},{"id":2342,"difficulty_rating":"medium-hard"}]}}