{"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":2248,"title":"Bell Number calculator","description":"Calculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the Wikipedia entry for Bell Number.\r\nExample\r\n Belln(8) = [1 1 2 5 15 52 203 877 4140]","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: 102.433px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 51.2167px; transform-origin: 407px 51.2167px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 374px 8px; transform-origin: 374px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See 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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWikipedia entry for Bell Number\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\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: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 160px 8.5px; transform-origin: 160px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Belln(8) = [1 1 2 5 15 52 203 877 4140]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = Belln(n)\r\n  y = [1:x];\r\nend","test_suite":"%%\r\nn = 0;\r\ny_correct = 1;\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 5;\r\ny_correct = [1 1 2 5 15 52];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 10;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 13;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975 678570 4213597 27644437];\r\nassert(isequal(Belln(n),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":23893,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":191,"test_suite_updated_at":"2021-06-16T09:39:43.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-03-14T09:59:39.000Z","updated_at":"2026-02-16T10:15:53.000Z","published_at":"2014-03-14T10:09:41.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\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia entry for Bell Number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Belln(8) = [1 1 2 5 15 52 203 877 4140]]]\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":59586,"title":"List ways to make a sum in Killer Sudoku","description":"In Sudoku, the subject of several Cody problems, one tries to arrange the digits 1 through 9 in a 9x9 grid of 81 cells (or a 3x3 arrangement of nine 3x3 boxes) so that every row, column, and 3x3 box contains each digit exactly once. In the variant Killer Sudoku, digits are placed in cages that indicate the sum of the digits; digits cannot be repeated in cages. In the example below from Wikipedia, the cages are indicated by colors. \r\nSolving Killer Sudoku with few (or no) given digits requires ready ideas of how to make particular sums. A two-digit cage with a sum of 3 can contain only 1 and 2, and a two-digit cage with a sum of 4 can contain only 1 and 3 because 2 cannot be repeated. A three-digit cage with a sum of 21 can have some arrangement of [9 8 4], [9 7 5], or [8 7 6]. The three-digit cage summing to 17 in the central box of the example has seven possible sets, but if the box already has an 8 outside the 17-cage, then only four of those sets are possible: [9 7 1], [9 6 2], [9 5 3], [7 6 4].\r\nWrite a function to list the ways to make a sum with a given number of digits. If only two arguments are given, then all of the digits 1-9 are possible. If a third argument is given, then it indicates the digits that cannot be used. The output should be a matrix in which the digits decrease along the rows and the rows are sorted in decreasing order of the first digit, then the second digit, then the third, etc., as in the examples. List only one arrangement: in the last example above, only [9 7 1] is given, not [9 1 7], [7 9 1], [7 1 9], [1 9 7], and [1 7 9]. If the sum cannot be made, return [].\r\n","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 582.7px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 291.35px; transform-origin: 407px 291.35px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; 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 42px; text-align: left; transform-origin: 384px 42px; 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: 78.95px 8px; transform-origin: 78.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn Sudoku, the subject of \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems?term=sudoku\u0026amp;submitsearch=\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eseveral Cody problems\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 223.65px 8px; transform-origin: 223.65px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, one tries to arrange the digits 1 through 9 in a 9x9 grid of 81 cells (or a 3x3 arrangement of nine 3x3 boxes) so that every row, column, and 3x3 box contains each digit exactly once. In the variant Killer Sudoku, digits are placed in cages that indicate the sum of the digits; digits cannot be repeated in cages. In the example below from \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Killer_sudoku\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWikipedia\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 110.075px 8px; transform-origin: 110.075px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, the cages are indicated by colors. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 105px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 52.5px; text-align: left; transform-origin: 384px 52.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 372.65px 8px; transform-origin: 372.65px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSolving Killer Sudoku with few (or no) given digits requires ready ideas of how to make particular sums. A two-digit cage with a sum of 3 can contain only 1 and 2, and a two-digit cage with a sum of 4 can contain only 1 and 3 because 2 cannot be repeated. A three-digit cage with a sum of 21 can have some arrangement of [9 8 4], [9 7 5], or [8 7 6]. The three-digit cage summing to 17 in the central box of the example has seven possible sets, but if the box already has an 8 outside the 17-cage, then only four of those sets are possible: [9 7 1], [9 6 2], [9 5 3], [7 6 4].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 105px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 52.5px; text-align: left; transform-origin: 384px 52.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 383.75px 8px; transform-origin: 383.75px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to list the ways to make a sum with a given number of digits. If only two arguments are given, then all of the digits 1-9 are possible. If a third argument is given, then it indicates the digits that cannot be used. The output should be a matrix in which the digits decrease along the rows and the rows are sorted in decreasing order of the first digit, then the second digit, then the third, etc., as in the examples. List only one arrangement: in the last example above, only [9 7 1] is given, not [9 1 7], [7 9 1], [7 1 9], [1 9 7], and [1 7 9]. If the sum cannot be made, return [].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 261.7px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 130.85px; text-align: left; transform-origin: 384px 130.85px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cimg class=\"imageNode\" width=\"256\" height=\"256\" style=\"vertical-align: baseline;width: 256px;height: 256px\" src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Killersudoku_color.svg/1024px-Killersudoku_color.svg.png\" data-image-state=\"image-loaded\"\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = makesum(varargin)\r\n% Argument 1 is the target sum, and argument 2 is the number of digits to be used in the sum.\r\n% If given, argument 3 lists the digits to exclude from the sum.\r\n  y = sum(randi(9,n));\r\nend","test_suite":"%%\r\nx = randi(9);\r\nn = 1;\r\ny = makesum(x,n);\r\ny_correct = x;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 3;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [2 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 4;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [3 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 5;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [4 1; 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 6;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [5 1; 4 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 7;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [6 1; 5 2; 4 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 8;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [7 1; 6 2; 5 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 9;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [8 1; 7 2; 6 3; 5 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 10;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 1; 8 2; 7 3; 6 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 11;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 2; 8 3; 7 4; 6 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 12;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 3; 8 4; 7 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 13;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 4; 8 5; 7 6];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 14;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 5; 8 6];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 15;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 6; 8 7];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 16;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 7];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 17;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 8];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 17;\r\nn = 2;\r\nd = [];\r\ny = makesum(x,n,d);\r\ny_correct = [9 8];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 17;\r\nn = 2;\r\nd = [1 2];\r\ny = makesum(x,n,d);\r\ny_correct = [9 8];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 6;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [3 2 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 7;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [4 2 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 8;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [5 2 1; 4 3 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 8;\r\nn = 3;\r\nd = 2;\r\ny = makesum(x,n,d);\r\ny_correct = [4 3 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 9;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [6 2 1; 5 3 1; 4 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 10;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [7 2 1; 6 3 1; 5 4 1; 5 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 11;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [8 2 1; 7 3 1; 6 4 1; 6 3 2; 5 4 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 12;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 2 1; 8 3 1; 7 4 1; 7 3 2; 6 5 1; 6 4 2; 5 4 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 13;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 3 1; 8 4 1; 8 3 2; 7 5 1; 7 4 2; 6 5 2; 6 4 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 13;\r\nn = 3;\r\nd = [1 3];\r\ny = makesum(x,n,d);\r\ny_correct = [7 4 2; 6 5 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 14;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 4 1; 9 3 2; 8 5 1; 8 4 2; 7 6 1; 7 5 2; 7 4 3; 6 5 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 15;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 5 1; 9 4 2; 8 6 1; 8 5 2; 8 4 3; 7 6 2; 7 5 3; 6 5 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 16;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 6 1; 9 5 2; 9 4 3; 8 7 1; 8 6 2; 8 5 3; 7 6 3; 7 5 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 16;\r\nn = 3;\r\nd = 3;\r\ny = makesum(x,n,d);\r\ny_correct = [9 6 1; 9 5 2; 8 7 1; 8 6 2; 7 5 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 17;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 7 1; 9 6 2; 9 5 3; 8 7 2; 8 6 3; 8 5 4; 7 6 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 18;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 8 1; 9 7 2; 9 6 3; 9 5 4; 8 7 3; 8 6 4; 7 6 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 19;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 8 2; 9 7 3; 9 6 4; 8 7 4; 8 6 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 20;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 8 3; 9 7 4; 9 6 5; 8 7 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 21;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 8 4; 9 7 5; 8 7 6];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 21;\r\nn = 3;\r\nd = 7;\r\ny = makesum(x,n,d);\r\ny_correct = [9 8 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 10;\r\nn = 4;\r\ny = makesum(x,n);\r\ny_correct = [4 3 2 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 16;\r\nn = 4;\r\ny = makesum(x,n);\r\ny_correct = [9 4 2 1; 8 5 2 1; 8 4 3 1; 7 6 2 1; 7 5 3 1; 7 4 3 2; 6 5 4 1; 6 5 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 21;\r\nn = 4;\r\ny = makesum(x,n);\r\ny_correct = [9 8 3 1; 9 7 4 1; 9 7 3 2; 9 6 5 1; 9 6 4 2; 9 5 4 3; 8 7 5 1; 8 7 4 2; 8 6 5 2; 8 6 4 3; 7 6 5 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 21;\r\nn = 4;\r\nd = [1 3];\r\ny = makesum(x,n,d);\r\ny_correct = [9 6 4 2; 8 7 4 2; 8 6 5 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 40;\r\nn = 6;\r\ny = makesum(x,n);\r\nassert(isempty(y))\r\n\r\n%% \r\nx = 40;\r\nn = 7;\r\ny = makesum(x,n);\r\ny_correct = [9 8 7 6 5 4 1; 9 8 7 6 5 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 45;\r\nn = 9;\r\ny = makesum(x,n);\r\ny_correct = 9:-1:1;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nfiletext = fileread('makesum.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert'); \r\nassert(~illegal)","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2024-01-22T12:22:39.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2024-01-22T05:25:55.000Z","updated_at":"2024-01-22T12:22:39.000Z","published_at":"2024-01-22T05:32:13.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\u003eIn Sudoku, the subject of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems?term=sudoku\u0026amp;submitsearch=\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eseveral Cody problems\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, one tries to arrange the digits 1 through 9 in a 9x9 grid of 81 cells (or a 3x3 arrangement of nine 3x3 boxes) so that every row, column, and 3x3 box contains each digit exactly once. In the variant Killer Sudoku, digits are placed in cages that indicate the sum of the digits; digits cannot be repeated in cages. In the example below from \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Killer_sudoku\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, the cages are indicated by colors. \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\u003eSolving Killer Sudoku with few (or no) given digits requires ready ideas of how to make particular sums. A two-digit cage with a sum of 3 can contain only 1 and 2, and a two-digit cage with a sum of 4 can contain only 1 and 3 because 2 cannot be repeated. A three-digit cage with a sum of 21 can have some arrangement of [9 8 4], [9 7 5], or [8 7 6]. The three-digit cage summing to 17 in the central box of the example has seven possible sets, but if the box already has an 8 outside the 17-cage, then only four of those sets are possible: [9 7 1], [9 6 2], [9 5 3], [7 6 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\u003eWrite a function to list the ways to make a sum with a given number of digits. If only two arguments are given, then all of the digits 1-9 are possible. If a third argument is given, then it indicates the digits that cannot be used. The output should be a matrix in which the digits decrease along the rows and the rows are sorted in decreasing order of the first digit, then the second digit, then the third, etc., as in the examples. List only one arrangement: in the last example above, only [9 7 1] is given, not [9 1 7], [7 9 1], [7 1 9], [1 9 7], and [1 7 9]. If the sum cannot be made, return [].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"256\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"256\\\"/\u003e\u003cw:attr w:name=\\\"verticalAlign\\\" w:val=\\\"baseline\\\"/\u003e\u003cw:attr w:name=\\\"altText\\\" w:val=\\\"\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"target\":\"/media/image1.png\",\"relationshipId\":\"rId1\"}]},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Killersudoku_color.svg/1024px-Killersudoku_color.svg.png\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":2248,"title":"Bell Number calculator","description":"Calculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the Wikipedia entry for Bell Number.\r\nExample\r\n Belln(8) = [1 1 2 5 15 52 203 877 4140]","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: 102.433px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 51.2167px; transform-origin: 407px 51.2167px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 42px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 21px; text-align: left; transform-origin: 384px 21px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 374px 8px; transform-origin: 374px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See 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: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"/#null\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWikipedia entry for Bell Number\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 2px 8px; transform-origin: 2px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e.\u003c/span\u003e\u003c/span\u003e\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: 26.5px 8px; transform-origin: 26.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 20.4333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 160px 8.5px; transform-origin: 160px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e Belln(8) = [1 1 2 5 15 52 203 877 4140]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = Belln(n)\r\n  y = [1:x];\r\nend","test_suite":"%%\r\nn = 0;\r\ny_correct = 1;\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 5;\r\ny_correct = [1 1 2 5 15 52];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 9;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 10;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975];\r\nassert(isequal(Belln(n),y_correct))\r\n%%\r\nn = 13;\r\ny_correct = [1 1 2 5 15 52 203 877 4140 21147 115975 678570 4213597 27644437];\r\nassert(isequal(Belln(n),y_correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":23893,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":191,"test_suite_updated_at":"2021-06-16T09:39:43.000Z","rescore_all_solutions":true,"group_id":8,"created_at":"2014-03-14T09:59:39.000Z","updated_at":"2026-02-16T10:15:53.000Z","published_at":"2014-03-14T10:09:41.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\u003eCalculate a vector of Bell numbers for sets up to length n. Bell numbers are the maximum number of partitions of a set. See the\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia entry for Bell Number\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Belln(8) = [1 1 2 5 15 52 203 877 4140]]]\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":59586,"title":"List ways to make a sum in Killer Sudoku","description":"In Sudoku, the subject of several Cody problems, one tries to arrange the digits 1 through 9 in a 9x9 grid of 81 cells (or a 3x3 arrangement of nine 3x3 boxes) so that every row, column, and 3x3 box contains each digit exactly once. In the variant Killer Sudoku, digits are placed in cages that indicate the sum of the digits; digits cannot be repeated in cages. In the example below from Wikipedia, the cages are indicated by colors. \r\nSolving Killer Sudoku with few (or no) given digits requires ready ideas of how to make particular sums. A two-digit cage with a sum of 3 can contain only 1 and 2, and a two-digit cage with a sum of 4 can contain only 1 and 3 because 2 cannot be repeated. A three-digit cage with a sum of 21 can have some arrangement of [9 8 4], [9 7 5], or [8 7 6]. The three-digit cage summing to 17 in the central box of the example has seven possible sets, but if the box already has an 8 outside the 17-cage, then only four of those sets are possible: [9 7 1], [9 6 2], [9 5 3], [7 6 4].\r\nWrite a function to list the ways to make a sum with a given number of digits. If only two arguments are given, then all of the digits 1-9 are possible. If a third argument is given, then it indicates the digits that cannot be used. The output should be a matrix in which the digits decrease along the rows and the rows are sorted in decreasing order of the first digit, then the second digit, then the third, etc., as in the examples. List only one arrangement: in the last example above, only [9 7 1] is given, not [9 1 7], [7 9 1], [7 1 9], [1 9 7], and [1 7 9]. If the sum cannot be made, return [].\r\n","description_html":"\u003cdiv style = \"text-align: start; line-height: 20.4333px; min-height: 0px; white-space: normal; color: rgb(0, 0, 0); font-family: Menlo, Monaco, Consolas, monospace; font-style: normal; font-size: 14px; font-weight: 400; text-decoration: rgb(0, 0, 0); white-space: normal; \"\u003e\u003cdiv style=\"block-size: 582.7px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 291.35px; transform-origin: 407px 291.35px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 84px; 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 42px; text-align: left; transform-origin: 384px 42px; 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: 78.95px 8px; transform-origin: 78.95px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eIn Sudoku, the subject of \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://www.mathworks.com/matlabcentral/cody/problems?term=sudoku\u0026amp;submitsearch=\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"text-decoration-line: underline; \"\u003eseveral Cody problems\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 223.65px 8px; transform-origin: 223.65px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, one tries to arrange the digits 1 through 9 in a 9x9 grid of 81 cells (or a 3x3 arrangement of nine 3x3 boxes) so that every row, column, and 3x3 box contains each digit exactly once. In the variant Killer Sudoku, digits are placed in cages that indicate the sum of the digits; digits cannot be repeated in cages. In the example below from \u003c/span\u003e\u003c/span\u003e\u003ca target='_blank' href = \"https://en.wikipedia.org/wiki/Killer_sudoku\"\u003e\u003cspan style=\"\"\u003e\u003cspan style=\"\"\u003eWikipedia\u003c/span\u003e\u003c/span\u003e\u003c/a\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 110.075px 8px; transform-origin: 110.075px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e, the cages are indicated by colors. \u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 105px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 52.5px; text-align: left; transform-origin: 384px 52.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 372.65px 8px; transform-origin: 372.65px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eSolving Killer Sudoku with few (or no) given digits requires ready ideas of how to make particular sums. A two-digit cage with a sum of 3 can contain only 1 and 2, and a two-digit cage with a sum of 4 can contain only 1 and 3 because 2 cannot be repeated. A three-digit cage with a sum of 21 can have some arrangement of [9 8 4], [9 7 5], or [8 7 6]. The three-digit cage summing to 17 in the central box of the example has seven possible sets, but if the box already has an 8 outside the 17-cage, then only four of those sets are possible: [9 7 1], [9 6 2], [9 5 3], [7 6 4].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 105px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 52.5px; text-align: left; transform-origin: 384px 52.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 383.75px 8px; transform-origin: 383.75px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eWrite a function to list the ways to make a sum with a given number of digits. If only two arguments are given, then all of the digits 1-9 are possible. If a third argument is given, then it indicates the digits that cannot be used. The output should be a matrix in which the digits decrease along the rows and the rows are sorted in decreasing order of the first digit, then the second digit, then the third, etc., as in the examples. List only one arrangement: in the last example above, only [9 7 1] is given, not [9 1 7], [7 9 1], [7 1 9], [1 9 7], and [1 7 9]. If the sum cannot be made, return [].\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 261.7px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 130.85px; text-align: left; transform-origin: 384px 130.85px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cimg class=\"imageNode\" width=\"256\" height=\"256\" style=\"vertical-align: baseline;width: 256px;height: 256px\" src=\"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Killersudoku_color.svg/1024px-Killersudoku_color.svg.png\" data-image-state=\"image-loaded\"\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function y = makesum(varargin)\r\n% Argument 1 is the target sum, and argument 2 is the number of digits to be used in the sum.\r\n% If given, argument 3 lists the digits to exclude from the sum.\r\n  y = sum(randi(9,n));\r\nend","test_suite":"%%\r\nx = randi(9);\r\nn = 1;\r\ny = makesum(x,n);\r\ny_correct = x;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 3;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [2 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 4;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [3 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 5;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [4 1; 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 6;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [5 1; 4 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 7;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [6 1; 5 2; 4 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 8;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [7 1; 6 2; 5 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 9;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [8 1; 7 2; 6 3; 5 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 10;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 1; 8 2; 7 3; 6 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 11;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 2; 8 3; 7 4; 6 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 12;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 3; 8 4; 7 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 13;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 4; 8 5; 7 6];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 14;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 5; 8 6];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 15;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 6; 8 7];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 16;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 7];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 17;\r\nn = 2;\r\ny = makesum(x,n);\r\ny_correct = [9 8];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 17;\r\nn = 2;\r\nd = [];\r\ny = makesum(x,n,d);\r\ny_correct = [9 8];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 17;\r\nn = 2;\r\nd = [1 2];\r\ny = makesum(x,n,d);\r\ny_correct = [9 8];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 6;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [3 2 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 7;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [4 2 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 8;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [5 2 1; 4 3 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 8;\r\nn = 3;\r\nd = 2;\r\ny = makesum(x,n,d);\r\ny_correct = [4 3 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 9;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [6 2 1; 5 3 1; 4 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 10;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [7 2 1; 6 3 1; 5 4 1; 5 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 11;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [8 2 1; 7 3 1; 6 4 1; 6 3 2; 5 4 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 12;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 2 1; 8 3 1; 7 4 1; 7 3 2; 6 5 1; 6 4 2; 5 4 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 13;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 3 1; 8 4 1; 8 3 2; 7 5 1; 7 4 2; 6 5 2; 6 4 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 13;\r\nn = 3;\r\nd = [1 3];\r\ny = makesum(x,n,d);\r\ny_correct = [7 4 2; 6 5 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 14;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 4 1; 9 3 2; 8 5 1; 8 4 2; 7 6 1; 7 5 2; 7 4 3; 6 5 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 15;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 5 1; 9 4 2; 8 6 1; 8 5 2; 8 4 3; 7 6 2; 7 5 3; 6 5 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 16;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 6 1; 9 5 2; 9 4 3; 8 7 1; 8 6 2; 8 5 3; 7 6 3; 7 5 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 16;\r\nn = 3;\r\nd = 3;\r\ny = makesum(x,n,d);\r\ny_correct = [9 6 1; 9 5 2; 8 7 1; 8 6 2; 7 5 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 17;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 7 1; 9 6 2; 9 5 3; 8 7 2; 8 6 3; 8 5 4; 7 6 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 18;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 8 1; 9 7 2; 9 6 3; 9 5 4; 8 7 3; 8 6 4; 7 6 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 19;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 8 2; 9 7 3; 9 6 4; 8 7 4; 8 6 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 20;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 8 3; 9 7 4; 9 6 5; 8 7 5];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 21;\r\nn = 3;\r\ny = makesum(x,n);\r\ny_correct = [9 8 4; 9 7 5; 8 7 6];\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nx = 21;\r\nn = 3;\r\nd = 7;\r\ny = makesum(x,n,d);\r\ny_correct = [9 8 4];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 10;\r\nn = 4;\r\ny = makesum(x,n);\r\ny_correct = [4 3 2 1];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 16;\r\nn = 4;\r\ny = makesum(x,n);\r\ny_correct = [9 4 2 1; 8 5 2 1; 8 4 3 1; 7 6 2 1; 7 5 3 1; 7 4 3 2; 6 5 4 1; 6 5 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 21;\r\nn = 4;\r\ny = makesum(x,n);\r\ny_correct = [9 8 3 1; 9 7 4 1; 9 7 3 2; 9 6 5 1; 9 6 4 2; 9 5 4 3; 8 7 5 1; 8 7 4 2; 8 6 5 2; 8 6 4 3; 7 6 5 3];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 21;\r\nn = 4;\r\nd = [1 3];\r\ny = makesum(x,n,d);\r\ny_correct = [9 6 4 2; 8 7 4 2; 8 6 5 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 40;\r\nn = 6;\r\ny = makesum(x,n);\r\nassert(isempty(y))\r\n\r\n%% \r\nx = 40;\r\nn = 7;\r\ny = makesum(x,n);\r\ny_correct = [9 8 7 6 5 4 1; 9 8 7 6 5 3 2];\r\nassert(isequal(y,y_correct))\r\n\r\n%% \r\nx = 45;\r\nn = 9;\r\ny = makesum(x,n);\r\ny_correct = 9:-1:1;\r\nassert(isequal(y,y_correct))\r\n\r\n%%\r\nfiletext = fileread('makesum.m');\r\nillegal = contains(filetext, 'assignin') || contains(filetext, 'assert'); \r\nassert(~illegal)","published":true,"deleted":false,"likes_count":1,"comments_count":0,"created_by":46909,"edited_by":46909,"edited_at":"2024-01-22T12:22:39.000Z","deleted_by":null,"deleted_at":null,"solvers_count":3,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2024-01-22T05:25:55.000Z","updated_at":"2024-01-22T12:22:39.000Z","published_at":"2024-01-22T05:32:13.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\u003eIn Sudoku, the subject of \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://www.mathworks.com/matlabcentral/cody/problems?term=sudoku\u0026amp;submitsearch=\\\"\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:u/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eseveral Cody problems\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, one tries to arrange the digits 1 through 9 in a 9x9 grid of 81 cells (or a 3x3 arrangement of nine 3x3 boxes) so that every row, column, and 3x3 box contains each digit exactly once. In the variant Killer Sudoku, digits are placed in cages that indicate the sum of the digits; digits cannot be repeated in cages. In the example below from \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:hyperlink w:docLocation=\\\"https://en.wikipedia.org/wiki/Killer_sudoku\\\"\u003e\u003cw:r\u003e\u003cw:t\u003eWikipedia\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e, the cages are indicated by colors. \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\u003eSolving Killer Sudoku with few (or no) given digits requires ready ideas of how to make particular sums. A two-digit cage with a sum of 3 can contain only 1 and 2, and a two-digit cage with a sum of 4 can contain only 1 and 3 because 2 cannot be repeated. A three-digit cage with a sum of 21 can have some arrangement of [9 8 4], [9 7 5], or [8 7 6]. The three-digit cage summing to 17 in the central box of the example has seven possible sets, but if the box already has an 8 outside the 17-cage, then only four of those sets are possible: [9 7 1], [9 6 2], [9 5 3], [7 6 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\u003eWrite a function to list the ways to make a sum with a given number of digits. If only two arguments are given, then all of the digits 1-9 are possible. If a third argument is given, then it indicates the digits that cannot be used. The output should be a matrix in which the digits decrease along the rows and the rows are sorted in decreasing order of the first digit, then the second digit, then the third, etc., as in the examples. List only one arrangement: in the last example above, only [9 7 1] is given, not [9 1 7], [7 9 1], [7 1 9], [1 9 7], and [1 7 9]. If the sum cannot be made, return [].\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:customXml w:element=\\\"image\\\"\u003e\u003cw:customXmlPr\u003e\u003cw:attr w:name=\\\"height\\\" w:val=\\\"256\\\"/\u003e\u003cw:attr w:name=\\\"width\\\" w:val=\\\"256\\\"/\u003e\u003cw:attr w:name=\\\"verticalAlign\\\" w:val=\\\"baseline\\\"/\u003e\u003cw:attr w:name=\\\"altText\\\" w:val=\\\"\\\"/\u003e\u003cw:attr w:name=\\\"relationshipId\\\" w:val=\\\"rId1\\\"/\u003e\u003c/w:customXmlPr\u003e\u003c/w:customXml\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\",\"relationship\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/image\",\"target\":\"/media/image1.png\",\"relationshipId\":\"rId1\"}]},{\"partUri\":\"/media/image1.png\",\"contentType\":\"image/png\",\"content\":\"https://upload.wikimedia.org/wikipedia/commons/thumb/5/5e/Killersudoku_color.svg/1024px-Killersudoku_color.svg.png\",\"relationship\":null}],\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"target\":\"/matlab/document.xml\",\"relationshipId\":\"rId1\"}]}"}],"term":"tag:\"partition\"","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:\"partition\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"partition\"","","\"","partition","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f3035215518\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f3035215478\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f3035214bb8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f3035215798\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f30352156f8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f3035215658\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f30352155b8\u003e":"tag:\"partition\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f30352155b8\u003e":"tag:\"partition\""},"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:\"partition\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"partition\"","","\"","partition","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f3035215518\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f3035215478\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f3035214bb8\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f3035215798\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f30352156f8\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f3035215658\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f30352155b8\u003e":"tag:\"partition\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f30352155b8\u003e":"tag:\"partition\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":2248,"difficulty_rating":"easy-medium"},{"id":59586,"difficulty_rating":"medium"}]}}