{"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":48990,"title":"Solve the recursion","description":"Solve the recursion: f(n)=f(n-1)+1 + f(n-2)+2.\r\nf(1)=4;\r\nf(2)=8;","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: 81px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 40.5px; transform-origin: 407px 40.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: 141px 8px; transform-origin: 141px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSolve the recursion: f(n)=f(n-1)+1 + f(n-2)+2.\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: 21px 8px; transform-origin: 21px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ef(1)=4;\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: 21px 8px; transform-origin: 21px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ef(2)=8;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = rec(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nfiletext = fileread('rec.m');\r\nillegal = contains(filetext, 'switch') || contains(filetext, 'else') \r\nassert(~illegal)\r\n%%\r\nn = 1;\r\ny_correct = 4;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 5;\r\ny_correct = 44;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 13;\r\ny_correct = 2204;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 20;\r\ny_correct = 64076;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 34;\r\ny_correct = 54018518;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 37;\r\ny_correct = 228826124;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 40;\r\ny_correct = 969323026;\r\nassert(isequal(rec(n),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":698530,"edited_by":223089,"edited_at":"2022-12-12T06:11:46.000Z","deleted_by":null,"deleted_at":null,"solvers_count":38,"test_suite_updated_at":"2022-12-12T06:11:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-12-22T17:50:06.000Z","updated_at":"2026-03-23T17:38:43.000Z","published_at":"2020-12-31T01:21:21.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\u003eSolve the recursion: f(n)=f(n-1)+1 + f(n-2)+2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ef(1)=4;\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\u003ef(2)=8;\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":56030,"title":"Pay up","description":"You live in a world where arbitrary denominations of currency exist. You owe your friend a sum of money denoted by s. However, it is possible that neither of you carry exact change for this deal. You and your friend happen to carry currency in only certain specific denominations. You both take all the money you have and lay them out on a table and identify every bill of currency you have collectively. The list L contains the values of each of the bills such that the values corresponding to your bills come with a positive sign and that of your friend negative. The function pay takes as arguments L and s and returns boolean true if the exchange is possible and false otherwise. Complete the definition of pay.\r\nConstraints:\r\n(1) s ∈ Z\r\n(2) L ∈ T ∣ T = { { x₁,x₂,...,xₙ } ∣ xᵢ ∈ Z, i ∈ N } ∩ { ∅ }","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: 216px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 108px; transform-origin: 407px 108px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 126px; 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 63px; text-align: left; transform-origin: 384px 63px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYou live in a world where arbitrary denominations of currency exist. You owe your friend a sum of money denoted by \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003es. \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eHowever, it is possible that neither of you carry exact change for this deal. You and your friend happen to carry currency in only certain specific denominations. You both take all the money you have and lay them out on a table and identify every bill of currency you have collectively. The list \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eL \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003econtains the values of each of the bills such that the values corresponding to your bills come with a positive sign and that of your friend negative. The function \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003epay\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e takes as arguments \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eL \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eand \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003es\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e and returns boolean \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003etrue \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eif the exchange is possible and \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003efalse \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eotherwise. Complete the definition of \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003epay\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e.\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eConstraints:\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e(1)\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e s\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: 0px 0px; transform-origin: 0px 0px; \"\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eZ\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e(2) \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eL\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e ∈ T ∣ T = { { x₁,x₂,...,xₙ } ∣ xᵢ ∈ \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eZ,\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e i ∈ \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eN \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e} ∩ { ∅ }\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = pay(L,s)\r\n  y = 0;\r\nend","test_suite":"%%\r\nL = [967, 605, -249, -255, 894, -199];\r\ns = -504;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-22];\r\ns = -467;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-637, -402];\r\ns = 0;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [473, -498, -16, -288];\r\ns = 169;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-384, -715, 651, 874, -13];\r\ns = 759;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [186, -745];\r\ns = -166;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-186, -266, 914, 122, -289, 912];\r\ns = 359;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [437, -832, 572, -361, 877, 548];\r\ns = 548;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-803, 95, 503];\r\ns = 503;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [62, -867, -222];\r\ns = -805;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [394];\r\ns = -333;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-836, -353];\r\ns = 519;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [740, 952, -150];\r\ns = -765;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [137, -973, 620];\r\ns = 757;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [483, 772, 458];\r\ns = 109;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [212, 869, 10, -468, 523];\r\ns = -905;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-851];\r\ns = 822;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-667, -308, 549, 792, -128];\r\ns = 674;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = -8;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [206, -246, -545, -402, 18, 150];\r\ns = -929;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-104, -710, -565, 448, -717];\r\ns = -669;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [672, -991, -467, 527, -111, -14];\r\ns = -65;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [384];\r\ns = -371;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-436, -662, -530, 279, -469, -415];\r\ns = 257;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [844, 288];\r\ns = 956;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-709, 570, 896, 293, -925];\r\ns = 403;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [11, -626, -258, -537, -961, -341];\r\ns = -864;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [710, -256, 63];\r\ns = -136;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-336, -238, 127, 193, 437, -220];\r\ns = 56;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-446, 274];\r\ns = -172;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [648, 931, 234, -218];\r\ns = 737;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [447, 109, 157, -252, -512, 134];\r\ns = -208;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-581, -916];\r\ns = -133;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [801, 621, -437, 580];\r\ns = -437;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [617, -424, -690, 9, -783];\r\ns = -64;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [864, -98, 179, -443, 505, 515];\r\ns = 922;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-48];\r\ns = -469;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [581, 372, -712, -154, 126, 80];\r\ns = 787;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [655, -167, 357, 289, -891];\r\ns = -701;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [941, -67, -764, -202, -919, -210];\r\ns = -809;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-361, -905, 437, 955, -40, 907];\r\ns = 915;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-506, -724];\r\ns = 157;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-432, -652, 860, -115, 579];\r\ns = -497;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 735;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-141, 334, -315, -866];\r\ns = -141;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [874, -980, -112];\r\ns = 246;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [768, 962, 245];\r\ns = 245;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [207, -281, 543, 462, -440, 995];\r\ns = 462;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 397;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [438, -548, -295, -270, 721, 750];\r\ns = -405;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [583, -617, -567];\r\ns = 307;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-590];\r\ns = -343;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-582];\r\ns = -526;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-634];\r\ns = -470;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-341, -761, -641];\r\ns = -341;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [929, -448, -53, 951, -932];\r\ns = -53;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [23, -338, -653, 107, -533, 802];\r\ns = 61;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-297, -331, -150, 481, -112, 895];\r\ns = -262;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-992, 401, -467];\r\ns = 339;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [592, 611, 660];\r\ns = 900;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-135, -544, -857];\r\ns = -523;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-259, -466, 976, 635, -607];\r\ns = 369;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-876, -852, -430, 370, -489, 468];\r\ns = -971;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-804, 96, -655, -253, 462];\r\ns = 209;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-418, 193, 353, 810, -780];\r\ns = 546;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-383, 116, 814, -359, 106];\r\ns = -359;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = -327;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [317, -825, 299, 674];\r\ns = 991;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 977;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [873, -44, 505, 352, -794, -609];\r\ns = 0;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 300;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-60, -817, 431, 411, -229, 625];\r\ns = -386;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-830];\r\ns = 786;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-341, 711, -155, 531, -317];\r\ns = -155;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = -429;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 596;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [121, 915, 610, -114, -957, -594];\r\ns = 938;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [633, -465, -282, 413, -58];\r\ns = -110;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-946, -349, 290, 228, 565, 399];\r\ns = -331;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-104, 91, 452];\r\ns = 167;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [374, -547, -796, 603, 18];\r\ns = 448;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-503, 440, 604, 897, -390, 597];\r\ns = -33;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-762, -748, -55, -542, -927, -339];\r\ns = -799;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-129, -575, 221, 926, 927, -44];\r\ns = 798;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-669, 999, 316, 594, -40, 625];\r\ns = -75;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-857];\r\ns = 824;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [810, 680, 180];\r\ns = 680;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-554, 478];\r\ns = -926;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-562, 736, 114, 855];\r\ns = -562;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [478, -853, -694, -868, 666];\r\ns = -881;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-790, -131, -419, -669, 956];\r\ns = -673;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-19, 702, -57, -771];\r\ns = 728;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-188];\r\ns = 0;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = -469;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-491, 617, 718, 503, 452];\r\ns = -341;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [290, 697, -644, 345, 230, -494];\r\ns = -494;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 0;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [289];\r\ns = 650;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-426, -610, -85, 191, -544, -385];\r\ns = 618;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [833, 403, -426];\r\ns = -426;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":2242415,"edited_by":2242415,"edited_at":"2022-09-29T09:49:41.000Z","deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":"2022-09-29T08:37:54.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-09-23T11:47:19.000Z","updated_at":"2022-09-29T09:49:41.000Z","published_at":"2022-09-23T11:50:25.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\u003eYou live in a world where arbitrary denominations of currency exist. You owe your friend a sum of money denoted by \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es. \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eHowever, it is possible that neither of you carry exact change for this deal. You and your friend happen to carry currency in only certain specific denominations. You both take all the money you have and lay them out on a table and identify every bill of currency you have collectively. The list \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eL \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003econtains the values of each of the bills such that the values corresponding to your bills come with a positive sign and that of your friend negative. The function \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003epay\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e takes as arguments \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eL \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and returns boolean \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etrue \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eif the exchange is possible and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efalse \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eotherwise. Complete the definition of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003epay\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eConstraints:\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\u003e(1)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e s\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\u003eZ\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\u003e(2) \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eL\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ∈ T ∣ T = { { x₁,x₂,...,xₙ } ∣ xᵢ ∈ \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eZ,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e i ∈ \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e} ∩ { ∅ }\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":55290,"title":"Cut the rod","description":"A rod of length n can be cut in different sizes. Different price is associated with different length of cuts. \r\nlength, len= [1, 2, 3, 4, 5,  6,   7,  8]\r\nprice, p     = [1, 5, 8, 9,10,17,17,20]\r\nHere, if you cut a piece of length 5, the price for that piece is 10. For length of 8, the price is 20.\r\nSay, you have to obtain a rod of length x. By cutting the rod in which way will give you the maximum price.\r\n\r\nFor instance, say x=4. you can cut the rod in pieces like (1,3)/(3,1), (2,2), (1,1,1,1), (1,1,2)/(1,2,1)/... or (4).\r\nThe maximum revenue that you can get here is when you cut the rod in (2,2) pieces to get length x =\u003e 5+5=10. \r\nFor (1,3)=\u003e9; (1,1,1,1)=\u003e 4; (1,1,2)=\u003e7, (4)=\u003e9. \r\n\r\nIn this problem, you have to return the maximum reveneue you can obtain by cutting the rod of size x.","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: 322.875px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 161.438px; transform-origin: 407px 161.438px; 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=\"\"\u003eA rod of length n can be cut in different sizes. Different price is associated with different length of cuts. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 40.875px; 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 20.4375px; transform-origin: 391px 20.4375px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4375px; 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.2125px; text-align: left; transform-origin: 363px 10.2188px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003elength, len= [1, 2, 3, 4, 5,  6,   7,  8]\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4375px; 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.2125px; text-align: left; transform-origin: 363px 10.2188px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eprice, p     = [1, 5, 8, 9,10,17,17,20]\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eHere, if you cut a piece of length 5, the price for that piece is 10. For length of 8, the price is 20.\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eSay, you have to obtain a rod of length x. By cutting the rod in which way will give you the maximum price.\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor instance, say x=4. you can cut the rod in pieces like (1,3)/(3,1), (2,2), (1,1,1,1), (1,1,2)/(1,2,1)/... or (4).\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThe maximum revenue that you can get here is when you cut the rod in (2,2) pieces to get length x =\u0026gt; 5+5=10. \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor (1,3)=\u0026gt;9; (1,1,1,1)=\u0026gt; 4; (1,1,2)=\u0026gt;7, (4)=\u0026gt;9. \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIn this problem, you have to return the maximum reveneue you can obtain by cutting the rod of size x.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = rod_cut(x,p)\r\n  y = x;\r\nend","test_suite":"%%\r\np=[1,5,8,9,10,17,17,20];\r\nx=4;\r\ny_correct = 10;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[1,5,8,9,10,17,17,20];\r\nx=8;\r\ny_correct = 22;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[1,5,8,9,10,17,17,20];\r\nx=7;\r\ny_correct = 18;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[1,5,8,9,10,17,17,20];\r\nx=6;\r\ny_correct = 17;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[10,5,3,18];\r\nx=4;\r\ny_correct = 40;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n\r\n%%\r\np=[10,5,3,18];\r\nx=2;\r\ny_correct = 20;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n\r\n%%\r\np=[10,5,36,18,36];\r\nx=4;\r\ny_correct = 46;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[10,5,36,18,36];\r\nx=5;\r\ny_correct = 56;\r\nassert(isequal(rod_cut(x,p),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":363598,"edited_by":363598,"edited_at":"2022-08-13T23:35:18.000Z","deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":"2022-08-13T23:35:18.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-08-13T23:28:51.000Z","updated_at":"2026-01-06T08:34:18.000Z","published_at":"2022-08-13T23:35:18.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\u003eA rod of length n can be cut in different sizes. Different price is associated with different length of cuts. \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\u003elength, len= [1, 2, 3, 4, 5,  6,   7,  8]\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\u003eprice, p     = [1, 5, 8, 9,10,17,17,20]\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\u003eHere, if you cut a piece of length 5, the price for that piece is 10. For length of 8, the price is 20.\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\u003eSay, you have to obtain a rod of length x. By cutting the rod in which way will give you the maximum price.\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\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\u003eFor instance, say x=4. you can cut the rod in pieces like (1,3)/(3,1), (2,2), (1,1,1,1), (1,1,2)/(1,2,1)/... or (4).\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 maximum revenue that you can get here is when you cut the rod in (2,2) pieces to get length x =\u0026gt; 5+5=10. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor (1,3)=\u0026gt;9; (1,1,1,1)=\u0026gt; 4; (1,1,2)=\u0026gt;7, (4)=\u0026gt;9. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this problem, you have to return the maximum reveneue you can obtain by cutting the rod of size x.\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":44066,"title":"Number of paths on a 3d grid","description":"This problem is inspired by \u003chttps://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003e, which you might want to solve first.\r\n\r\nConsider a 3d grid formed by n vertices vertically down, m vertices horizontally right, l vertices horizontally front. Your starting point is at the top left front vertex. Your destination is the bottom right back vertex. (From one corner to the furthest corner) You are permitted at each vertex to choose to move down,  right or back, that is in the direction towards the destination. You are not to move on what constitutes a back step like moving left, up, or front. If you hit the bottom boundary, right boundary, or back boundary, take it to be given that you move along the 2d boundary.\r\n\r\nEx: in a 2x2X2 grid there are 6 ways. (down, right, back), (d,b,r), (r,d,b), (r,b,d), (b,r,d), (b,d,r)\r\n\r\n4x3x2 has 60 ways\r\n\r\n6x5x4 has 27720 ways\r\n\r\nThis problem can be solved using dynamic programming but there are other methods too.\r\n\r\n","description_html":"\u003cp\u003eThis problem is inspired by \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003c/a\u003e, which you might want to solve first.\u003c/p\u003e\u003cp\u003eConsider a 3d grid formed by n vertices vertically down, m vertices horizontally right, l vertices horizontally front. Your starting point is at the top left front vertex. Your destination is the bottom right back vertex. (From one corner to the furthest corner) You are permitted at each vertex to choose to move down,  right or back, that is in the direction towards the destination. You are not to move on what constitutes a back step like moving left, up, or front. If you hit the bottom boundary, right boundary, or back boundary, take it to be given that you move along the 2d boundary.\u003c/p\u003e\u003cp\u003eEx: in a 2x2X2 grid there are 6 ways. (down, right, back), (d,b,r), (r,d,b), (r,b,d), (b,r,d), (b,d,r)\u003c/p\u003e\u003cp\u003e4x3x2 has 60 ways\u003c/p\u003e\u003cp\u003e6x5x4 has 27720 ways\u003c/p\u003e\u003cp\u003eThis problem can be solved using dynamic programming but there are other methods too.\u003c/p\u003e","function_template":"function y = count3dPath(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nm = 2; n = 2 ; l = 5;\r\ny_correct = 30;\r\nassert(isequal(count3dPath(m,n,l),y_correct))\r\n \t\t\r\n%%\r\nm = 8; n = 5 ; l = 2;\r\ny_correct = 3960;\r\nassert(isequal(count3dPath(m,n,l),y_correct))\r\n\t\r\n%%\r\nm = 5; n = 5 ; l = 10;\r\ny_correct = 1701700;\r\nassert(isequal(count3dPath(m,n,l),y_correct))\r\n\t\r\n%%\r\nm = 8; n = 4 ; l=2;\r\ny_correct = 1320;\r\nassert(isequal(count3dPath(m,n,l),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":115733,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-02-14T00:01:08.000Z","updated_at":"2026-03-19T08:12:10.000Z","published_at":"2017-02-14T00:01:08.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eThis problem is inspired by\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;, which you might want to solve first.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConsider a 3d grid formed by n vertices vertically down, m vertices horizontally right, l vertices horizontally front. Your starting point is at the top left front vertex. Your destination is the bottom right back vertex. (From one corner to the furthest corner) You are permitted at each vertex to choose to move down, right or back, that is in the direction towards the destination. You are not to move on what constitutes a back step like moving left, up, or front. If you hit the bottom boundary, right boundary, or back boundary, take it to be given that you move along the 2d boundary.\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\u003eEx: in a 2x2X2 grid there are 6 ways. (down, right, back), (d,b,r), (r,d,b), (r,b,d), (b,r,d), (b,d,r)\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\u003e4x3x2 has 60 ways\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\u003e6x5x4 has 27720 ways\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\u003eThis problem can be solved using dynamic programming but there are other methods too.\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":47154,"title":"Climbing the stairs","description":null,"description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 229.4px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 114.7px; transform-origin: 407px 114.7px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eThe number of steps in the staircase are given as n. You can climb atmost 3 steps at a time.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eOutput the \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003enumber of ways\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e you can climb the stairs modulo (10^9 + 7).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eif n = 1, output = 1, because ways of climbing = { (1) }\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eif n = 2, output = 2, because ways of climbing = {(1,1), (2)}\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eif n = 3, output =  4, because ways of climbing = { (1,1,1), (1,2), (2,1), (3) }\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eHint : refer tags\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = climb(n) \r\ny = y + y + y\r\ny = mod(y,10^9 + 7);\r\nend","test_suite":"%%\r\nn = 1;\r\ny_correct = 1;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 2;\r\ny_correct = 2;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 3;\r\ny_correct = 4;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 100;\r\ny_correct = 347873931;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 500; % normal people don't do this.\r\ny_correct = 283701821;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 1000; %Some sort of kung fu panda trainning :P\r\ny_correct = 509672692;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 10000; %hypothetical case.\r\ny_correct = 126130994;\r\nassert(isequal(climb(n),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":442401,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-10-31T11:51:36.000Z","updated_at":"2025-11-19T15:10:41.000Z","published_at":"2020-10-31T11:51:36.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\u003eThe number of steps in the staircase are given as n. You can climb atmost 3 steps at a time.\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\u003eOutput the \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enumber of ways\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e you can climb the stairs modulo (10^9 + 7).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 1, output = 1, because ways of climbing = { (1) }\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 2, output = 2, because ways of climbing = {(1,1), (2)}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 3, output =  4, because ways of climbing = { (1,1,1), (1,2), (2,1), (3) }\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHint : refer tags\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":44072,"title":"Number of paths on a n-dimensional grid","description":"This problem is inspired by \u003chttps://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003e and  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\u003e, which you might want to solve first.\r\n \r\nConsider n-dimensional grid, and you are moving from one corner to the farthest corner in a minimal number of moves. Each move corresponds to moving to a neighbouring hypercube (among possible up to 2*n neighbours). How many ways are there?\r\n\r\nInput format is a row array of size \"d\" (for d dimension) with number of grid points on each direction.\r\n\r\nOptional: can you solve it without loops?","description_html":"\u003cp\u003eThis problem is inspired by \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003c/a\u003e and  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\u003c/a\u003e, which you might want to solve first.\u003c/p\u003e\u003cp\u003eConsider n-dimensional grid, and you are moving from one corner to the farthest corner in a minimal number of moves. Each move corresponds to moving to a neighbouring hypercube (among possible up to 2*n neighbours). How many ways are there?\u003c/p\u003e\u003cp\u003eInput format is a row array of size \"d\" (for d dimension) with number of grid points on each direction.\u003c/p\u003e\u003cp\u003eOptional: can you solve it without loops?\u003c/p\u003e","function_template":"function y = countNdPath(NdRowVector)\r\n  y = sum(NdRowVector);\r\nend","test_suite":"%%\r\nNdRowVector = [3,3,3,3,3];\r\ny_correct = 113400;\r\nassert(isequal(countNdPath(NdRowVector),y_correct))\r\n\r\n%%\r\nNdRowVector = [1,3,3,3,3,1,1,1,3,3];\r\ny_correct = 7484400;\r\nassert(isequal(countNdPath(NdRowVector),y_correct))\r\n\r\n%%\r\nNdRowVector = [2,2,2,2,2,2,2,1,1,2,2,2,2];\r\ny_correct = 39916800;\r\nassert(isequal(countNdPath(NdRowVector),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":115733,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":50,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-02-14T01:28:35.000Z","updated_at":"2025-12-16T03:16:34.000Z","published_at":"2017-02-14T01:28:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is inspired by\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt; and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;, which you might want to solve first.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConsider n-dimensional grid, and you are moving from one corner to the farthest corner in a minimal number of moves. Each move corresponds to moving to a neighbouring hypercube (among possible up to 2*n neighbours). How many ways are there?\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\u003eInput format is a row array of size \\\"d\\\" (for d dimension) with number of grid points on each 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\u003eOptional: can you solve it without loops?\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":45415,"title":"Find an optimal placement of coolers on a grid","description":"In a certain chemical plant, 6 new pieces of cooling equipment (coolers) are to be installed in a vacant space. This vacant space was divided into a grid of 6 cells by 6 cells. Your task is to assign the 6 coolers to 6 cells in this grid with the following requirements:\r\n\r\n# There must be one cooler for every column in the grid.\r\n# If you decide to install a cooler at row R, column C, then the cooler at column C+1 must be installed either on row R-1, R, or R+1 only. This is done to ease the connection of coolers by piping.\r\n# The total installation cost for the 6 coolers must be minimum.\r\n\r\nFor this problem, you are given a cost matrix (COST) in relation to the third requirement above. COST is a 6 x 6 matrix where the _r,c_-th element is the cost of assigning any cooler to row _r_, column _c_ (All the coolers are identical). Write a function that accepts the matrix COST, and output the value of the minimum cost of installation. You are ensured that all elements of COST are integers in the range [1,1000].\r\n\r\nIn the sample test case below, the optimal placement is at the following rows: 4,3,3,2,2,2.\r\n\r\n  \u003e\u003e COST = [695   766   710   119   752   548;\r\n             318   796   755   499   256   139;\r\n             951   187   277   960   506   150;\r\n              35   490   680   341   700   258;\r\n             439   446   656   586   891   841;\r\n             382   647   163   224   960   255];\r\n  \u003e\u003e coolers(COST)\r\n  ans = \r\n        1393\r\n    \r\nMeanwhile, the optimal placement for the case below is at rows: 5,6,5,6,5,6\r\n\r\n  \u003e\u003e COST = [815   617   918    76   569   312;\r\n             244   474   286    54   470   529;\r\n             930   352   758   531   455   988;\r\n             350   831   754   780    12   602;\r\n             197   586   381   935   163   263;\r\n             252   550   568   130   795   100];\r\n  \u003e\u003e coolers(COST)\r\n  ans = \r\n        1521\r\n","description_html":"\u003cp\u003eIn a certain chemical plant, 6 new pieces of cooling equipment (coolers) are to be installed in a vacant space. This vacant space was divided into a grid of 6 cells by 6 cells. Your task is to assign the 6 coolers to 6 cells in this grid with the following requirements:\u003c/p\u003e\u003col\u003e\u003cli\u003eThere must be one cooler for every column in the grid.\u003c/li\u003e\u003cli\u003eIf you decide to install a cooler at row R, column C, then the cooler at column C+1 must be installed either on row R-1, R, or R+1 only. This is done to ease the connection of coolers by piping.\u003c/li\u003e\u003cli\u003eThe total installation cost for the 6 coolers must be minimum.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eFor this problem, you are given a cost matrix (COST) in relation to the third requirement above. COST is a 6 x 6 matrix where the \u003ci\u003er,c\u003c/i\u003e-th element is the cost of assigning any cooler to row \u003ci\u003er\u003c/i\u003e, column \u003ci\u003ec\u003c/i\u003e (All the coolers are identical). Write a function that accepts the matrix COST, and output the value of the minimum cost of installation. You are ensured that all elements of COST are integers in the range [1,1000].\u003c/p\u003e\u003cp\u003eIn the sample test case below, the optimal placement is at the following rows: 4,3,3,2,2,2.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; COST = [695   766   710   119   752   548;\r\n           318   796   755   499   256   139;\r\n           951   187   277   960   506   150;\r\n            35   490   680   341   700   258;\r\n           439   446   656   586   891   841;\r\n           382   647   163   224   960   255];\r\n\u0026gt;\u0026gt; coolers(COST)\r\nans = \r\n      1393\r\n\u003c/pre\u003e\u003cp\u003eMeanwhile, the optimal placement for the case below is at rows: 5,6,5,6,5,6\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; COST = [815   617   918    76   569   312;\r\n           244   474   286    54   470   529;\r\n           930   352   758   531   455   988;\r\n           350   831   754   780    12   602;\r\n           197   586   381   935   163   263;\r\n           252   550   568   130   795   100];\r\n\u0026gt;\u0026gt; coolers(COST)\r\nans = \r\n      1521\r\n\u003c/pre\u003e","function_template":"function y = coolers(COST)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('coolers.m')\r\nassert(isempty(strfind(filetext, 'rand')))\r\n%%\r\nCOST = [815   617   918    76   569   312;\r\n   244   474   286    54   470   529;\r\n   930   352   758   531   455   988;\r\n   350   831   754   780    12   602;\r\n   197   586   381   935   163   263;\r\n   252   550   568   130   795   100];\r\nassert(isequal(coolers(COST),1521))\r\n%%\r\nCOST = [690   153   107    85   182   550;\r\n   749   826   962   400   264   145;\r\n   451   539     5   260   146   854;\r\n    84   997   775   801   137   623;\r\n   229    79   818   432   870   351;\r\n   914   443   869   911   580   514];\r\nassert(isequal(coolers(COST),1179))\r\n%%\r\nCOST = [402   418   338   242   576    44;\r\n    76    50   901   404    60   169;\r\n   240   903   370    97   235   650;\r\n   124   945   112   132   354   732;\r\n   184   491   781   943   822   648;\r\n   240   490   390   957    16   451];\r\nassert(isequal(coolers(COST),697))\r\n%%\r\nCOST = [1 1 1000 1000 1000 1;\r\n        1 1000 1 1000 1000 1000;\r\n        1 1000 1000 1000 1 1000;\r\n        1 1000 1000 1 1000 1000;\r\n        1 1000 1000 1000 1000 1000;\r\n        1 1000 1000 1000 1000 1000];\r\nassert(isequal(coolers(COST),2004))\r\n%%\r\nCOST = [548   369   487   818   351   208;\r\n   297   626   436   795   940   302;\r\n   745   781   447   645   876   471;\r\n   189    82   307   379   551   231;\r\n   687   930   509   812   623   845;\r\n   184   776   511   533   588   195];\r\nassert(isequal(coolers(COST),1739))\r\n%%\r\nCOST = [226   431   259   222    86   489;\r\n   171   185   409   118   263   579;\r\n   228   905   595   297   802   238;\r\n   436   980   263   319    30   459;\r\n   312   439   603   425   929   964;\r\n   924   112   712   508   731   547];\r\nassert(isequal(coolers(COST),1234))\r\n%%\r\nCOST = [522   368    99   107   891   501;\r\n   232   988   262   654   335   480;\r\n   489    38   336   495   699   905;\r\n   625   886   680   780   198   610;\r\n   680   914   137   716    31   618;\r\n   396   797   722   904   745   860];\r\nassert(isequal(coolers(COST),1454))\r\n%%\r\nCOST = [806   490    60   819   973    84;\r\n   577   168   682   818   649   134;\r\n   183   979    43   723   801   174;\r\n   240   713    72   150   454   391;\r\n   887   501   522   660   433   832;\r\n    29   472    97   519   826   804];\r\nassert(isequal(coolers(COST),1172))\r\n%%\r\nCOST = [61         292         373          53         418         699;\r\n         400         432         199         738         984         667;\r\n         527          16         490         270         302         179;\r\n         417         985         340         423         702         129;\r\n         657         168         952         548         667        1000;\r\n         628         107         921         943         540         172];\r\nassert(isequal(coolers(COST),1253))\r\n%%\r\nCOST = [33   461   191   385   825   907;\r\n   562   982   429   583   983   880;\r\n   882   157   483   252   731   818;\r\n   670   856   121   291   344   261;\r\n   191   645   590   618   585   595;\r\n   369   377   227   266   108    23];\r\nassert(isequal(coolers(COST),1192))\r\n%%\r\nCOST = [426   599    69   719   779   441;\r\n   313   471   320   969   424   528;\r\n   162   696   531   532    91   458;\r\n   179   700   655   326   267   876;\r\n   423   639   408   106   154   519;\r\n    95    34   820   611   282   944];\r\nassert(isequal(coolers(COST),1316))\r\n%%\r\nCOST = [638   696   345   916   323   474;\r\n   958    68   781     2   785   153;\r\n   241   255   676   463   472   342;\r\n   677   225     7   425    36   608;\r\n   290   668   603   461   176   192;\r\n   672   845   387   771   722   739];\r\nassert(isequal(coolers(COST),1126))\r\n%%\r\nCOST = [243    92   648   237   771   257;\r\n   918   577   680   120   351   614;\r\n   270   684   636   608   663   583;\r\n   766   547   946   451   417   541;\r\n   189   426   209   459   842   870;\r\n   288   645   710   662   833   265];\r\nassert(isequal(coolers(COST),1711))\r\n%%\r\nCOST = [319   545   219   366   193   862;\r\n   120   648   106   764   139   485;\r\n   940   544   110   628   697   394;\r\n   646   722    64   772    94   672;\r\n   480   523   405   933   526   742;\r\n   640   994   449   973   531   521];\r\nassert(isequal(coolers(COST),1669))\r\n%%\r\nCOST = [674   622   842   636   885   896;\r\n   575   722   853   599   699   975;\r\n   794   844   722   911   905   664;\r\n   632   680   510   715   878   836;\r\n   523   869   667   944   689   720;\r\n   878   698   713   696   609   917];\r\nassert(isequal(coolers(COST),3837))\r\n%%\r\nCOST = [82 122 681 602 355 371;...\r\n    483 544 417 347 776 384;...\r\n    129 315 643 365 237 862;...\r\n    253 383 215 172 845 464;...\r\n    884 792 618 796 817 571;...\r\n    197 840 676 493 847 696];\r\nassert(isequal(coolers(COST),1452))\r\n%%\r\nCOST = [961 170 710 563 536 327;...\r\n    547 179 176 177 199 603;...\r\n    637 244 859 514 624 362;...\r\n    571 752 910 549 27 135;...\r\n    928 200 962 166 319 914;...\r\n    864 983 571 494 533 641];\r\nassert(isequal(coolers(COST),1569))\r\n%%\r\nCOST = [659 381 223 112 267 869;...\r\n    676 822 1000 425 292 529;...\r\n    745 172 64 614 189 915;...\r\n    843 330 426 989 23 974;...\r\n    517 967 405 220 450 586;...\r\n    152 807 401 355 244 119];\r\nassert(isequal(coolers(COST),1835))\r\n%%\r\nCOST = [927 925 215 554 571 679;...\r\n    594 643 249 631 336 213;...\r\n    884 105 227 986 958 82;...\r\n    425 701 704 635 440 275;...\r\n    608 396 755 601 602 868;...\r\n    71 85 548 910 721 560];\r\nassert(isequal(coolers(COST),1751))\r\n%%\r\nCOST = [465 433 384 904 809 299;...\r\n    431 506 712 219 180 769;...\r\n    774 376 481 874 166 502;...\r\n    654 481 730 83 182 910;...\r\n    658 343 938 466 692 58;...\r\n    162 778 518 22 214 437];\r\nassert(isequal(coolers(COST),1317))\r\n%%\r\nCOST = [573 952 497 860 78 228;...\r\n    566 767 809 627 339 710;...\r\n    824 752 633 181 581 149;...\r\n    127 139 689 574 476 659;...\r\n    301 350 640 164 806 634;...\r\n    3 152 730 907 531 230];\r\nassert(isequal(coolers(COST),1568))\r\n%%\r\nCOST = [183 958 897 179 998 879;...\r\n    167 26 190 747 5 747;...\r\n    150 972 661 50 543 118;...\r\n    203 298 942 72 862 510;...\r\n    955 526 976 490 910 169;...\r\n    16 863 108 850 846 832];\r\nassert(isequal(coolers(COST),539))\r\n%%\r\nCOST = [929 868 245 81 27 760;...\r\n    170 742 641 361 786 926;...\r\n    884 448 809 829 923 833;...\r\n    388 710 854 215 493 260;...\r\n    383 945 399 792 835 214;...\r\n    272 175 116 655 132 523];\r\nassert(isequal(coolers(COST),1564))\r\n%%\r\nCOST = [398 438 798 217 378 972;...\r\n    480 773 656 812 168 361;...\r\n    994 745 33 139 541 645;...\r\n    605 443 558 882 102 68;...\r\n    945 54 720 924 40 208;...\r\n    491 88 111 13 934 40];\r\nassert(isequal(coolers(COST),749))\r\n%%\r\nCOST = [470 581 9 642 470 879;...\r\n    151 541 825 106 220 189;...\r\n    992 706 768 269 923 760;...\r\n    428 6 998 764 321 32;...\r\n    956 783 228 806 858 643;...\r\n    725 927 920 105 260 567];\r\nassert(isequal(coolers(COST),1216))\r\n%%\r\nCOST = [377 187 35 595 562 603;...\r\n    213 486 489 499 634 474;...\r\n    793 839 972 568 931 357;...\r\n    146 142 113 427 978 476;...\r\n    490 733 744 77 94 672;...\r\n    13 692 639 291 662 960];\r\nassert(isequal(coolers(COST),1048))\r\n%%\r\nCOST = [90 52 454 629 707 46;...\r\n    798 505 738 133 536 886;...\r\n    591 769 510 619 194 840;...\r\n    913 283 383 384 690 119;...\r\n    102 226 906 992 51 411;...\r\n    294 332 966 287 185 121];\r\nassert(isequal(coolers(COST),1042))\r\n%%\r\nCOST = [573 666 232 754 549 464;...\r\n    950 974 53 622 461 590;...\r\n    257 623 902 395 646 188;...\r\n    990 64 794 360 514 612;...\r\n    350 374 374 89 815 52;...\r\n    209 167 833 342 98 576];\r\nassert(isequal(coolers(COST),934))\r\n%%\r\nCOST = [843 797 666 67 652 382;...\r\n    500 294 961 898 134 301;...\r\n    440 116 944 498 639 341;...\r\n    150 376 113 772 385 919;...\r\n    29 829 649 61 766 457;...\r\n    757 842 481 263 653 443];\r\nassert(isequal(coolers(COST),1166))\r\n%%\r\nCOST = [455 767 602 56 365 673;...\r\n    946 343 650 99 677 203;...\r\n    220 619 343 650 376 869;...\r\n    883 454 494 765 864 752;...\r\n    20 11 702 988 292 420;...\r\n    342 600 888 126 134 1];\r\nassert(isequal(coolers(COST),994))\r\n%%\r\nCOST = [150 436 24 66 150 132;...\r\n    274 904 575 924 351 887;...\r\n    873 926 47 535 336 675;...\r\n    602 506 423 367 785 836;...\r\n    322 628 468 364 487 657;...\r\n    285 720 23 152 465 984];\r\nassert(isequal(coolers(COST),958))\r\n%%\r\nCOST = [980 191 386 245 842 952;...\r\n    251 125 311 804 79 966;...\r\n    625 3 4 824 238 766;...\r\n    729 153 816 853 818 575;...\r\n    499 535 639 468 406 916;...\r\n    850 511 449 971 467 496];\r\nassert(isequal(coolers(COST),1655))\r\n%%\r\nCOST = [167 167 988 896 65 887;...\r\n    326 948 151 835 264 421;...\r\n    297 812 959 3 103 284;...\r\n    559 711 531 641 484 49;...\r\n    68 971 75 804 419 220;...\r\n    69 999 312 246 382 240];\r\nassert(isequal(coolers(COST),640))\r\n%%\r\nCOST = [30 653 667 689 433 469;...\r\n    703 321 848 321 905 546;...\r\n    8 104 763 532 631 180;...\r\n    611 536 808 874 984 635;...\r\n    409 165 633 55 586 963;...\r\n    249 884 711 501 841 535];\r\nassert(isequal(coolers(COST),2007))\r\n%%\r\nCOST = [480 679 683 689 62 13;...\r\n    794 566 947 148 220 217;...\r\n    93 479 100 778 83 12;...\r\n    881 321 512 400 951 643;...\r\n    4 602 111 899 17 517;...\r\n    512 914 546 308 115 246];\r\nassert(isequal(coolers(COST),648))\r\n%%\r\nCOST = [194 309 342 580 56 396;...\r\n    91 745 840 329 35 170;...\r\n    369 840 983 269 287 431;...\r\n    8 263 627 551 78 417;...\r\n    603 515 182 181 901 729;...\r\n    479 447 124 679 847 407];\r\nassert(isequal(coolers(COST),1129))\r\n%%\r\nCOST = [952 211 79 334 443 924;...\r\n    912 131 934 693 633 153;...\r\n    952 521 603 204 930 406;...\r\n    347 906 378 959 530 313;...\r\n    291 403 665 712 627 694;...\r\n    887 216 793 167 681 891];\r\nassert(isequal(coolers(COST),2052))\r\n%%\r\nCOST = [491 677 35 27 661 34;...\r\n    806 829 437 501 330 407;...\r\n    327 111 937 828 660 717;...\r\n    550 280 263 259 14 922;...\r\n    389 768 570 46 719 985;...\r\n    897 217 360 247 392 984];\r\nassert(isequal(coolers(COST),1266))\r\n%%\r\nCOST = [897 655 269 739 879 390;...\r\n    866 864 153 13 903 300;...\r\n    801 275 631 606 153 735;...\r\n    555 841 317 577 193 105;...\r\n    419 71 960 808 791 793;...\r\n    128 379 499 655 61 783];\r\nassert(isequal(coolers(COST),1254))\r\n%%\r\nCOST = [533 130 314 596 463 399;...\r\n    254 451 642 537 368 478;...\r\n    71 673 787 331 680 67;...\r\n    626 857 290 412 568 412;...\r\n    25 499 498 795 652 970;...\r\n    63 49 819 344 492 781];\r\nassert(isequal(coolers(COST),1580))\r\n%%\r\nCOST = [730 112 727 411 679 798;...\r\n    766 397 148 143 254 712;...\r\n    757 493 148 799 844 784;...\r\n    844 259 705 931 294 624;...\r\n    771 37 381 5 27 826;...\r\n    979 975 77 651 94 36];\r\nassert(isequal(coolers(COST),953))\r\n%%\r\nCOST = [406 27 672 377 507 436;...\r\n    250 156 53 114 329 158;...\r\n    481 834 735 965 754 601;...\r\n    881 195 500 433 837 938;...\r\n    281 830 944 85 254 108;...\r\n    600 339 290 717 535 900];\r\nassert(isequal(coolers(COST),931))\r\n%%\r\nCOST = [551 355 642 427 787 943;...\r\n    428 774 128 34 512 97;...\r\n    153 882 497 930 563 846;...\r\n    248 735 311 925 685 910;...\r\n    448 407 579 359 93 12;...\r\n    533 605 944 260 873 524];\r\nassert(isequal(coolers(COST),1430))\r\n%%\r\nCOST = [651 279 401 430 885 568;...\r\n    386 840 555 38 256 895;...\r\n    650 427 444 976 910 215;...\r\n    763 632 91 523 895 4;...\r\n    576 834 745 910 399 881;...\r\n    632 271 33 384 626 236];\r\nassert(isequal(coolers(COST),1575))\r\n%%\r\nCOST = [245 391 532 153 716 903;...\r\n    641 802 889 231 281 290;...\r\n    305 158 264 658 413 500;...\r\n    826 626 235 563 363 784;...\r\n    884 699 840 292 782 678;...\r\n    946 86 496 623 136 150];\r\nassert(isequal(coolers(COST),1276))\r\n%%\r\nCOST = [697 977 429 793 902 349;...\r\n    130 126 15 420 52 166;...\r\n    946 753 326 533 809 29;...\r\n    887 828 135 926 335 956;...\r\n    516 782 451 900 229 681;...\r\n    680 191 573 545 823 861];\r\nassert(isequal(coolers(COST),772))\r\n%%\r\nCOST = [940 301 652 887 695 895;...\r\n    681 74 170 115 207 842;...\r\n    918 768 532 443 555 131;...\r\n    257 85 634 660 880 190;...\r\n    886 729 15 295 558 154;...\r\n    921 448 471 951 753 29];\r\nassert(isequal(coolers(COST),1239))\r\n%%\r\nCOST = [10 496 746 686 237 463;...\r\n    597 259 338 268 196 926;...\r\n    610 733 585 970 706 216;...\r\n    919 117 469 184 181 2;...\r\n    734 747 88 300 523 907;...\r\n    302 810 829 412 297 681];\r\nassert(isequal(coolers(COST),1182))\r\n%%\r\nCOST = [515 394 842 779 399 396;...\r\n    523 8 49 728 671 399;...\r\n    103 546 317 651 441 752;...\r\n    997 510 784 665 133 523;...\r\n    359 247 973 939 440 491;...\r\n    626 46 587 536 548 89];\r\nassert(isequal(coolers(COST),1435))\r\n%%\r\nCOST = [251 93 71 159 652 1;...\r\n    448 954 301 63 499 641;...\r\n    638 163 814 702 285 8;...\r\n    710 971 77 87 831 107;...\r\n    993 598 355 617 819 107;...\r\n    933 241 133 174 939 368];\r\nassert(isequal(coolers(COST),771))\r\n%%\r\nCOST = [240 788 66 813 71 954;...\r\n    347 270 611 815 242 209;...\r\n    250 844 702 90 732 117;...\r\n    388 741 112 732 41 647;...\r\n    422 827 96 904 425 109;...\r\n    641 183 598 453 541 984];\r\nassert(isequal(coolers(COST),1343))\r\n%%\r\nCOST = [249 916 747 918 880 282;...\r\n    607 901 476 471 799 169;...\r\n    817 215 584 270 325 746;...\r\n    831 548 261 763 670 478;...\r\n    490 785 85 773 297 654;...\r\n    761 195 299 22 930 967];\r\nassert(isequal(coolers(COST),1567))\r\n%%\r\nCOST = [314 77 818 283 736 557;...\r\n    77 154 767 639 157 274;...\r\n    792 827 375 593 435 133;...\r\n    366 301 190 326 833 700;...\r\n    586 384 647 989 360 486;...\r\n    184 651 4 124 77 183];\r\nassert(isequal(coolers(COST),956))\r\n%%\r\nCOST = [102 248 381 378 851 968;...\r\n    202 438 749 973 257 477;...\r\n    135 670 157 606 286 995;...\r\n    324 548 59 339 780 491;...\r\n    951 610 340 928 702 504;...\r\n    533 864 818 899 493 769];\r\nassert(isequal(coolers(COST),1799))\r\n%%\r\nCOST = [389 799 340 268 52 543;...\r\n    454 221 273 177 628 809;...\r\n    133 858 171 432 30 794;...\r\n    759 905 665 476 137 502;...\r\n    566 293 536 786 695 277;...\r\n    649 726 830 131 516 120];\r\nassert(isequal(coolers(COST),1234))\r\n%%\r\nCOST = [887 183 567 504 84 962;...\r\n    971 32 378 261 74 467;...\r\n    943 725 822 733 770 787;...\r\n    639 145 305 163 818 423;...\r\n    91 636 320 922 741 944;...\r\n    75 790 785 223 759 2];\r\nassert(isequal(coolers(COST),1447))\r\n%%\r\nCOST = [982 666 329 847 415 7;...\r\n    571 685 928 902 662 767;...\r\n    347 793 757 596 784 22;...\r\n    558 349 289 69 248 394;...\r\n    300 251 607 219 555 253;...\r\n    160 346 767 870 230 205];\r\nassert(isequal(coolers(COST),1039))\r\n%%\r\nCOST = [663 975 947 135 372 260;...\r\n    915 120 967 806 227 134;...\r\n    7 519 68 525 447 420;...\r\n    747 822 438 945 267 507;...\r\n    800 638 321 989 460 325;...\r\n    908 954 135 410 433 685];\r\nassert(isequal(coolers(COST),1081))\r\n%%\r\nCOST = [444 502 305 970 394 701;...\r\n    436 556 767 690 459 110;...\r\n    794 631 268 718 209 7;...\r\n    816 98 40 560 758 598;...\r\n    753 246 297 534 547 660;...\r\n    790 616 557 876 358 581];\r\nassert(isequal(coolers(COST),1667))\r\n%%\r\nCOST = [910 165 870 241 503 143;...\r\n    637 281 788 9 568 381;...\r\n    526 260 970 672 189 397;...\r\n    260 548 181 905 325 577;...\r\n    52 542 931 573 717 20;...\r\n    732 789 46 156 553 578];\r\nassert(isequal(coolers(COST),1369))\r\n%%\r\nCOST = [933 303 817 55 540 946;...\r\n    107 460 451 638 938 377;...\r\n    733 49 807 425 661 68;...\r\n    971 386 791 906 395 182;...\r\n    609 362 283 418 259 576;...\r\n    720 288 69 155 848 186];\r\nassert(isequal(coolers(COST),1495))\r\n%%\r\nCOST = [292 28 747 842 871 890;...\r\n    462 659 747 511 212 66;...\r\n    347 159 174 166 837 510;...\r\n    319 803 118 715 860 621;...\r\n    460 409 175 908 524 734;...\r\n    236 328 628 219 478 230];\r\nassert(isequal(coolers(COST),1040))\r\n%%\r\nCOST = [22 327 315 114 208 74;...\r\n    139 138 160 701 785 595;...\r\n    770 385 153 180 527 862;...\r\n    970 563 137 804 572 449;...\r\n    387 634 710 514 423 653;...\r\n    994 542 465 549 722 304];\r\nassert(isequal(coolers(COST),716))\r\n%%\r\nCOST = [608 457 948 406 340 75;...\r\n    279 600 453 439 896 664;...\r\n    800 843 811 679 546 704;...\r\n    797 32 929 466 750 919;...\r\n    955 188 673 954 125 661;...\r\n    445 944 373 355 454 691];\r\nassert(isequal(coolers(COST),2010))\r\n%%\r\nCOST = [854 26 473 324 731 29;...\r\n    468 57 679 802 774 128;...\r\n    459 143 115 300 901 134;...\r\n    807 172 237 776 139 129;...\r\n    825 626 290 553 795 936;...\r\n    191 30 173 555 190 274];\r\nassert(isequal(coolers(COST),1199))\r\n%%\r\nCOST = [943 546 850 417 382 152;...\r\n    639 256 8 518 723 437;...\r\n    873 306 635 887 96 13;...\r\n    368 16 360 150 668 230;...\r\n    237 588 115 435 297 264;...\r\n    188 963 541 60 599 512];\r\nassert(isequal(coolers(COST),627))\r\n%%\r\nCOST = [216 475 261 618 402 95;...\r\n    347 826 590 145 15 376;...\r\n    748 304 480 717 75 546;...\r\n    414 822 199 402 592 112;...\r\n    56 566 240 463 447 905;...\r\n    391 55 781 708 927 634];\r\nassert(isequal(coolers(COST),940))\r\n%%\r\nCOST = [906 61 814 762 771 880;...\r\n    631 674 316 876 876 374;...\r\n    15 478 312 872 68 767;...\r\n    317 306 345 173 647 169;...\r\n    112 517 667 851 325 520;...\r\n    630 708 862 960 641 628];\r\nassert(isequal(coolers(COST),1043))\r\n%%\r\nCOST = [714 628 766 404 544 135;...\r\n    307 193 319 751 411 541;...\r\n    264 777 253 488 901 858;...\r\n    917 865 201 385 57 199;...\r\n    616 334 70 62 444 156;...\r\n    94 136 552 214 538 62];\r\nassert(isequal(coolers(COST),575))\r\n%%\r\nCOST = [662 683 487 77 915 603;...\r\n    19 138 680 445 92 466;...\r\n    292 630 705 166 994 299;...\r\n    974 858 461 399 97 134;...\r\n    765 900 365 921 314 296;...\r\n    244 349 281 512 786 167];\r\nassert(isequal(coolers(COST),1112))\r\n%%\r\nCOST = [318 40 863 414 595 658;...\r\n    110 617 277 415 310 685;...\r\n    833 670 532 984 902 474;...\r\n    972 38 523 58 94 142;...\r\n    219 4 568 397 320 951;...\r\n    707 143 334 792 887 883];\r\nassert(isequal(coolers(COST),1040))\r\n%%\r\nCOST = [438 952 914 477 226 187;...\r\n    835 2 534 251 568 647;...\r\n    326 296 805 308 999 129;...\r\n    368 49 563 967 132 82;...\r\n    795 443 751 209 955 660;...\r\n    100 790 10 521 124 28];\r\nassert(isequal(coolers(COST),914))\r\n%%\r\nCOST = [986 693 226 415 41 625;...\r\n    540 603 797 499 583 296;...\r\n    374 776 997 950 565 75;...\r\n    707 592 282 954 356 294;...\r\n    948 377 711 733 881 235;...\r\n    383 851 665 385 625 346];\r\nassert(isequal(coolers(COST),1955))\r\n%%\r\nCOST = [849 636 448 593 844 465;...\r\n    161 844 327 69 424 31;...\r\n    158 783 280 206 545 435;...\r\n    509 265 932 724 528 558;...\r\n    604 315 400 576 186 639;...\r\n    162 184 380 201 82 35];\r\nassert(isequal(coolers(COST),1044))\r\n%%\r\nCOST = [710 855 367 351 91 968;...\r\n    170 385 350 193 258 434;...\r\n    594 400 631 920 428 785;...\r\n    609 326 665 289 578 526;...\r\n    773 556 993 551 900 332;...\r\n    57 296 945 920 219 432];\r\nassert(isequal(coolers(COST),1623))\r\n%%\r\nCOST = [718 654 235 805 97 557;...\r\n    917 41 201 104 600 840;...\r\n    891 505 381 730 234 205;...\r\n    135 895 595 649 33 622;...\r\n    120 386 269 475 580 175;...\r\n    894 293 623 933 843 290];\r\nassert(isequal(coolers(COST),1365))\r\n%%\r\nCOST = [19 283 206 904 234 347;...\r\n    702 245 435 541 247 298;...\r\n    953 287 143 818 171 405;...\r\n    750 964 376 709 236 303;...\r\n    757 231 794 44 276 758;...\r\n    543 538 813 146 952 360];\r\nassert(isequal(coolers(COST),1417))\r\n%%\r\nCOST = [125 458 201 22 719 780;...\r\n    618 78 960 483 450 568;...\r\n    356 905 666 808 660 77;...\r\n    363 282 542 737 754 252;...\r\n    69 614 869 573 805 134;...\r\n    868 662 558 9 30 565];\r\nassert(isequal(coolers(COST),953))\r\n%%\r\nCOST = [541 43 122 494 863 421;...\r\n    69 528 592 856 685 488;...\r\n    989 257 360 725 635 461;...\r\n    252 409 720 200 142 516;...\r\n    316 948 524 158 80 272;...\r\n    301 920 261 371 877 232];\r\nassert(isequal(coolers(COST),1198))\r\n%%\r\nCOST = [900 895 226 336 740 434;...\r\n    909 88 105 620 889 290;...\r\n    604 540 10 993 860 632;...\r\n    366 429 60 649 598 296;...\r\n    599 618 323 540 655 623;...\r\n    669 559 780 233 916 48];\r\nassert(isequal(coolers(COST),2054))\r\n%%\r\nCOST = [995 67 543 281 171 63;...\r\n    207 928 781 599 372 407;...\r\n    608 88 522 37 40 464;...\r\n    348 333 932 64 710 203;...\r\n    718 527 148 323 642 870;...\r\n    28 247 417 99 175 598];\r\nassert(isequal(coolers(COST),730))\r\n%%\r\nCOST = [24 867 571 301 445 250;...\r\n    900 616 326 522 983 956;...\r\n    453 27 451 562 579 143;...\r\n    59 323 578 242 235 513;...\r\n    107 464 75 913 811 972;...\r\n    999 100 58 826 452 649];\r\nassert(isequal(coolers(COST),902))\r\n%%\r\nCOST = [615 424 874 119 114 462;...\r\n    470 274 301 99 491 864;...\r\n    578 445 401 891 600 263;...\r\n    912 628 518 34 91 824;...\r\n    377 535 62 840 979 329;...\r\n    229 386 232 508 654 942];\r\nassert(isequal(coolers(COST),1065))\r\n%%\r\nCOST = [245 314 524 145 800 565;...\r\n    958 58 893 245 209 218;...\r\n    511 45 406 379 897 858;...\r\n    565 813 605 271 746 862;...\r\n    994 413 95 216 537 314;...\r\n    771 385 336 634 970 327];\r\nassert(isequal(coolers(COST),1381))\r\n%%\r\nCOST = [841 334 286 610 505 816;...\r\n    493 367 657 384 8 910;...\r\n    52 795 232 31 920 778;...\r\n    779 39 622 858 411 758;...\r\n    427 727 76 604 733 406;...\r\n    280 873 967 848 152 702];\r\nassert(isequal(coolers(COST),1140))\r\n%%\r\nCOST = [566 563 904 539 781 176;...\r\n    585 547 605 738 537 417;...\r\n    345 551 927 182 770 740;...\r\n    705 695 117 427 639 893;...\r\n    161 928 341 99 894 26;...\r\n    2 945 37 304 61 138];\r\nassert(isequal(coolers(COST),1153))\r\n%%\r\nCOST = [425 619 192 805 191 892;...\r\n    765 7 715 860 504 674;...\r\n    525 741 178 567 51 686;...\r\n    755 992 987 755 57 696;...\r\n    170 129 17 520 336 800;...\r\n    673 361 40 586 631 661];\r\nassert(isequal(coolers(COST),1579))\r\n%%\r\nCOST = [520 255 928 227 995 523;...\r\n    332 846 588 2 984 274;...\r\n    935 539 102 894 965 719;...\r\n    247 911 367 454 667 779;...\r\n    512 351 276 579 727 82;...\r\n    741 936 267 316 335 222];\r\nassert(isequal(coolers(COST),1598))\r\n%%\r\nCOST = [204 470 675 379 889 587;...\r\n    625 379 552 618 563 969;...\r\n    726 341 52 563 195 582;...\r\n    835 64 308 831 222 100;...\r\n    19 762 966 958 706 167;...\r\n    203 403 932 76 597 103];\r\nassert(isequal(coolers(COST),993))\r\n%%\r\nCOST = [147 800 210 627 782 774;...\r\n    672 400 481 412 936 748;...\r\n    640 756 113 639 740 319;...\r\n    373 296 133 857 254 511;...\r\n    163 641 65 764 720 774;...\r\n    390 886 80 977 694 573];\r\nassert(isequal(coolers(COST),1784))\r\n%%\r\nCOST = [954 463 111 359 365 588;...\r\n    172 130 200 135 400 778;...\r\n    908 550 163 999 927 658;...\r\n    753 970 37 514 496 529;...\r\n    287 443 273 388 610 826;...\r\n    628 591 231 250 5 963];\r\nassert(isequal(coolers(COST),1501))\r\n%%\r\nCOST = [314 306 715 905 664 101;...\r\n    798 19 460 387 603 287;...\r\n    286 163 920 604 657 355;...\r\n    15 444 989 561 310 536;...\r\n    95 767 933 846 332 991;...\r\n    329 682 462 285 189 29];\r\nassert(isequal(coolers(COST),1729))\r\n%%\r\nCOST = [710 876 77 818 359 455;...\r\n    906 865 377 174 364 30;...\r\n    866 356 150 677 268 638;...\r\n    120 632 35 876 338 60;...\r\n    956 865 783 758 87 170;...\r\n    441 21 328 230 452 685];\r\nassert(isequal(coolers(COST),1098))\r\n%%\r\nCOST = [555 461 15 279 896 625;...\r\n    7 371 5 645 888 207;...\r\n    289 825 167 288 394 110;...\r\n    377 538 366 322 676 566;...\r\n    147 818 719 156 253 275;...\r\n    75 461 160 388 950 72];\r\nassert(isequal(coolers(COST),1175))\r\n%%\r\nCOST = [159 896 447 617 948 551;...\r\n    50 608 812 304 334 161;...\r\n    681 15 145 90 390 118;...\r\n    782 345 975 522 151 399;...\r\n    808 534 834 826 334 832;...\r\n    266 628 341 764 554 186];\r\nassert(isequal(coolers(COST),569))\r\n%%\r\nCOST = [501 491 579 185 613 662;...\r\n    127 887 776 198 738 896;...\r\n    865 906 662 862 304 275;...\r\n    767 499 470 126 43 998;...\r\n    565 530 220 646 836 835;...\r\n    390 910 603 438 370 792];\r\nassert(isequal(coolers(COST),1584))\r\n%%\r\nCOST = [657 988 206 794 242 185;...\r\n    544 789 495 682 210 88;...\r\n    387 853 32 651 273 309;...\r\n    823 486 828 238 776 231;...\r\n    596 874 265 478 332 910;...\r\n    782 334 678 937 604 937];\r\nassert(isequal(coolers(COST),1504))\r\n%%\r\nCOST = [32 626 369 811 16 974;...\r\n    594 256 338 724 95 373;...\r\n    44 905 619 675 515 321;...\r\n    425 768 87 914 953 784;...\r\n    522 563 376 821 844 213;...\r\n    841 898 188 549 936 960];\r\nassert(isequal(coolers(COST),1717))\r\n%%\r\nCOST = [931 594 600 844 914 151;...\r\n    366 98 227 771 577 947;...\r\n    345 560 714 510 288 651;...\r\n    693 44 725 707 267 983;...\r\n    717 758 345 792 891 194;...\r\n    801 660 33 331 367 829];\r\nassert(isequal(coolers(COST),1626))\r\n%%\r\nCOST = [494 60 648 497 429 28;...\r\n    591 516 624 763 42 906;...\r\n    45 54 954 180 226 472;...\r\n    565 844 177 692 667 911;...\r\n    634 595 475 915 872 328;...\r\n    499 692 843 163 345 692];\r\nassert(isequal(coolers(COST),526))\r\n%%\r\nCOST = [18 334 151 424 616 681;...\r\n    513 633 839 529 102 394;...\r\n    332 416 727 276 670 392;...\r\n    337 577 109 828 348 207;...\r\n    954 960 162 793 670 725;...\r\n    751 616 298 274 296 820];\r\nassert(isequal(coolers(COST),1421))\r\n%%\r\nCOST = [927 854 101 228 459 109;...\r\n    515 430 413 358 952 652;...\r\n    194 926 925 925 133 147;...\r\n    603 374 56 503 71 694;...\r\n    199 699 385 804 707 626;...\r\n    411 589 241 351 932 44];\r\nassert(isequal(coolers(COST),1345))\r\n%%\r\nCOST = [798 582 93 769 788 680;...\r\n    987 602 334 283 125 10;...\r\n    437 253 652 650 158 129;...\r\n    345 655 504 923 415 764;...\r\n    49 61 531 331 688 842;...\r\n    226 941 380 814 658 747];\r\nassert(isequal(coolers(COST),1350))\r\n%%\r\nCOST = [945 618 338 215 587 443;...\r\n    920 559 552 293 939 692;...\r\n    224 731 744 450 619 760;...\r\n    510 64 413 241 251 400;...\r\n    788 493 508 264 103 568;...\r\n    523 230 129 892 547 206];\r\nassert(isequal(coolers(COST),1251))\r\n%%\r\nCOST = [944 708 393 379 767 434;...\r\n    513 657 243 634 337 103;...\r\n    277 779 282 32 626 237;...\r\n    230 581 905 921 327 972;...\r\n    953 504 703 470 312 699;...\r\n    690 879 854 520 647 660];\r\nassert(isequal(coolers(COST),1565))\r\n%%\r\nCOST = [327 450 172 573 377 40;...\r\n    20 769 722 832 394 565;...\r\n    571 628 90 348 429 50;...\r\n    37 315 918 780 424 873;...\r\n    265 293 430 709 219 861;...\r\n    191 79 80 591 497 339];\r\nassert(isequal(coolers(COST),1224))\r\n%%\r\nCOST = [975 347 346 214 761 636;...\r\n    955 234 903 936 580 803;...\r\n    989 756 13 970 622 670;...\r\n    158 226 133 376 490 472;...\r\n    3 449 389 985 221 945;...\r\n    249 260 841 123 145 592];\r\nassert(isequal(coolers(COST),1311))\r\n%%\r\nCOST = [227 932 883 581 327 592;...\r\n    684 697 780 627 288 1;...\r\n    321 96 19 112 497 904;...\r\n    749 246 771 214 182 683;...\r\n    999 935 686 37 934 74;...\r\n    270 480 868 445 941 997];\r\nassert(isequal(coolers(COST),804))\r\n%%\r\nCOST = [315 176 835 189 254 788;...\r\n    810 588 997 578 287 438;...\r\n    462 155 973 629 126 551;...\r\n    588 446 746 365 529 987;...\r\n    478 538 200 637 821 690;...\r\n    553 462 37 892 300 971];\r\nassert(isequal(coolers(COST),2037))\r\n%%\r\nCOST = [96 320 833 203 939 1;...\r\n    899 796 571 493 975 484;...\r\n    59 302 71 730 608 148;...\r\n    124 608 267 955 958 315;...\r\n    631 462 171 763 331 172;...\r\n    371 293 561 81 902 593];\r\nassert(isequal(coolers(COST),1341))\r\n%%\r\nCOST = [658 16 262 188 656 56;...\r\n    349 974 894 744 782 820;...\r\n    54 735 973 719 863 107;...\r\n    48 753 995 189 786 7;...\r\n    56 34 347 434 434 276;...\r\n    72 118 293 46 348 943];\r\nassert(isequal(coolers(COST),862))\r\n%%\r\nCOST = [675 962 293 837 855 788;...\r\n    386 823 439 42 174 175;...\r\n    857 11 399 424 536 720;...\r\n    675 142 138 76 295 233;...\r\n    609 483 953 314 903 208;...\r\n    440 581 361 946 82 217];\r\nassert(isequal(coolers(COST),1114))\r\n%%\r\nCOST = [977 461 237 907 842 269;...\r\n    382 4 832 993 684 981;...\r\n    636 465 438 391 172 313;...\r\n    47 825 508 827 238 572;...\r\n    233 872 186 955 435 612;...\r\n    875 302 152 894 26 902];\r\nassert(isequal(coolers(COST),1700))\r\n%%\r\nCOST = [397 297 634 847 995 269;...\r\n    693 572 965 41 429 758;...\r\n    205 317 201 330 268 610;...\r\n    63 810 599 710 473 967;...\r\n    623 366 84 861 161 774;...\r\n    689 699 545 501 159 573];\r\nassert(isequal(coolers(COST),1320))\r\n%%\r\nCOST = [451 355 996 87 199 597;...\r\n    288 581 84 520 657 323;...\r\n    753 299 469 553 699 831;...\r\n    95 714 94 686 460 123;...\r\n    107 361 726 300 158 252;...\r\n    735 719 913 602 422 938];\r\nassert(isequal(coolers(COST),1069))\r\n\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":255320,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2020-04-03T23:22:52.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-04-01T22:04:29.000Z","updated_at":"2026-02-26T16:11:43.000Z","published_at":"2020-04-01T22:55:22.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn a certain chemical plant, 6 new pieces of cooling equipment (coolers) are to be installed in a vacant space. This vacant space was divided into a grid of 6 cells by 6 cells. Your task is to assign the 6 coolers to 6 cells in this grid with the following requirements:\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThere must be one cooler for every column in the grid.\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf you decide to install a cooler at row R, column C, then the cooler at column C+1 must be installed either on row R-1, R, or R+1 only. This is done to ease the connection of coolers by piping.\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe total installation cost for the 6 coolers must be minimum.\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 this problem, you are given a cost matrix (COST) in relation to the third requirement above. COST is a 6 x 6 matrix where the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003er,c\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e-th element is the cost of assigning any cooler to row\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\u003er\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, column\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\u003ec\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (All the coolers are identical). Write a function that accepts the matrix COST, and output the value of the minimum cost of installation. You are ensured that all elements of COST are integers in the range [1,1000].\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 the sample test case below, the optimal placement is at the following rows: 4,3,3,2,2,2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[\u003e\u003e COST = [695   766   710   119   752   548;\\n           318   796   755   499   256   139;\\n           951   187   277   960   506   150;\\n            35   490   680   341   700   258;\\n           439   446   656   586   891   841;\\n           382   647   163   224   960   255];\\n\u003e\u003e coolers(COST)\\nans = \\n      1393]]\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\u003eMeanwhile, the optimal placement for the case below is at rows: 5,6,5,6,5,6\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[\u003e\u003e COST = [815   617   918    76   569   312;\\n           244   474   286    54   470   529;\\n           930   352   758   531   455   988;\\n           350   831   754   780    12   602;\\n           197   586   381   935   163   263;\\n           252   550   568   130   795   100];\\n\u003e\u003e coolers(COST)\\nans = \\n      1521]]\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":1885,"title":"Minimum Sum thru a Lower Triangle","description":"This Challenge is to find the minimum cumulative sum that traverses from row-1 thru row-N via vertical/diagonal adjacent elements of adjacent rows.\r\n\r\nThe input is a series of values of length n*(n+1)/2.\r\n\r\n*Input:* S  [Series that can be converted into a lower triangle]\r\n\r\n*Output:* MinSum  [Minimum cost path from top to bottom]\r\n\r\n*Example:*\r\n\r\n[5 7 6 3 2 5] becomes\r\n\r\n  5 0 0\r\n  7 6 0\r\n  3 2 5\r\n\r\nCreates a MinSum of 13 [5+6+2].  The 5 can only see 6, 3 sees 7 and 6, while 2 sees 7 6 0.\r\n ","description_html":"\u003cp\u003eThis Challenge is to find the minimum cumulative sum that traverses from row-1 thru row-N via vertical/diagonal adjacent elements of adjacent rows.\u003c/p\u003e\u003cp\u003eThe input is a series of values of length n*(n+1)/2.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e S  [Series that can be converted into a lower triangle]\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e MinSum  [Minimum cost path from top to bottom]\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e[5 7 6 3 2 5] becomes\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e5 0 0\r\n7 6 0\r\n3 2 5\r\n\u003c/pre\u003e\u003cp\u003eCreates a MinSum of 13 [5+6+2].  The 5 can only see 6, 3 sees 7 and 6, while 2 sees 7 6 0.\u003c/p\u003e","function_template":"function MinSum=Find_MinSum(s)\r\n MinSum=0;\r\nend","test_suite":"%%\r\ns=[5 7 6 3 2 5];\r\nMinSum=Find_MinSum(s);\r\nexp=13;\r\nassert(exp==MinSum)\r\n%%\r\ns=[7 9 8 3 2 6 7 1 5   5 9   4   8   2   4 6   3   2   9   7   5 7   2   4   8   5   1   9 4   2   9   3   8   5   2   8  8   2   4   8   5   9   2   7   3];\r\nMinSum=Find_MinSum(s);\r\nexp=30;\r\nassert(exp==MinSum)\r\n%%\r\ns=[21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1];\r\nMinSum=Find_MinSum(s);\r\nexp=76;\r\nassert(exp==MinSum)\r\n%%\r\ns=1:28;\r\nMinSum=Find_MinSum(s);\r\nexp=63;\r\nassert(exp==MinSum)\r\n%%\r\ns=[82 91 13 92 64 10 28 55 96 97 16 98 96 49 81 15 43 92 80 96 66 4 85 94 68 76 75 40 66 18 71 4 28 5 10 83 ];\r\nMinSum=Find_MinSum(s);\r\nexp=213;\r\nassert(exp==MinSum)\r\n%%\r\ns=[348 159 476 18 220 191 383 398 94 245 223 324 355 378 139 340 328 82 60 250 480 171 293 112 376 128 253 350 446 480 274 70 75 129 421 128 ];\r\nMinSum=Find_MinSum(s);\r\nexp=1409;\r\nassert(exp==MinSum)\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-21T02:45:50.000Z","updated_at":"2025-12-04T12:10:46.000Z","published_at":"2013-09-21T03:00:18.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\u003eThis Challenge is to find the minimum cumulative sum that traverses from row-1 thru row-N via vertical/diagonal adjacent elements of adjacent rows.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe input is a series of values of length n*(n+1)/2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e S [Series that can be converted into a lower triangle]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e MinSum [Minimum cost path from top to bottom]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e[5 7 6 3 2 5] becomes\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[5 0 0\\n7 6 0\\n3 2 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\u003eCreates a MinSum of 13 [5+6+2]. The 5 can only see 6, 3 sees 7 and 6, while 2 sees 7 6 0.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":48990,"title":"Solve the recursion","description":"Solve the recursion: f(n)=f(n-1)+1 + f(n-2)+2.\r\nf(1)=4;\r\nf(2)=8;","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: 81px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 40.5px; transform-origin: 407px 40.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: 141px 8px; transform-origin: 141px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSolve the recursion: f(n)=f(n-1)+1 + f(n-2)+2.\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: 21px 8px; transform-origin: 21px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ef(1)=4;\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: 21px 8px; transform-origin: 21px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003ef(2)=8;\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = rec(n)\r\n  y = n;\r\nend","test_suite":"%%\r\nfiletext = fileread('rec.m');\r\nillegal = contains(filetext, 'switch') || contains(filetext, 'else') \r\nassert(~illegal)\r\n%%\r\nn = 1;\r\ny_correct = 4;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 5;\r\ny_correct = 44;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 13;\r\ny_correct = 2204;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 20;\r\ny_correct = 64076;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 34;\r\ny_correct = 54018518;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 37;\r\ny_correct = 228826124;\r\nassert(isequal(rec(n),y_correct))\r\n%%\r\nn = 40;\r\ny_correct = 969323026;\r\nassert(isequal(rec(n),y_correct))\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":698530,"edited_by":223089,"edited_at":"2022-12-12T06:11:46.000Z","deleted_by":null,"deleted_at":null,"solvers_count":38,"test_suite_updated_at":"2022-12-12T06:11:46.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-12-22T17:50:06.000Z","updated_at":"2026-03-23T17:38:43.000Z","published_at":"2020-12-31T01:21:21.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\u003eSolve the recursion: f(n)=f(n-1)+1 + f(n-2)+2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ef(1)=4;\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\u003ef(2)=8;\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":56030,"title":"Pay up","description":"You live in a world where arbitrary denominations of currency exist. You owe your friend a sum of money denoted by s. However, it is possible that neither of you carry exact change for this deal. You and your friend happen to carry currency in only certain specific denominations. You both take all the money you have and lay them out on a table and identify every bill of currency you have collectively. The list L contains the values of each of the bills such that the values corresponding to your bills come with a positive sign and that of your friend negative. The function pay takes as arguments L and s and returns boolean true if the exchange is possible and false otherwise. Complete the definition of pay.\r\nConstraints:\r\n(1) s ∈ Z\r\n(2) L ∈ T ∣ T = { { x₁,x₂,...,xₙ } ∣ xᵢ ∈ Z, i ∈ N } ∩ { ∅ }","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: 216px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 108px; transform-origin: 407px 108px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 126px; 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 63px; text-align: left; transform-origin: 384px 63px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eYou live in a world where arbitrary denominations of currency exist. You owe your friend a sum of money denoted by \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003es. \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eHowever, it is possible that neither of you carry exact change for this deal. You and your friend happen to carry currency in only certain specific denominations. You both take all the money you have and lay them out on a table and identify every bill of currency you have collectively. The list \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eL \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003econtains the values of each of the bills such that the values corresponding to your bills come with a positive sign and that of your friend negative. The function \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003epay\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e takes as arguments \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eL \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eand \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003es\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e and returns boolean \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003etrue \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eif the exchange is possible and \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003efalse \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eotherwise. Complete the definition of \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003epay\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e.\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eConstraints:\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e(1)\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003e s\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: 0px 0px; transform-origin: 0px 0px; \"\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eZ\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e(2) \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003eL\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e ∈ T ∣ T = { { x₁,x₂,...,xₙ } ∣ xᵢ ∈ \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eZ,\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e i ∈ \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-style: italic; \"\u003eN \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e} ∩ { ∅ }\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = pay(L,s)\r\n  y = 0;\r\nend","test_suite":"%%\r\nL = [967, 605, -249, -255, 894, -199];\r\ns = -504;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-22];\r\ns = -467;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-637, -402];\r\ns = 0;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [473, -498, -16, -288];\r\ns = 169;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-384, -715, 651, 874, -13];\r\ns = 759;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [186, -745];\r\ns = -166;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-186, -266, 914, 122, -289, 912];\r\ns = 359;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [437, -832, 572, -361, 877, 548];\r\ns = 548;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-803, 95, 503];\r\ns = 503;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [62, -867, -222];\r\ns = -805;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [394];\r\ns = -333;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-836, -353];\r\ns = 519;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [740, 952, -150];\r\ns = -765;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [137, -973, 620];\r\ns = 757;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [483, 772, 458];\r\ns = 109;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [212, 869, 10, -468, 523];\r\ns = -905;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-851];\r\ns = 822;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-667, -308, 549, 792, -128];\r\ns = 674;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = -8;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [206, -246, -545, -402, 18, 150];\r\ns = -929;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-104, -710, -565, 448, -717];\r\ns = -669;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [672, -991, -467, 527, -111, -14];\r\ns = -65;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [384];\r\ns = -371;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-436, -662, -530, 279, -469, -415];\r\ns = 257;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [844, 288];\r\ns = 956;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-709, 570, 896, 293, -925];\r\ns = 403;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [11, -626, -258, -537, -961, -341];\r\ns = -864;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [710, -256, 63];\r\ns = -136;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-336, -238, 127, 193, 437, -220];\r\ns = 56;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-446, 274];\r\ns = -172;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [648, 931, 234, -218];\r\ns = 737;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [447, 109, 157, -252, -512, 134];\r\ns = -208;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-581, -916];\r\ns = -133;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [801, 621, -437, 580];\r\ns = -437;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [617, -424, -690, 9, -783];\r\ns = -64;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [864, -98, 179, -443, 505, 515];\r\ns = 922;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-48];\r\ns = -469;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [581, 372, -712, -154, 126, 80];\r\ns = 787;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [655, -167, 357, 289, -891];\r\ns = -701;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [941, -67, -764, -202, -919, -210];\r\ns = -809;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-361, -905, 437, 955, -40, 907];\r\ns = 915;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-506, -724];\r\ns = 157;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-432, -652, 860, -115, 579];\r\ns = -497;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 735;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-141, 334, -315, -866];\r\ns = -141;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [874, -980, -112];\r\ns = 246;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [768, 962, 245];\r\ns = 245;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [207, -281, 543, 462, -440, 995];\r\ns = 462;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 397;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [438, -548, -295, -270, 721, 750];\r\ns = -405;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [583, -617, -567];\r\ns = 307;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-590];\r\ns = -343;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-582];\r\ns = -526;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-634];\r\ns = -470;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-341, -761, -641];\r\ns = -341;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [929, -448, -53, 951, -932];\r\ns = -53;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [23, -338, -653, 107, -533, 802];\r\ns = 61;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-297, -331, -150, 481, -112, 895];\r\ns = -262;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-992, 401, -467];\r\ns = 339;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [592, 611, 660];\r\ns = 900;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-135, -544, -857];\r\ns = -523;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-259, -466, 976, 635, -607];\r\ns = 369;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-876, -852, -430, 370, -489, 468];\r\ns = -971;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-804, 96, -655, -253, 462];\r\ns = 209;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-418, 193, 353, 810, -780];\r\ns = 546;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-383, 116, 814, -359, 106];\r\ns = -359;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = -327;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [317, -825, 299, 674];\r\ns = 991;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 977;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [873, -44, 505, 352, -794, -609];\r\ns = 0;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 300;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-60, -817, 431, 411, -229, 625];\r\ns = -386;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-830];\r\ns = 786;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-341, 711, -155, 531, -317];\r\ns = -155;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = -429;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 596;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [121, 915, 610, -114, -957, -594];\r\ns = 938;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [633, -465, -282, 413, -58];\r\ns = -110;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-946, -349, 290, 228, 565, 399];\r\ns = -331;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-104, 91, 452];\r\ns = 167;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [374, -547, -796, 603, 18];\r\ns = 448;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-503, 440, 604, 897, -390, 597];\r\ns = -33;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-762, -748, -55, -542, -927, -339];\r\ns = -799;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-129, -575, 221, 926, 927, -44];\r\ns = 798;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-669, 999, 316, 594, -40, 625];\r\ns = -75;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-857];\r\ns = 824;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [810, 680, 180];\r\ns = 680;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-554, 478];\r\ns = -926;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-562, 736, 114, 855];\r\ns = -562;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [478, -853, -694, -868, 666];\r\ns = -881;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-790, -131, -419, -669, 956];\r\ns = -673;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-19, 702, -57, -771];\r\ns = 728;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-188];\r\ns = 0;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = -469;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-491, 617, 718, 503, 452];\r\ns = -341;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [290, 697, -644, 345, 230, -494];\r\ns = -494;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [];\r\ns = 0;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [289];\r\ns = 650;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [-426, -610, -85, 191, -544, -385];\r\ns = 618;\r\ny_correct = 0;\r\nassert(isequal(pay(L,s),y_correct))\r\n%%\r\nL = [833, 403, -426];\r\ns = -426;\r\ny_correct = 1;\r\nassert(isequal(pay(L,s),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":3,"created_by":2242415,"edited_by":2242415,"edited_at":"2022-09-29T09:49:41.000Z","deleted_by":null,"deleted_at":null,"solvers_count":5,"test_suite_updated_at":"2022-09-29T08:37:54.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-09-23T11:47:19.000Z","updated_at":"2022-09-29T09:49:41.000Z","published_at":"2022-09-23T11:50:25.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\u003eYou live in a world where arbitrary denominations of currency exist. You owe your friend a sum of money denoted by \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es. \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eHowever, it is possible that neither of you carry exact change for this deal. You and your friend happen to carry currency in only certain specific denominations. You both take all the money you have and lay them out on a table and identify every bill of currency you have collectively. The list \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eL \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003econtains the values of each of the bills such that the values corresponding to your bills come with a positive sign and that of your friend negative. The function \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003epay\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e takes as arguments \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eL \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eand \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003es\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e and returns boolean \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003etrue \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eif the exchange is possible and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003efalse \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003eotherwise. Complete the definition of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003epay\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eConstraints:\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\u003e(1)\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003e s\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\u003eZ\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\u003e(2) \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eL\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e ∈ T ∣ T = { { x₁,x₂,...,xₙ } ∣ xᵢ ∈ \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eZ,\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e i ∈ \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eN \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e} ∩ { ∅ }\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":55290,"title":"Cut the rod","description":"A rod of length n can be cut in different sizes. Different price is associated with different length of cuts. \r\nlength, len= [1, 2, 3, 4, 5,  6,   7,  8]\r\nprice, p     = [1, 5, 8, 9,10,17,17,20]\r\nHere, if you cut a piece of length 5, the price for that piece is 10. For length of 8, the price is 20.\r\nSay, you have to obtain a rod of length x. By cutting the rod in which way will give you the maximum price.\r\n\r\nFor instance, say x=4. you can cut the rod in pieces like (1,3)/(3,1), (2,2), (1,1,1,1), (1,1,2)/(1,2,1)/... or (4).\r\nThe maximum revenue that you can get here is when you cut the rod in (2,2) pieces to get length x =\u003e 5+5=10. \r\nFor (1,3)=\u003e9; (1,1,1,1)=\u003e 4; (1,1,2)=\u003e7, (4)=\u003e9. \r\n\r\nIn this problem, you have to return the maximum reveneue you can obtain by cutting the rod of size x.","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: 322.875px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 161.438px; transform-origin: 407px 161.438px; 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=\"\"\u003eA rod of length n can be cut in different sizes. Different price is associated with different length of cuts. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cul style=\"block-size: 40.875px; 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 20.4375px; transform-origin: 391px 20.4375px; margin-top: 10px; margin-bottom: 20px; \"\u003e\u003cli style=\"block-size: 20.4375px; 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.2125px; text-align: left; transform-origin: 363px 10.2188px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003elength, len= [1, 2, 3, 4, 5,  6,   7,  8]\u003c/span\u003e\u003c/span\u003e\u003c/li\u003e\u003cli style=\"block-size: 20.4375px; 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.2125px; text-align: left; transform-origin: 363px 10.2188px; white-space: pre-wrap; margin-left: 56px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-inline-start: 0px; margin-left: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eprice, p     = [1, 5, 8, 9,10,17,17,20]\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eHere, if you cut a piece of length 5, the price for that piece is 10. For length of 8, the price is 20.\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eSay, you have to obtain a rod of length x. By cutting the rod in which way will give you the maximum price.\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor instance, say x=4. you can cut the rod in pieces like (1,3)/(3,1), (2,2), (1,1,1,1), (1,1,2)/(1,2,1)/... or (4).\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eThe maximum revenue that you can get here is when you cut the rod in (2,2) pieces to get length x =\u0026gt; 5+5=10. \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eFor (1,3)=\u0026gt;9; (1,1,1,1)=\u0026gt; 4; (1,1,2)=\u0026gt;7, (4)=\u0026gt;9. \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eIn this problem, you have to return the maximum reveneue you can obtain by cutting the rod of size x.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = rod_cut(x,p)\r\n  y = x;\r\nend","test_suite":"%%\r\np=[1,5,8,9,10,17,17,20];\r\nx=4;\r\ny_correct = 10;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[1,5,8,9,10,17,17,20];\r\nx=8;\r\ny_correct = 22;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[1,5,8,9,10,17,17,20];\r\nx=7;\r\ny_correct = 18;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[1,5,8,9,10,17,17,20];\r\nx=6;\r\ny_correct = 17;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[10,5,3,18];\r\nx=4;\r\ny_correct = 40;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n\r\n%%\r\np=[10,5,3,18];\r\nx=2;\r\ny_correct = 20;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n\r\n%%\r\np=[10,5,36,18,36];\r\nx=4;\r\ny_correct = 46;\r\nassert(isequal(rod_cut(x,p),y_correct))\r\n\r\n%%\r\np=[10,5,36,18,36];\r\nx=5;\r\ny_correct = 56;\r\nassert(isequal(rod_cut(x,p),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":0,"created_by":363598,"edited_by":363598,"edited_at":"2022-08-13T23:35:18.000Z","deleted_by":null,"deleted_at":null,"solvers_count":12,"test_suite_updated_at":"2022-08-13T23:35:18.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-08-13T23:28:51.000Z","updated_at":"2026-01-06T08:34:18.000Z","published_at":"2022-08-13T23:35:18.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\u003eA rod of length n can be cut in different sizes. Different price is associated with different length of cuts. \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\u003elength, len= [1, 2, 3, 4, 5,  6,   7,  8]\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\u003eprice, p     = [1, 5, 8, 9,10,17,17,20]\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\u003eHere, if you cut a piece of length 5, the price for that piece is 10. For length of 8, the price is 20.\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\u003eSay, you have to obtain a rod of length x. By cutting the rod in which way will give you the maximum price.\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\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\u003eFor instance, say x=4. you can cut the rod in pieces like (1,3)/(3,1), (2,2), (1,1,1,1), (1,1,2)/(1,2,1)/... or (4).\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 maximum revenue that you can get here is when you cut the rod in (2,2) pieces to get length x =\u0026gt; 5+5=10. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor (1,3)=\u0026gt;9; (1,1,1,1)=\u0026gt; 4; (1,1,2)=\u0026gt;7, (4)=\u0026gt;9. \u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn this problem, you have to return the maximum reveneue you can obtain by cutting the rod of size x.\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":44066,"title":"Number of paths on a 3d grid","description":"This problem is inspired by \u003chttps://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003e, which you might want to solve first.\r\n\r\nConsider a 3d grid formed by n vertices vertically down, m vertices horizontally right, l vertices horizontally front. Your starting point is at the top left front vertex. Your destination is the bottom right back vertex. (From one corner to the furthest corner) You are permitted at each vertex to choose to move down,  right or back, that is in the direction towards the destination. You are not to move on what constitutes a back step like moving left, up, or front. If you hit the bottom boundary, right boundary, or back boundary, take it to be given that you move along the 2d boundary.\r\n\r\nEx: in a 2x2X2 grid there are 6 ways. (down, right, back), (d,b,r), (r,d,b), (r,b,d), (b,r,d), (b,d,r)\r\n\r\n4x3x2 has 60 ways\r\n\r\n6x5x4 has 27720 ways\r\n\r\nThis problem can be solved using dynamic programming but there are other methods too.\r\n\r\n","description_html":"\u003cp\u003eThis problem is inspired by \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003c/a\u003e, which you might want to solve first.\u003c/p\u003e\u003cp\u003eConsider a 3d grid formed by n vertices vertically down, m vertices horizontally right, l vertices horizontally front. Your starting point is at the top left front vertex. Your destination is the bottom right back vertex. (From one corner to the furthest corner) You are permitted at each vertex to choose to move down,  right or back, that is in the direction towards the destination. You are not to move on what constitutes a back step like moving left, up, or front. If you hit the bottom boundary, right boundary, or back boundary, take it to be given that you move along the 2d boundary.\u003c/p\u003e\u003cp\u003eEx: in a 2x2X2 grid there are 6 ways. (down, right, back), (d,b,r), (r,d,b), (r,b,d), (b,r,d), (b,d,r)\u003c/p\u003e\u003cp\u003e4x3x2 has 60 ways\u003c/p\u003e\u003cp\u003e6x5x4 has 27720 ways\u003c/p\u003e\u003cp\u003eThis problem can be solved using dynamic programming but there are other methods too.\u003c/p\u003e","function_template":"function y = count3dPath(x)\r\n  y = x;\r\nend","test_suite":"%%\r\nm = 2; n = 2 ; l = 5;\r\ny_correct = 30;\r\nassert(isequal(count3dPath(m,n,l),y_correct))\r\n \t\t\r\n%%\r\nm = 8; n = 5 ; l = 2;\r\ny_correct = 3960;\r\nassert(isequal(count3dPath(m,n,l),y_correct))\r\n\t\r\n%%\r\nm = 5; n = 5 ; l = 10;\r\ny_correct = 1701700;\r\nassert(isequal(count3dPath(m,n,l),y_correct))\r\n\t\r\n%%\r\nm = 8; n = 4 ; l=2;\r\ny_correct = 1320;\r\nassert(isequal(count3dPath(m,n,l),y_correct))\r\n","published":true,"deleted":false,"likes_count":1,"comments_count":1,"created_by":115733,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":53,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-02-14T00:01:08.000Z","updated_at":"2026-03-19T08:12:10.000Z","published_at":"2017-02-14T00:01:08.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"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\u003eThis problem is inspired by\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;, which you might want to solve first.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConsider a 3d grid formed by n vertices vertically down, m vertices horizontally right, l vertices horizontally front. Your starting point is at the top left front vertex. Your destination is the bottom right back vertex. (From one corner to the furthest corner) You are permitted at each vertex to choose to move down, right or back, that is in the direction towards the destination. You are not to move on what constitutes a back step like moving left, up, or front. If you hit the bottom boundary, right boundary, or back boundary, take it to be given that you move along the 2d boundary.\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\u003eEx: in a 2x2X2 grid there are 6 ways. (down, right, back), (d,b,r), (r,d,b), (r,b,d), (b,r,d), (b,d,r)\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\u003e4x3x2 has 60 ways\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\u003e6x5x4 has 27720 ways\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\u003eThis problem can be solved using dynamic programming but there are other methods too.\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":47154,"title":"Climbing the stairs","description":null,"description_html":"\u003cdiv style = \"text-align: start; line-height: 20.44px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: none solid rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 229.4px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 114.7px; transform-origin: 407px 114.7px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eThe number of steps in the staircase are given as n. You can climb atmost 3 steps at a time.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eOutput the \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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"font-weight: 700; \"\u003enumber of ways\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: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003e you can climb the stairs modulo (10^9 + 7).\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eExample:\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eif n = 1, output = 1, because ways of climbing = { (1) }\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eif n = 2, output = 2, because ways of climbing = {(1,1), (2)}\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eif n = 3, output =  4, because ways of climbing = { (1,1,1), (1,2), (2,1), (3) }\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003e\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 20.8px; 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.4px; text-align: left; transform-origin: 384px 10.4px; 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=\"\"\u003eHint : refer tags\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = climb(n) \r\ny = y + y + y\r\ny = mod(y,10^9 + 7);\r\nend","test_suite":"%%\r\nn = 1;\r\ny_correct = 1;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 2;\r\ny_correct = 2;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 3;\r\ny_correct = 4;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 100;\r\ny_correct = 347873931;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 500; % normal people don't do this.\r\ny_correct = 283701821;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 1000; %Some sort of kung fu panda trainning :P\r\ny_correct = 509672692;\r\nassert(isequal(climb(n),y_correct))\r\n\r\n%%\r\nn = 10000; %hypothetical case.\r\ny_correct = 126130994;\r\nassert(isequal(climb(n),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":442401,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":6,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2020-10-31T11:51:36.000Z","updated_at":"2025-11-19T15:10:41.000Z","published_at":"2020-10-31T11:51:36.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\u003eThe number of steps in the staircase are given as n. You can climb atmost 3 steps at a time.\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\u003eOutput the \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003enumber of ways\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e you can climb the stairs modulo (10^9 + 7).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 1, output = 1, because ways of climbing = { (1) }\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 2, output = 2, because ways of climbing = {(1,1), (2)}\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eif n = 3, output =  4, because ways of climbing = { (1,1,1), (1,2), (2,1), (3) }\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eHint : refer tags\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":44072,"title":"Number of paths on a n-dimensional grid","description":"This problem is inspired by \u003chttps://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003e and  \u003chttps://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\u003e, which you might want to solve first.\r\n \r\nConsider n-dimensional grid, and you are moving from one corner to the farthest corner in a minimal number of moves. Each move corresponds to moving to a neighbouring hypercube (among possible up to 2*n neighbours). How many ways are there?\r\n\r\nInput format is a row array of size \"d\" (for d dimension) with number of grid points on each direction.\r\n\r\nOptional: can you solve it without loops?","description_html":"\u003cp\u003eThis problem is inspired by \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003c/a\u003e and  \u003ca href = \"https://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\"\u003ehttps://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\u003c/a\u003e, which you might want to solve first.\u003c/p\u003e\u003cp\u003eConsider n-dimensional grid, and you are moving from one corner to the farthest corner in a minimal number of moves. Each move corresponds to moving to a neighbouring hypercube (among possible up to 2*n neighbours). How many ways are there?\u003c/p\u003e\u003cp\u003eInput format is a row array of size \"d\" (for d dimension) with number of grid points on each direction.\u003c/p\u003e\u003cp\u003eOptional: can you solve it without loops?\u003c/p\u003e","function_template":"function y = countNdPath(NdRowVector)\r\n  y = sum(NdRowVector);\r\nend","test_suite":"%%\r\nNdRowVector = [3,3,3,3,3];\r\ny_correct = 113400;\r\nassert(isequal(countNdPath(NdRowVector),y_correct))\r\n\r\n%%\r\nNdRowVector = [1,3,3,3,3,1,1,1,3,3];\r\ny_correct = 7484400;\r\nassert(isequal(countNdPath(NdRowVector),y_correct))\r\n\r\n%%\r\nNdRowVector = [2,2,2,2,2,2,2,1,1,2,2,2,2];\r\ny_correct = 39916800;\r\nassert(isequal(countNdPath(NdRowVector),y_correct))","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":115733,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":50,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2017-02-14T01:28:35.000Z","updated_at":"2025-12-16T03:16:34.000Z","published_at":"2017-02-14T01:28:35.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis problem is inspired by\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/1483-number-of-paths-on-a-grid\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt; and \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\\\"\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026lt;https://www.mathworks.com/matlabcentral/cody/problems/44066-number-of-paths-on-a-3d-grid\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e\u0026gt;, which you might want to solve first.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eConsider n-dimensional grid, and you are moving from one corner to the farthest corner in a minimal number of moves. Each move corresponds to moving to a neighbouring hypercube (among possible up to 2*n neighbours). How many ways are there?\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\u003eInput format is a row array of size \\\"d\\\" (for d dimension) with number of grid points on each 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\u003eOptional: can you solve it without loops?\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":45415,"title":"Find an optimal placement of coolers on a grid","description":"In a certain chemical plant, 6 new pieces of cooling equipment (coolers) are to be installed in a vacant space. This vacant space was divided into a grid of 6 cells by 6 cells. Your task is to assign the 6 coolers to 6 cells in this grid with the following requirements:\r\n\r\n# There must be one cooler for every column in the grid.\r\n# If you decide to install a cooler at row R, column C, then the cooler at column C+1 must be installed either on row R-1, R, or R+1 only. This is done to ease the connection of coolers by piping.\r\n# The total installation cost for the 6 coolers must be minimum.\r\n\r\nFor this problem, you are given a cost matrix (COST) in relation to the third requirement above. COST is a 6 x 6 matrix where the _r,c_-th element is the cost of assigning any cooler to row _r_, column _c_ (All the coolers are identical). Write a function that accepts the matrix COST, and output the value of the minimum cost of installation. You are ensured that all elements of COST are integers in the range [1,1000].\r\n\r\nIn the sample test case below, the optimal placement is at the following rows: 4,3,3,2,2,2.\r\n\r\n  \u003e\u003e COST = [695   766   710   119   752   548;\r\n             318   796   755   499   256   139;\r\n             951   187   277   960   506   150;\r\n              35   490   680   341   700   258;\r\n             439   446   656   586   891   841;\r\n             382   647   163   224   960   255];\r\n  \u003e\u003e coolers(COST)\r\n  ans = \r\n        1393\r\n    \r\nMeanwhile, the optimal placement for the case below is at rows: 5,6,5,6,5,6\r\n\r\n  \u003e\u003e COST = [815   617   918    76   569   312;\r\n             244   474   286    54   470   529;\r\n             930   352   758   531   455   988;\r\n             350   831   754   780    12   602;\r\n             197   586   381   935   163   263;\r\n             252   550   568   130   795   100];\r\n  \u003e\u003e coolers(COST)\r\n  ans = \r\n        1521\r\n","description_html":"\u003cp\u003eIn a certain chemical plant, 6 new pieces of cooling equipment (coolers) are to be installed in a vacant space. This vacant space was divided into a grid of 6 cells by 6 cells. Your task is to assign the 6 coolers to 6 cells in this grid with the following requirements:\u003c/p\u003e\u003col\u003e\u003cli\u003eThere must be one cooler for every column in the grid.\u003c/li\u003e\u003cli\u003eIf you decide to install a cooler at row R, column C, then the cooler at column C+1 must be installed either on row R-1, R, or R+1 only. This is done to ease the connection of coolers by piping.\u003c/li\u003e\u003cli\u003eThe total installation cost for the 6 coolers must be minimum.\u003c/li\u003e\u003c/ol\u003e\u003cp\u003eFor this problem, you are given a cost matrix (COST) in relation to the third requirement above. COST is a 6 x 6 matrix where the \u003ci\u003er,c\u003c/i\u003e-th element is the cost of assigning any cooler to row \u003ci\u003er\u003c/i\u003e, column \u003ci\u003ec\u003c/i\u003e (All the coolers are identical). Write a function that accepts the matrix COST, and output the value of the minimum cost of installation. You are ensured that all elements of COST are integers in the range [1,1000].\u003c/p\u003e\u003cp\u003eIn the sample test case below, the optimal placement is at the following rows: 4,3,3,2,2,2.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; COST = [695   766   710   119   752   548;\r\n           318   796   755   499   256   139;\r\n           951   187   277   960   506   150;\r\n            35   490   680   341   700   258;\r\n           439   446   656   586   891   841;\r\n           382   647   163   224   960   255];\r\n\u0026gt;\u0026gt; coolers(COST)\r\nans = \r\n      1393\r\n\u003c/pre\u003e\u003cp\u003eMeanwhile, the optimal placement for the case below is at rows: 5,6,5,6,5,6\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e\u0026gt;\u0026gt; COST = [815   617   918    76   569   312;\r\n           244   474   286    54   470   529;\r\n           930   352   758   531   455   988;\r\n           350   831   754   780    12   602;\r\n           197   586   381   935   163   263;\r\n           252   550   568   130   795   100];\r\n\u0026gt;\u0026gt; coolers(COST)\r\nans = \r\n      1521\r\n\u003c/pre\u003e","function_template":"function y = coolers(COST)\r\n  y = x;\r\nend","test_suite":"%%\r\nfiletext = fileread('coolers.m')\r\nassert(isempty(strfind(filetext, 'rand')))\r\n%%\r\nCOST = [815   617   918    76   569   312;\r\n   244   474   286    54   470   529;\r\n   930   352   758   531   455   988;\r\n   350   831   754   780    12   602;\r\n   197   586   381   935   163   263;\r\n   252   550   568   130   795   100];\r\nassert(isequal(coolers(COST),1521))\r\n%%\r\nCOST = [690   153   107    85   182   550;\r\n   749   826   962   400   264   145;\r\n   451   539     5   260   146   854;\r\n    84   997   775   801   137   623;\r\n   229    79   818   432   870   351;\r\n   914   443   869   911   580   514];\r\nassert(isequal(coolers(COST),1179))\r\n%%\r\nCOST = [402   418   338   242   576    44;\r\n    76    50   901   404    60   169;\r\n   240   903   370    97   235   650;\r\n   124   945   112   132   354   732;\r\n   184   491   781   943   822   648;\r\n   240   490   390   957    16   451];\r\nassert(isequal(coolers(COST),697))\r\n%%\r\nCOST = [1 1 1000 1000 1000 1;\r\n        1 1000 1 1000 1000 1000;\r\n        1 1000 1000 1000 1 1000;\r\n        1 1000 1000 1 1000 1000;\r\n        1 1000 1000 1000 1000 1000;\r\n        1 1000 1000 1000 1000 1000];\r\nassert(isequal(coolers(COST),2004))\r\n%%\r\nCOST = [548   369   487   818   351   208;\r\n   297   626   436   795   940   302;\r\n   745   781   447   645   876   471;\r\n   189    82   307   379   551   231;\r\n   687   930   509   812   623   845;\r\n   184   776   511   533   588   195];\r\nassert(isequal(coolers(COST),1739))\r\n%%\r\nCOST = [226   431   259   222    86   489;\r\n   171   185   409   118   263   579;\r\n   228   905   595   297   802   238;\r\n   436   980   263   319    30   459;\r\n   312   439   603   425   929   964;\r\n   924   112   712   508   731   547];\r\nassert(isequal(coolers(COST),1234))\r\n%%\r\nCOST = [522   368    99   107   891   501;\r\n   232   988   262   654   335   480;\r\n   489    38   336   495   699   905;\r\n   625   886   680   780   198   610;\r\n   680   914   137   716    31   618;\r\n   396   797   722   904   745   860];\r\nassert(isequal(coolers(COST),1454))\r\n%%\r\nCOST = [806   490    60   819   973    84;\r\n   577   168   682   818   649   134;\r\n   183   979    43   723   801   174;\r\n   240   713    72   150   454   391;\r\n   887   501   522   660   433   832;\r\n    29   472    97   519   826   804];\r\nassert(isequal(coolers(COST),1172))\r\n%%\r\nCOST = [61         292         373          53         418         699;\r\n         400         432         199         738         984         667;\r\n         527          16         490         270         302         179;\r\n         417         985         340         423         702         129;\r\n         657         168         952         548         667        1000;\r\n         628         107         921         943         540         172];\r\nassert(isequal(coolers(COST),1253))\r\n%%\r\nCOST = [33   461   191   385   825   907;\r\n   562   982   429   583   983   880;\r\n   882   157   483   252   731   818;\r\n   670   856   121   291   344   261;\r\n   191   645   590   618   585   595;\r\n   369   377   227   266   108    23];\r\nassert(isequal(coolers(COST),1192))\r\n%%\r\nCOST = [426   599    69   719   779   441;\r\n   313   471   320   969   424   528;\r\n   162   696   531   532    91   458;\r\n   179   700   655   326   267   876;\r\n   423   639   408   106   154   519;\r\n    95    34   820   611   282   944];\r\nassert(isequal(coolers(COST),1316))\r\n%%\r\nCOST = [638   696   345   916   323   474;\r\n   958    68   781     2   785   153;\r\n   241   255   676   463   472   342;\r\n   677   225     7   425    36   608;\r\n   290   668   603   461   176   192;\r\n   672   845   387   771   722   739];\r\nassert(isequal(coolers(COST),1126))\r\n%%\r\nCOST = [243    92   648   237   771   257;\r\n   918   577   680   120   351   614;\r\n   270   684   636   608   663   583;\r\n   766   547   946   451   417   541;\r\n   189   426   209   459   842   870;\r\n   288   645   710   662   833   265];\r\nassert(isequal(coolers(COST),1711))\r\n%%\r\nCOST = [319   545   219   366   193   862;\r\n   120   648   106   764   139   485;\r\n   940   544   110   628   697   394;\r\n   646   722    64   772    94   672;\r\n   480   523   405   933   526   742;\r\n   640   994   449   973   531   521];\r\nassert(isequal(coolers(COST),1669))\r\n%%\r\nCOST = [674   622   842   636   885   896;\r\n   575   722   853   599   699   975;\r\n   794   844   722   911   905   664;\r\n   632   680   510   715   878   836;\r\n   523   869   667   944   689   720;\r\n   878   698   713   696   609   917];\r\nassert(isequal(coolers(COST),3837))\r\n%%\r\nCOST = [82 122 681 602 355 371;...\r\n    483 544 417 347 776 384;...\r\n    129 315 643 365 237 862;...\r\n    253 383 215 172 845 464;...\r\n    884 792 618 796 817 571;...\r\n    197 840 676 493 847 696];\r\nassert(isequal(coolers(COST),1452))\r\n%%\r\nCOST = [961 170 710 563 536 327;...\r\n    547 179 176 177 199 603;...\r\n    637 244 859 514 624 362;...\r\n    571 752 910 549 27 135;...\r\n    928 200 962 166 319 914;...\r\n    864 983 571 494 533 641];\r\nassert(isequal(coolers(COST),1569))\r\n%%\r\nCOST = [659 381 223 112 267 869;...\r\n    676 822 1000 425 292 529;...\r\n    745 172 64 614 189 915;...\r\n    843 330 426 989 23 974;...\r\n    517 967 405 220 450 586;...\r\n    152 807 401 355 244 119];\r\nassert(isequal(coolers(COST),1835))\r\n%%\r\nCOST = [927 925 215 554 571 679;...\r\n    594 643 249 631 336 213;...\r\n    884 105 227 986 958 82;...\r\n    425 701 704 635 440 275;...\r\n    608 396 755 601 602 868;...\r\n    71 85 548 910 721 560];\r\nassert(isequal(coolers(COST),1751))\r\n%%\r\nCOST = [465 433 384 904 809 299;...\r\n    431 506 712 219 180 769;...\r\n    774 376 481 874 166 502;...\r\n    654 481 730 83 182 910;...\r\n    658 343 938 466 692 58;...\r\n    162 778 518 22 214 437];\r\nassert(isequal(coolers(COST),1317))\r\n%%\r\nCOST = [573 952 497 860 78 228;...\r\n    566 767 809 627 339 710;...\r\n    824 752 633 181 581 149;...\r\n    127 139 689 574 476 659;...\r\n    301 350 640 164 806 634;...\r\n    3 152 730 907 531 230];\r\nassert(isequal(coolers(COST),1568))\r\n%%\r\nCOST = [183 958 897 179 998 879;...\r\n    167 26 190 747 5 747;...\r\n    150 972 661 50 543 118;...\r\n    203 298 942 72 862 510;...\r\n    955 526 976 490 910 169;...\r\n    16 863 108 850 846 832];\r\nassert(isequal(coolers(COST),539))\r\n%%\r\nCOST = [929 868 245 81 27 760;...\r\n    170 742 641 361 786 926;...\r\n    884 448 809 829 923 833;...\r\n    388 710 854 215 493 260;...\r\n    383 945 399 792 835 214;...\r\n    272 175 116 655 132 523];\r\nassert(isequal(coolers(COST),1564))\r\n%%\r\nCOST = [398 438 798 217 378 972;...\r\n    480 773 656 812 168 361;...\r\n    994 745 33 139 541 645;...\r\n    605 443 558 882 102 68;...\r\n    945 54 720 924 40 208;...\r\n    491 88 111 13 934 40];\r\nassert(isequal(coolers(COST),749))\r\n%%\r\nCOST = [470 581 9 642 470 879;...\r\n    151 541 825 106 220 189;...\r\n    992 706 768 269 923 760;...\r\n    428 6 998 764 321 32;...\r\n    956 783 228 806 858 643;...\r\n    725 927 920 105 260 567];\r\nassert(isequal(coolers(COST),1216))\r\n%%\r\nCOST = [377 187 35 595 562 603;...\r\n    213 486 489 499 634 474;...\r\n    793 839 972 568 931 357;...\r\n    146 142 113 427 978 476;...\r\n    490 733 744 77 94 672;...\r\n    13 692 639 291 662 960];\r\nassert(isequal(coolers(COST),1048))\r\n%%\r\nCOST = [90 52 454 629 707 46;...\r\n    798 505 738 133 536 886;...\r\n    591 769 510 619 194 840;...\r\n    913 283 383 384 690 119;...\r\n    102 226 906 992 51 411;...\r\n    294 332 966 287 185 121];\r\nassert(isequal(coolers(COST),1042))\r\n%%\r\nCOST = [573 666 232 754 549 464;...\r\n    950 974 53 622 461 590;...\r\n    257 623 902 395 646 188;...\r\n    990 64 794 360 514 612;...\r\n    350 374 374 89 815 52;...\r\n    209 167 833 342 98 576];\r\nassert(isequal(coolers(COST),934))\r\n%%\r\nCOST = [843 797 666 67 652 382;...\r\n    500 294 961 898 134 301;...\r\n    440 116 944 498 639 341;...\r\n    150 376 113 772 385 919;...\r\n    29 829 649 61 766 457;...\r\n    757 842 481 263 653 443];\r\nassert(isequal(coolers(COST),1166))\r\n%%\r\nCOST = [455 767 602 56 365 673;...\r\n    946 343 650 99 677 203;...\r\n    220 619 343 650 376 869;...\r\n    883 454 494 765 864 752;...\r\n    20 11 702 988 292 420;...\r\n    342 600 888 126 134 1];\r\nassert(isequal(coolers(COST),994))\r\n%%\r\nCOST = [150 436 24 66 150 132;...\r\n    274 904 575 924 351 887;...\r\n    873 926 47 535 336 675;...\r\n    602 506 423 367 785 836;...\r\n    322 628 468 364 487 657;...\r\n    285 720 23 152 465 984];\r\nassert(isequal(coolers(COST),958))\r\n%%\r\nCOST = [980 191 386 245 842 952;...\r\n    251 125 311 804 79 966;...\r\n    625 3 4 824 238 766;...\r\n    729 153 816 853 818 575;...\r\n    499 535 639 468 406 916;...\r\n    850 511 449 971 467 496];\r\nassert(isequal(coolers(COST),1655))\r\n%%\r\nCOST = [167 167 988 896 65 887;...\r\n    326 948 151 835 264 421;...\r\n    297 812 959 3 103 284;...\r\n    559 711 531 641 484 49;...\r\n    68 971 75 804 419 220;...\r\n    69 999 312 246 382 240];\r\nassert(isequal(coolers(COST),640))\r\n%%\r\nCOST = [30 653 667 689 433 469;...\r\n    703 321 848 321 905 546;...\r\n    8 104 763 532 631 180;...\r\n    611 536 808 874 984 635;...\r\n    409 165 633 55 586 963;...\r\n    249 884 711 501 841 535];\r\nassert(isequal(coolers(COST),2007))\r\n%%\r\nCOST = [480 679 683 689 62 13;...\r\n    794 566 947 148 220 217;...\r\n    93 479 100 778 83 12;...\r\n    881 321 512 400 951 643;...\r\n    4 602 111 899 17 517;...\r\n    512 914 546 308 115 246];\r\nassert(isequal(coolers(COST),648))\r\n%%\r\nCOST = [194 309 342 580 56 396;...\r\n    91 745 840 329 35 170;...\r\n    369 840 983 269 287 431;...\r\n    8 263 627 551 78 417;...\r\n    603 515 182 181 901 729;...\r\n    479 447 124 679 847 407];\r\nassert(isequal(coolers(COST),1129))\r\n%%\r\nCOST = [952 211 79 334 443 924;...\r\n    912 131 934 693 633 153;...\r\n    952 521 603 204 930 406;...\r\n    347 906 378 959 530 313;...\r\n    291 403 665 712 627 694;...\r\n    887 216 793 167 681 891];\r\nassert(isequal(coolers(COST),2052))\r\n%%\r\nCOST = [491 677 35 27 661 34;...\r\n    806 829 437 501 330 407;...\r\n    327 111 937 828 660 717;...\r\n    550 280 263 259 14 922;...\r\n    389 768 570 46 719 985;...\r\n    897 217 360 247 392 984];\r\nassert(isequal(coolers(COST),1266))\r\n%%\r\nCOST = [897 655 269 739 879 390;...\r\n    866 864 153 13 903 300;...\r\n    801 275 631 606 153 735;...\r\n    555 841 317 577 193 105;...\r\n    419 71 960 808 791 793;...\r\n    128 379 499 655 61 783];\r\nassert(isequal(coolers(COST),1254))\r\n%%\r\nCOST = [533 130 314 596 463 399;...\r\n    254 451 642 537 368 478;...\r\n    71 673 787 331 680 67;...\r\n    626 857 290 412 568 412;...\r\n    25 499 498 795 652 970;...\r\n    63 49 819 344 492 781];\r\nassert(isequal(coolers(COST),1580))\r\n%%\r\nCOST = [730 112 727 411 679 798;...\r\n    766 397 148 143 254 712;...\r\n    757 493 148 799 844 784;...\r\n    844 259 705 931 294 624;...\r\n    771 37 381 5 27 826;...\r\n    979 975 77 651 94 36];\r\nassert(isequal(coolers(COST),953))\r\n%%\r\nCOST = [406 27 672 377 507 436;...\r\n    250 156 53 114 329 158;...\r\n    481 834 735 965 754 601;...\r\n    881 195 500 433 837 938;...\r\n    281 830 944 85 254 108;...\r\n    600 339 290 717 535 900];\r\nassert(isequal(coolers(COST),931))\r\n%%\r\nCOST = [551 355 642 427 787 943;...\r\n    428 774 128 34 512 97;...\r\n    153 882 497 930 563 846;...\r\n    248 735 311 925 685 910;...\r\n    448 407 579 359 93 12;...\r\n    533 605 944 260 873 524];\r\nassert(isequal(coolers(COST),1430))\r\n%%\r\nCOST = [651 279 401 430 885 568;...\r\n    386 840 555 38 256 895;...\r\n    650 427 444 976 910 215;...\r\n    763 632 91 523 895 4;...\r\n    576 834 745 910 399 881;...\r\n    632 271 33 384 626 236];\r\nassert(isequal(coolers(COST),1575))\r\n%%\r\nCOST = [245 391 532 153 716 903;...\r\n    641 802 889 231 281 290;...\r\n    305 158 264 658 413 500;...\r\n    826 626 235 563 363 784;...\r\n    884 699 840 292 782 678;...\r\n    946 86 496 623 136 150];\r\nassert(isequal(coolers(COST),1276))\r\n%%\r\nCOST = [697 977 429 793 902 349;...\r\n    130 126 15 420 52 166;...\r\n    946 753 326 533 809 29;...\r\n    887 828 135 926 335 956;...\r\n    516 782 451 900 229 681;...\r\n    680 191 573 545 823 861];\r\nassert(isequal(coolers(COST),772))\r\n%%\r\nCOST = [940 301 652 887 695 895;...\r\n    681 74 170 115 207 842;...\r\n    918 768 532 443 555 131;...\r\n    257 85 634 660 880 190;...\r\n    886 729 15 295 558 154;...\r\n    921 448 471 951 753 29];\r\nassert(isequal(coolers(COST),1239))\r\n%%\r\nCOST = [10 496 746 686 237 463;...\r\n    597 259 338 268 196 926;...\r\n    610 733 585 970 706 216;...\r\n    919 117 469 184 181 2;...\r\n    734 747 88 300 523 907;...\r\n    302 810 829 412 297 681];\r\nassert(isequal(coolers(COST),1182))\r\n%%\r\nCOST = [515 394 842 779 399 396;...\r\n    523 8 49 728 671 399;...\r\n    103 546 317 651 441 752;...\r\n    997 510 784 665 133 523;...\r\n    359 247 973 939 440 491;...\r\n    626 46 587 536 548 89];\r\nassert(isequal(coolers(COST),1435))\r\n%%\r\nCOST = [251 93 71 159 652 1;...\r\n    448 954 301 63 499 641;...\r\n    638 163 814 702 285 8;...\r\n    710 971 77 87 831 107;...\r\n    993 598 355 617 819 107;...\r\n    933 241 133 174 939 368];\r\nassert(isequal(coolers(COST),771))\r\n%%\r\nCOST = [240 788 66 813 71 954;...\r\n    347 270 611 815 242 209;...\r\n    250 844 702 90 732 117;...\r\n    388 741 112 732 41 647;...\r\n    422 827 96 904 425 109;...\r\n    641 183 598 453 541 984];\r\nassert(isequal(coolers(COST),1343))\r\n%%\r\nCOST = [249 916 747 918 880 282;...\r\n    607 901 476 471 799 169;...\r\n    817 215 584 270 325 746;...\r\n    831 548 261 763 670 478;...\r\n    490 785 85 773 297 654;...\r\n    761 195 299 22 930 967];\r\nassert(isequal(coolers(COST),1567))\r\n%%\r\nCOST = [314 77 818 283 736 557;...\r\n    77 154 767 639 157 274;...\r\n    792 827 375 593 435 133;...\r\n    366 301 190 326 833 700;...\r\n    586 384 647 989 360 486;...\r\n    184 651 4 124 77 183];\r\nassert(isequal(coolers(COST),956))\r\n%%\r\nCOST = [102 248 381 378 851 968;...\r\n    202 438 749 973 257 477;...\r\n    135 670 157 606 286 995;...\r\n    324 548 59 339 780 491;...\r\n    951 610 340 928 702 504;...\r\n    533 864 818 899 493 769];\r\nassert(isequal(coolers(COST),1799))\r\n%%\r\nCOST = [389 799 340 268 52 543;...\r\n    454 221 273 177 628 809;...\r\n    133 858 171 432 30 794;...\r\n    759 905 665 476 137 502;...\r\n    566 293 536 786 695 277;...\r\n    649 726 830 131 516 120];\r\nassert(isequal(coolers(COST),1234))\r\n%%\r\nCOST = [887 183 567 504 84 962;...\r\n    971 32 378 261 74 467;...\r\n    943 725 822 733 770 787;...\r\n    639 145 305 163 818 423;...\r\n    91 636 320 922 741 944;...\r\n    75 790 785 223 759 2];\r\nassert(isequal(coolers(COST),1447))\r\n%%\r\nCOST = [982 666 329 847 415 7;...\r\n    571 685 928 902 662 767;...\r\n    347 793 757 596 784 22;...\r\n    558 349 289 69 248 394;...\r\n    300 251 607 219 555 253;...\r\n    160 346 767 870 230 205];\r\nassert(isequal(coolers(COST),1039))\r\n%%\r\nCOST = [663 975 947 135 372 260;...\r\n    915 120 967 806 227 134;...\r\n    7 519 68 525 447 420;...\r\n    747 822 438 945 267 507;...\r\n    800 638 321 989 460 325;...\r\n    908 954 135 410 433 685];\r\nassert(isequal(coolers(COST),1081))\r\n%%\r\nCOST = [444 502 305 970 394 701;...\r\n    436 556 767 690 459 110;...\r\n    794 631 268 718 209 7;...\r\n    816 98 40 560 758 598;...\r\n    753 246 297 534 547 660;...\r\n    790 616 557 876 358 581];\r\nassert(isequal(coolers(COST),1667))\r\n%%\r\nCOST = [910 165 870 241 503 143;...\r\n    637 281 788 9 568 381;...\r\n    526 260 970 672 189 397;...\r\n    260 548 181 905 325 577;...\r\n    52 542 931 573 717 20;...\r\n    732 789 46 156 553 578];\r\nassert(isequal(coolers(COST),1369))\r\n%%\r\nCOST = [933 303 817 55 540 946;...\r\n    107 460 451 638 938 377;...\r\n    733 49 807 425 661 68;...\r\n    971 386 791 906 395 182;...\r\n    609 362 283 418 259 576;...\r\n    720 288 69 155 848 186];\r\nassert(isequal(coolers(COST),1495))\r\n%%\r\nCOST = [292 28 747 842 871 890;...\r\n    462 659 747 511 212 66;...\r\n    347 159 174 166 837 510;...\r\n    319 803 118 715 860 621;...\r\n    460 409 175 908 524 734;...\r\n    236 328 628 219 478 230];\r\nassert(isequal(coolers(COST),1040))\r\n%%\r\nCOST = [22 327 315 114 208 74;...\r\n    139 138 160 701 785 595;...\r\n    770 385 153 180 527 862;...\r\n    970 563 137 804 572 449;...\r\n    387 634 710 514 423 653;...\r\n    994 542 465 549 722 304];\r\nassert(isequal(coolers(COST),716))\r\n%%\r\nCOST = [608 457 948 406 340 75;...\r\n    279 600 453 439 896 664;...\r\n    800 843 811 679 546 704;...\r\n    797 32 929 466 750 919;...\r\n    955 188 673 954 125 661;...\r\n    445 944 373 355 454 691];\r\nassert(isequal(coolers(COST),2010))\r\n%%\r\nCOST = [854 26 473 324 731 29;...\r\n    468 57 679 802 774 128;...\r\n    459 143 115 300 901 134;...\r\n    807 172 237 776 139 129;...\r\n    825 626 290 553 795 936;...\r\n    191 30 173 555 190 274];\r\nassert(isequal(coolers(COST),1199))\r\n%%\r\nCOST = [943 546 850 417 382 152;...\r\n    639 256 8 518 723 437;...\r\n    873 306 635 887 96 13;...\r\n    368 16 360 150 668 230;...\r\n    237 588 115 435 297 264;...\r\n    188 963 541 60 599 512];\r\nassert(isequal(coolers(COST),627))\r\n%%\r\nCOST = [216 475 261 618 402 95;...\r\n    347 826 590 145 15 376;...\r\n    748 304 480 717 75 546;...\r\n    414 822 199 402 592 112;...\r\n    56 566 240 463 447 905;...\r\n    391 55 781 708 927 634];\r\nassert(isequal(coolers(COST),940))\r\n%%\r\nCOST = [906 61 814 762 771 880;...\r\n    631 674 316 876 876 374;...\r\n    15 478 312 872 68 767;...\r\n    317 306 345 173 647 169;...\r\n    112 517 667 851 325 520;...\r\n    630 708 862 960 641 628];\r\nassert(isequal(coolers(COST),1043))\r\n%%\r\nCOST = [714 628 766 404 544 135;...\r\n    307 193 319 751 411 541;...\r\n    264 777 253 488 901 858;...\r\n    917 865 201 385 57 199;...\r\n    616 334 70 62 444 156;...\r\n    94 136 552 214 538 62];\r\nassert(isequal(coolers(COST),575))\r\n%%\r\nCOST = [662 683 487 77 915 603;...\r\n    19 138 680 445 92 466;...\r\n    292 630 705 166 994 299;...\r\n    974 858 461 399 97 134;...\r\n    765 900 365 921 314 296;...\r\n    244 349 281 512 786 167];\r\nassert(isequal(coolers(COST),1112))\r\n%%\r\nCOST = [318 40 863 414 595 658;...\r\n    110 617 277 415 310 685;...\r\n    833 670 532 984 902 474;...\r\n    972 38 523 58 94 142;...\r\n    219 4 568 397 320 951;...\r\n    707 143 334 792 887 883];\r\nassert(isequal(coolers(COST),1040))\r\n%%\r\nCOST = [438 952 914 477 226 187;...\r\n    835 2 534 251 568 647;...\r\n    326 296 805 308 999 129;...\r\n    368 49 563 967 132 82;...\r\n    795 443 751 209 955 660;...\r\n    100 790 10 521 124 28];\r\nassert(isequal(coolers(COST),914))\r\n%%\r\nCOST = [986 693 226 415 41 625;...\r\n    540 603 797 499 583 296;...\r\n    374 776 997 950 565 75;...\r\n    707 592 282 954 356 294;...\r\n    948 377 711 733 881 235;...\r\n    383 851 665 385 625 346];\r\nassert(isequal(coolers(COST),1955))\r\n%%\r\nCOST = [849 636 448 593 844 465;...\r\n    161 844 327 69 424 31;...\r\n    158 783 280 206 545 435;...\r\n    509 265 932 724 528 558;...\r\n    604 315 400 576 186 639;...\r\n    162 184 380 201 82 35];\r\nassert(isequal(coolers(COST),1044))\r\n%%\r\nCOST = [710 855 367 351 91 968;...\r\n    170 385 350 193 258 434;...\r\n    594 400 631 920 428 785;...\r\n    609 326 665 289 578 526;...\r\n    773 556 993 551 900 332;...\r\n    57 296 945 920 219 432];\r\nassert(isequal(coolers(COST),1623))\r\n%%\r\nCOST = [718 654 235 805 97 557;...\r\n    917 41 201 104 600 840;...\r\n    891 505 381 730 234 205;...\r\n    135 895 595 649 33 622;...\r\n    120 386 269 475 580 175;...\r\n    894 293 623 933 843 290];\r\nassert(isequal(coolers(COST),1365))\r\n%%\r\nCOST = [19 283 206 904 234 347;...\r\n    702 245 435 541 247 298;...\r\n    953 287 143 818 171 405;...\r\n    750 964 376 709 236 303;...\r\n    757 231 794 44 276 758;...\r\n    543 538 813 146 952 360];\r\nassert(isequal(coolers(COST),1417))\r\n%%\r\nCOST = [125 458 201 22 719 780;...\r\n    618 78 960 483 450 568;...\r\n    356 905 666 808 660 77;...\r\n    363 282 542 737 754 252;...\r\n    69 614 869 573 805 134;...\r\n    868 662 558 9 30 565];\r\nassert(isequal(coolers(COST),953))\r\n%%\r\nCOST = [541 43 122 494 863 421;...\r\n    69 528 592 856 685 488;...\r\n    989 257 360 725 635 461;...\r\n    252 409 720 200 142 516;...\r\n    316 948 524 158 80 272;...\r\n    301 920 261 371 877 232];\r\nassert(isequal(coolers(COST),1198))\r\n%%\r\nCOST = [900 895 226 336 740 434;...\r\n    909 88 105 620 889 290;...\r\n    604 540 10 993 860 632;...\r\n    366 429 60 649 598 296;...\r\n    599 618 323 540 655 623;...\r\n    669 559 780 233 916 48];\r\nassert(isequal(coolers(COST),2054))\r\n%%\r\nCOST = [995 67 543 281 171 63;...\r\n    207 928 781 599 372 407;...\r\n    608 88 522 37 40 464;...\r\n    348 333 932 64 710 203;...\r\n    718 527 148 323 642 870;...\r\n    28 247 417 99 175 598];\r\nassert(isequal(coolers(COST),730))\r\n%%\r\nCOST = [24 867 571 301 445 250;...\r\n    900 616 326 522 983 956;...\r\n    453 27 451 562 579 143;...\r\n    59 323 578 242 235 513;...\r\n    107 464 75 913 811 972;...\r\n    999 100 58 826 452 649];\r\nassert(isequal(coolers(COST),902))\r\n%%\r\nCOST = [615 424 874 119 114 462;...\r\n    470 274 301 99 491 864;...\r\n    578 445 401 891 600 263;...\r\n    912 628 518 34 91 824;...\r\n    377 535 62 840 979 329;...\r\n    229 386 232 508 654 942];\r\nassert(isequal(coolers(COST),1065))\r\n%%\r\nCOST = [245 314 524 145 800 565;...\r\n    958 58 893 245 209 218;...\r\n    511 45 406 379 897 858;...\r\n    565 813 605 271 746 862;...\r\n    994 413 95 216 537 314;...\r\n    771 385 336 634 970 327];\r\nassert(isequal(coolers(COST),1381))\r\n%%\r\nCOST = [841 334 286 610 505 816;...\r\n    493 367 657 384 8 910;...\r\n    52 795 232 31 920 778;...\r\n    779 39 622 858 411 758;...\r\n    427 727 76 604 733 406;...\r\n    280 873 967 848 152 702];\r\nassert(isequal(coolers(COST),1140))\r\n%%\r\nCOST = [566 563 904 539 781 176;...\r\n    585 547 605 738 537 417;...\r\n    345 551 927 182 770 740;...\r\n    705 695 117 427 639 893;...\r\n    161 928 341 99 894 26;...\r\n    2 945 37 304 61 138];\r\nassert(isequal(coolers(COST),1153))\r\n%%\r\nCOST = [425 619 192 805 191 892;...\r\n    765 7 715 860 504 674;...\r\n    525 741 178 567 51 686;...\r\n    755 992 987 755 57 696;...\r\n    170 129 17 520 336 800;...\r\n    673 361 40 586 631 661];\r\nassert(isequal(coolers(COST),1579))\r\n%%\r\nCOST = [520 255 928 227 995 523;...\r\n    332 846 588 2 984 274;...\r\n    935 539 102 894 965 719;...\r\n    247 911 367 454 667 779;...\r\n    512 351 276 579 727 82;...\r\n    741 936 267 316 335 222];\r\nassert(isequal(coolers(COST),1598))\r\n%%\r\nCOST = [204 470 675 379 889 587;...\r\n    625 379 552 618 563 969;...\r\n    726 341 52 563 195 582;...\r\n    835 64 308 831 222 100;...\r\n    19 762 966 958 706 167;...\r\n    203 403 932 76 597 103];\r\nassert(isequal(coolers(COST),993))\r\n%%\r\nCOST = [147 800 210 627 782 774;...\r\n    672 400 481 412 936 748;...\r\n    640 756 113 639 740 319;...\r\n    373 296 133 857 254 511;...\r\n    163 641 65 764 720 774;...\r\n    390 886 80 977 694 573];\r\nassert(isequal(coolers(COST),1784))\r\n%%\r\nCOST = [954 463 111 359 365 588;...\r\n    172 130 200 135 400 778;...\r\n    908 550 163 999 927 658;...\r\n    753 970 37 514 496 529;...\r\n    287 443 273 388 610 826;...\r\n    628 591 231 250 5 963];\r\nassert(isequal(coolers(COST),1501))\r\n%%\r\nCOST = [314 306 715 905 664 101;...\r\n    798 19 460 387 603 287;...\r\n    286 163 920 604 657 355;...\r\n    15 444 989 561 310 536;...\r\n    95 767 933 846 332 991;...\r\n    329 682 462 285 189 29];\r\nassert(isequal(coolers(COST),1729))\r\n%%\r\nCOST = [710 876 77 818 359 455;...\r\n    906 865 377 174 364 30;...\r\n    866 356 150 677 268 638;...\r\n    120 632 35 876 338 60;...\r\n    956 865 783 758 87 170;...\r\n    441 21 328 230 452 685];\r\nassert(isequal(coolers(COST),1098))\r\n%%\r\nCOST = [555 461 15 279 896 625;...\r\n    7 371 5 645 888 207;...\r\n    289 825 167 288 394 110;...\r\n    377 538 366 322 676 566;...\r\n    147 818 719 156 253 275;...\r\n    75 461 160 388 950 72];\r\nassert(isequal(coolers(COST),1175))\r\n%%\r\nCOST = [159 896 447 617 948 551;...\r\n    50 608 812 304 334 161;...\r\n    681 15 145 90 390 118;...\r\n    782 345 975 522 151 399;...\r\n    808 534 834 826 334 832;...\r\n    266 628 341 764 554 186];\r\nassert(isequal(coolers(COST),569))\r\n%%\r\nCOST = [501 491 579 185 613 662;...\r\n    127 887 776 198 738 896;...\r\n    865 906 662 862 304 275;...\r\n    767 499 470 126 43 998;...\r\n    565 530 220 646 836 835;...\r\n    390 910 603 438 370 792];\r\nassert(isequal(coolers(COST),1584))\r\n%%\r\nCOST = [657 988 206 794 242 185;...\r\n    544 789 495 682 210 88;...\r\n    387 853 32 651 273 309;...\r\n    823 486 828 238 776 231;...\r\n    596 874 265 478 332 910;...\r\n    782 334 678 937 604 937];\r\nassert(isequal(coolers(COST),1504))\r\n%%\r\nCOST = [32 626 369 811 16 974;...\r\n    594 256 338 724 95 373;...\r\n    44 905 619 675 515 321;...\r\n    425 768 87 914 953 784;...\r\n    522 563 376 821 844 213;...\r\n    841 898 188 549 936 960];\r\nassert(isequal(coolers(COST),1717))\r\n%%\r\nCOST = [931 594 600 844 914 151;...\r\n    366 98 227 771 577 947;...\r\n    345 560 714 510 288 651;...\r\n    693 44 725 707 267 983;...\r\n    717 758 345 792 891 194;...\r\n    801 660 33 331 367 829];\r\nassert(isequal(coolers(COST),1626))\r\n%%\r\nCOST = [494 60 648 497 429 28;...\r\n    591 516 624 763 42 906;...\r\n    45 54 954 180 226 472;...\r\n    565 844 177 692 667 911;...\r\n    634 595 475 915 872 328;...\r\n    499 692 843 163 345 692];\r\nassert(isequal(coolers(COST),526))\r\n%%\r\nCOST = [18 334 151 424 616 681;...\r\n    513 633 839 529 102 394;...\r\n    332 416 727 276 670 392;...\r\n    337 577 109 828 348 207;...\r\n    954 960 162 793 670 725;...\r\n    751 616 298 274 296 820];\r\nassert(isequal(coolers(COST),1421))\r\n%%\r\nCOST = [927 854 101 228 459 109;...\r\n    515 430 413 358 952 652;...\r\n    194 926 925 925 133 147;...\r\n    603 374 56 503 71 694;...\r\n    199 699 385 804 707 626;...\r\n    411 589 241 351 932 44];\r\nassert(isequal(coolers(COST),1345))\r\n%%\r\nCOST = [798 582 93 769 788 680;...\r\n    987 602 334 283 125 10;...\r\n    437 253 652 650 158 129;...\r\n    345 655 504 923 415 764;...\r\n    49 61 531 331 688 842;...\r\n    226 941 380 814 658 747];\r\nassert(isequal(coolers(COST),1350))\r\n%%\r\nCOST = [945 618 338 215 587 443;...\r\n    920 559 552 293 939 692;...\r\n    224 731 744 450 619 760;...\r\n    510 64 413 241 251 400;...\r\n    788 493 508 264 103 568;...\r\n    523 230 129 892 547 206];\r\nassert(isequal(coolers(COST),1251))\r\n%%\r\nCOST = [944 708 393 379 767 434;...\r\n    513 657 243 634 337 103;...\r\n    277 779 282 32 626 237;...\r\n    230 581 905 921 327 972;...\r\n    953 504 703 470 312 699;...\r\n    690 879 854 520 647 660];\r\nassert(isequal(coolers(COST),1565))\r\n%%\r\nCOST = [327 450 172 573 377 40;...\r\n    20 769 722 832 394 565;...\r\n    571 628 90 348 429 50;...\r\n    37 315 918 780 424 873;...\r\n    265 293 430 709 219 861;...\r\n    191 79 80 591 497 339];\r\nassert(isequal(coolers(COST),1224))\r\n%%\r\nCOST = [975 347 346 214 761 636;...\r\n    955 234 903 936 580 803;...\r\n    989 756 13 970 622 670;...\r\n    158 226 133 376 490 472;...\r\n    3 449 389 985 221 945;...\r\n    249 260 841 123 145 592];\r\nassert(isequal(coolers(COST),1311))\r\n%%\r\nCOST = [227 932 883 581 327 592;...\r\n    684 697 780 627 288 1;...\r\n    321 96 19 112 497 904;...\r\n    749 246 771 214 182 683;...\r\n    999 935 686 37 934 74;...\r\n    270 480 868 445 941 997];\r\nassert(isequal(coolers(COST),804))\r\n%%\r\nCOST = [315 176 835 189 254 788;...\r\n    810 588 997 578 287 438;...\r\n    462 155 973 629 126 551;...\r\n    588 446 746 365 529 987;...\r\n    478 538 200 637 821 690;...\r\n    553 462 37 892 300 971];\r\nassert(isequal(coolers(COST),2037))\r\n%%\r\nCOST = [96 320 833 203 939 1;...\r\n    899 796 571 493 975 484;...\r\n    59 302 71 730 608 148;...\r\n    124 608 267 955 958 315;...\r\n    631 462 171 763 331 172;...\r\n    371 293 561 81 902 593];\r\nassert(isequal(coolers(COST),1341))\r\n%%\r\nCOST = [658 16 262 188 656 56;...\r\n    349 974 894 744 782 820;...\r\n    54 735 973 719 863 107;...\r\n    48 753 995 189 786 7;...\r\n    56 34 347 434 434 276;...\r\n    72 118 293 46 348 943];\r\nassert(isequal(coolers(COST),862))\r\n%%\r\nCOST = [675 962 293 837 855 788;...\r\n    386 823 439 42 174 175;...\r\n    857 11 399 424 536 720;...\r\n    675 142 138 76 295 233;...\r\n    609 483 953 314 903 208;...\r\n    440 581 361 946 82 217];\r\nassert(isequal(coolers(COST),1114))\r\n%%\r\nCOST = [977 461 237 907 842 269;...\r\n    382 4 832 993 684 981;...\r\n    636 465 438 391 172 313;...\r\n    47 825 508 827 238 572;...\r\n    233 872 186 955 435 612;...\r\n    875 302 152 894 26 902];\r\nassert(isequal(coolers(COST),1700))\r\n%%\r\nCOST = [397 297 634 847 995 269;...\r\n    693 572 965 41 429 758;...\r\n    205 317 201 330 268 610;...\r\n    63 810 599 710 473 967;...\r\n    623 366 84 861 161 774;...\r\n    689 699 545 501 159 573];\r\nassert(isequal(coolers(COST),1320))\r\n%%\r\nCOST = [451 355 996 87 199 597;...\r\n    288 581 84 520 657 323;...\r\n    753 299 469 553 699 831;...\r\n    95 714 94 686 460 123;...\r\n    107 361 726 300 158 252;...\r\n    735 719 913 602 422 938];\r\nassert(isequal(coolers(COST),1069))\r\n\r\n","published":true,"deleted":false,"likes_count":7,"comments_count":2,"created_by":255320,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":56,"test_suite_updated_at":"2020-04-03T23:22:52.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2020-04-01T22:04:29.000Z","updated_at":"2026-02-26T16:11:43.000Z","published_at":"2020-04-01T22:55:22.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn a certain chemical plant, 6 new pieces of cooling equipment (coolers) are to be installed in a vacant space. This vacant space was divided into a grid of 6 cells by 6 cells. Your task is to assign the 6 coolers to 6 cells in this grid with the following requirements:\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThere must be one cooler for every column in the grid.\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf you decide to install a cooler at row R, column C, then the cooler at column C+1 must be installed either on row R-1, R, or R+1 only. This is done to ease the connection of coolers by piping.\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=\\\"2\\\"/\u003e\u003c/w:numPr\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe total installation cost for the 6 coolers must be minimum.\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 this problem, you are given a cost matrix (COST) in relation to the third requirement above. COST is a 6 x 6 matrix where the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:i/\u003e\u003c/w:rPr\u003e\u003cw:t\u003er,c\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e-th element is the cost of assigning any cooler to row\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\u003er\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e, column\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\u003ec\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e (All the coolers are identical). Write a function that accepts the matrix COST, and output the value of the minimum cost of installation. You are ensured that all elements of COST are integers in the range [1,1000].\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 the sample test case below, the optimal placement is at the following rows: 4,3,3,2,2,2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[\u003e\u003e COST = [695   766   710   119   752   548;\\n           318   796   755   499   256   139;\\n           951   187   277   960   506   150;\\n            35   490   680   341   700   258;\\n           439   446   656   586   891   841;\\n           382   647   163   224   960   255];\\n\u003e\u003e coolers(COST)\\nans = \\n      1393]]\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\u003eMeanwhile, the optimal placement for the case below is at rows: 5,6,5,6,5,6\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[\u003e\u003e COST = [815   617   918    76   569   312;\\n           244   474   286    54   470   529;\\n           930   352   758   531   455   988;\\n           350   831   754   780    12   602;\\n           197   586   381   935   163   263;\\n           252   550   568   130   795   100];\\n\u003e\u003e coolers(COST)\\nans = \\n      1521]]\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":1885,"title":"Minimum Sum thru a Lower Triangle","description":"This Challenge is to find the minimum cumulative sum that traverses from row-1 thru row-N via vertical/diagonal adjacent elements of adjacent rows.\r\n\r\nThe input is a series of values of length n*(n+1)/2.\r\n\r\n*Input:* S  [Series that can be converted into a lower triangle]\r\n\r\n*Output:* MinSum  [Minimum cost path from top to bottom]\r\n\r\n*Example:*\r\n\r\n[5 7 6 3 2 5] becomes\r\n\r\n  5 0 0\r\n  7 6 0\r\n  3 2 5\r\n\r\nCreates a MinSum of 13 [5+6+2].  The 5 can only see 6, 3 sees 7 and 6, while 2 sees 7 6 0.\r\n ","description_html":"\u003cp\u003eThis Challenge is to find the minimum cumulative sum that traverses from row-1 thru row-N via vertical/diagonal adjacent elements of adjacent rows.\u003c/p\u003e\u003cp\u003eThe input is a series of values of length n*(n+1)/2.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput:\u003c/b\u003e S  [Series that can be converted into a lower triangle]\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput:\u003c/b\u003e MinSum  [Minimum cost path from top to bottom]\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample:\u003c/b\u003e\u003c/p\u003e\u003cp\u003e[5 7 6 3 2 5] becomes\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e5 0 0\r\n7 6 0\r\n3 2 5\r\n\u003c/pre\u003e\u003cp\u003eCreates a MinSum of 13 [5+6+2].  The 5 can only see 6, 3 sees 7 and 6, while 2 sees 7 6 0.\u003c/p\u003e","function_template":"function MinSum=Find_MinSum(s)\r\n MinSum=0;\r\nend","test_suite":"%%\r\ns=[5 7 6 3 2 5];\r\nMinSum=Find_MinSum(s);\r\nexp=13;\r\nassert(exp==MinSum)\r\n%%\r\ns=[7 9 8 3 2 6 7 1 5   5 9   4   8   2   4 6   3   2   9   7   5 7   2   4   8   5   1   9 4   2   9   3   8   5   2   8  8   2   4   8   5   9   2   7   3];\r\nMinSum=Find_MinSum(s);\r\nexp=30;\r\nassert(exp==MinSum)\r\n%%\r\ns=[21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1];\r\nMinSum=Find_MinSum(s);\r\nexp=76;\r\nassert(exp==MinSum)\r\n%%\r\ns=1:28;\r\nMinSum=Find_MinSum(s);\r\nexp=63;\r\nassert(exp==MinSum)\r\n%%\r\ns=[82 91 13 92 64 10 28 55 96 97 16 98 96 49 81 15 43 92 80 96 66 4 85 94 68 76 75 40 66 18 71 4 28 5 10 83 ];\r\nMinSum=Find_MinSum(s);\r\nexp=213;\r\nassert(exp==MinSum)\r\n%%\r\ns=[348 159 476 18 220 191 383 398 94 245 223 324 355 378 139 340 328 82 60 250 480 171 293 112 376 128 253 350 446 480 274 70 75 129 421 128 ];\r\nMinSum=Find_MinSum(s);\r\nexp=1409;\r\nassert(exp==MinSum)\r\n\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":14,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-09-21T02:45:50.000Z","updated_at":"2025-12-04T12:10:46.000Z","published_at":"2013-09-21T03:00:18.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\u003eThis Challenge is to find the minimum cumulative sum that traverses from row-1 thru row-N via vertical/diagonal adjacent elements of adjacent rows.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe input is a series of values of length n*(n+1)/2.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e S [Series that can be converted into a lower triangle]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput:\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e MinSum [Minimum cost path from top to bottom]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e[5 7 6 3 2 5] becomes\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[5 0 0\\n7 6 0\\n3 2 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\u003eCreates a MinSum of 13 [5+6+2]. The 5 can only see 6, 3 sees 7 and 6, while 2 sees 7 6 0.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"dynamic programming\"","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:\"dynamic programming\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"dynamic programming\"","","\"","dynamic programming","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f08346c8020\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f08346c7b20\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f08346c4740\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f08346c9560\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f08346c9060\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f08346c8840\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f08346c82a0\u003e":"tag:\"dynamic programming\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f08346c82a0\u003e":"tag:\"dynamic programming\""},"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:\"dynamic programming\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"dynamic programming\"","","\"","dynamic programming","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f08346c8020\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f08346c7b20\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f08346c4740\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f08346c9560\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f08346c9060\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f08346c8840\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f08346c82a0\u003e":"tag:\"dynamic programming\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f08346c82a0\u003e":"tag:\"dynamic programming\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":48990,"difficulty_rating":"easy-medium"},{"id":56030,"difficulty_rating":"easy-medium"},{"id":55290,"difficulty_rating":"easy-medium"},{"id":44066,"difficulty_rating":"easy-medium"},{"id":47154,"difficulty_rating":"easy-medium"},{"id":44072,"difficulty_rating":"medium"},{"id":45415,"difficulty_rating":"medium"},{"id":1885,"difficulty_rating":"medium-hard"}]}}