{"group":{"group":{"id":5,"name":"Tiles Challenge","lockable":false,"created_at":"2012-03-27T14:48:44.000Z","updated_at":"2025-12-14T01:33:56.000Z","description":"Problems inspired by edge-matching puzzles, in which polygons edges, distinguished with colors or patterns, are tiled so that edges of adjacent tiles match.","is_default":false,"created_by":7,"badge_id":15,"featured":false,"trending":false,"solution_count_in_trending_period":85,"trending_last_calculated":"2025-12-14T00:00:00.000Z","image_id":2,"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":"{\"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\u003eProblems inspired by edge-matching puzzles, in which polygons edges, distinguished with colors or patterns, are tiled so that edges of adjacent tiles match.\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\"}]}","description_html":"\u003cdiv style = \"text-align: start; line-height: normal; 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=\"display: block; min-width: 0px; padding-top: 0px; perspective-origin: 289.5px 21px; transform-origin: 289.5px 21px; \"\u003e\u003cdiv style=\"font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-bottom: 9px; margin-left: 4px; margin-right: 10px; margin-top: 2px; text-align: left; white-space: pre-wrap; perspective-origin: 266.5px 21px; transform-origin: 266.5px 21px; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"display: inline; margin-bottom: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 0px 0px; transform-origin: 0px 0px; \"\u003e\u003cspan style=\"\"\u003eProblems inspired by edge-matching puzzles, in which polygons edges, distinguished with colors or patterns, are tiled so that edges of adjacent tiles match.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","published_at":"2017-09-28T03:17:50.000Z"},"current_player":null},"problems":[{"id":470,"title":"Scoring for oriented dominoes","description":"Given a list of ordered pairs, and the order they should be placed in a line, find the sum of the absolute values of the differences.\r\n\r\n  list = [1 2\r\n          5 3\r\n          2 4\r\n  \r\n  order = [1 3 2]\r\n  \r\n  yields: [1 2][2 4][5 3]\r\n      or: abs(2-2) + abs(4-5)\r\n      or:        0 + 1\r\n      or: 1\r\n","description_html":"\u003cp\u003eGiven a list of ordered pairs, and the order they should be placed in a line, find the sum of the absolute values of the differences.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003elist = [1 2\r\n        5 3\r\n        2 4\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eorder = [1 3 2]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eyields: [1 2][2 4][5 3]\r\n    or: abs(2-2) + abs(4-5)\r\n    or:        0 + 1\r\n    or: 1\r\n\u003c/pre\u003e","function_template":"function score = scoreOrderedDominoes(list, order)\r\n  y = 0;\r\nend","test_suite":"%%\r\nlist  = [1 2; 5 4; 2 4];\r\norder = [1 3 2];\r\ny_correct = 1;\r\nassert(isequal(scoreOrderedDominoes(list, order),y_correct))\r\n\r\n%%\r\nlist = [1 2; 5 4; 2 4];\r\norder = [2 1 3];\r\ny_correct = 3;\r\nassert(isequal(scoreOrderedDominoes(list, order),y_correct))\r\n\r\n%%\r\nlist = [1 2; 5 4; 2 4; 1 6; 7 5; 4 5; 4 8];\r\norder = [2 1 3 7 4 6 5];\r\ny_correct = 14;\r\nassert(isequal(scoreOrderedDominoes(list, order),y_correct))\r\n\r\n%%\r\nlist = [1 2; 6 6; 2 4];\r\norder = [2 1 3];\r\ny_correct = 5;\r\nassert(isequal(scoreOrderedDominoes(list, order),y_correct))\r\n\r\n%%\r\nlist = [1 2; 5 4; 2 4];\r\norder = [1 2 3];\r\ny_correct = 5;\r\nassert(isequal(scoreOrderedDominoes(list, order),y_correct))","published":true,"deleted":false,"likes_count":13,"comments_count":3,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":901,"test_suite_updated_at":"2012-03-08T19:58:01.000Z","rescore_all_solutions":false,"group_id":5,"created_at":"2012-03-08T19:58:01.000Z","updated_at":"2026-02-19T11:42:44.000Z","published_at":"2012-04-03T18:00:29.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a list of ordered pairs, and the order they should be placed in a line, find the sum of the absolute values of the differences.\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[list = [1 2\\n        5 3\\n        2 4\\n\\norder = [1 3 2]\\n\\nyields: [1 2][2 4][5 3]\\n    or: abs(2-2) + abs(4-5)\\n    or:        0 + 1\\n    or: 1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":487,"title":"Find perfect placement of non-rotating dominoes (easier)","description":"Given a list of ordered pairs, find the order they should be placed in a line, such that the sum of the absolute values of the differences is zero.\r\n\r\n  list = [1 2\r\n          4 3\r\n          2 4\r\n  \r\n  order = [1 3 2]\r\n  \r\n  yields: [1 2][2 4][4 3]\r\n      or: abs(2-2) + abs(4-4)\r\n      or:        0 + 0\r\n      or: 0\r\n\r\nThere is a unique solution to this problem where the final score is zero.\r\n","description_html":"\u003cp\u003eGiven a list of ordered pairs, find the order they should be placed in a line, such that the sum of the absolute values of the differences is zero.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003elist = [1 2\r\n        4 3\r\n        2 4\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eorder = [1 3 2]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eyields: [1 2][2 4][4 3]\r\n    or: abs(2-2) + abs(4-4)\r\n    or:        0 + 0\r\n    or: 0\r\n\u003c/pre\u003e\u003cp\u003eThere is a unique solution to this problem where the final score is zero.\u003c/p\u003e","function_template":"function order = findPerfectOrderedDominoes(list)\r\n  order = 0;\r\nend","test_suite":"clear\r\nclc\r\n\r\n%%\r\nlist  = [     1     5\r\n              2     1\r\n              2     2\r\n              3     2\r\n              4     8\r\n              5     4\r\n              5     5\r\n             10     3];\r\n         \r\ncorrect = [8     4     3     2     1     7     6     5];\r\n    \r\nassert(isequal(findPerfectOrderedDominoes(list),correct))\r\n%%\r\nlist  = [ 1     6\r\n          2     2\r\n          2     7\r\n          7     1\r\n          7     8\r\n          8    10\r\n         10     2\r\n         10    10];\r\n         \r\ncorrect = [5     6     8     7     2     3     4     1];\r\n    \r\nassert(isequal(findPerfectOrderedDominoes(list),correct))\r\n\r\n%%\r\nlist  = [1     1\r\n         1     7\r\n         2     4\r\n         4     6\r\n         5     1\r\n         6     2\r\n         7     4\r\n         7     5];\r\n         \r\ncorrect = [8     5     1     2     7     4     6     3];\r\n    \r\nassert(isequal(findPerfectOrderedDominoes(list),correct))\r\n\r\n%%\r\nlist  = [1    10\r\n         3    10\r\n         5     3\r\n         6     9\r\n         7     6\r\n         8     7\r\n         8     8\r\n         9     1\r\n        10     5];\r\n         \r\ncorrect = [7 6 5     4     8     1     9     3     2];\r\n    \r\nassert(isequal(findPerfectOrderedDominoes(list),correct))","published":true,"deleted":false,"likes_count":7,"comments_count":3,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":383,"test_suite_updated_at":"2012-03-12T19:51:28.000Z","rescore_all_solutions":false,"group_id":5,"created_at":"2012-03-12T19:23:10.000Z","updated_at":"2026-03-10T19:09:06.000Z","published_at":"2012-04-03T18:00:29.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a list of ordered pairs, find the order they should be placed in a line, such that the sum of the absolute values of the differences is zero.\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[list = [1 2\\n        4 3\\n        2 4\\n\\norder = [1 3 2]\\n\\nyields: [1 2][2 4][4 3]\\n    or: abs(2-2) + abs(4-4)\\n    or:        0 + 0\\n    or: 0]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThere is a unique solution to this problem where the final score is zero.\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":492,"title":"Find best placement for ordered dominoes (harder)","description":"Given a list of ordered pairs, find the order they should be placed in a line, such that the sum of the absolute values of the differences is *minimized*.\r\n\r\n  list = [1 2\r\n          5 3\r\n          2 4\r\n  \r\n  order = [1 3 2]\r\n  \r\n  yields: [1 2][2 4][5 3]\r\n      or: abs(2-2) + abs(4-5)\r\n      or:        0 + 1\r\n      or: 1\r\n\r\nThere is a unique best solution, but the score is NOT always zero.\r\n","description_html":"\u003cp\u003eGiven a list of ordered pairs, find the order they should be placed in a line, such that the sum of the absolute values of the differences is \u003cb\u003eminimized\u003c/b\u003e.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003elist = [1 2\r\n        5 3\r\n        2 4\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eorder = [1 3 2]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eyields: [1 2][2 4][5 3]\r\n    or: abs(2-2) + abs(4-5)\r\n    or:        0 + 1\r\n    or: 1\r\n\u003c/pre\u003e\u003cp\u003eThere is a unique best solution, but the score is NOT always zero.\u003c/p\u003e","function_template":"function order = findBestOrderedDominoes(list)\r\n  order = 0;\r\nend","test_suite":"%%\r\nlist  = [4     1\r\n         3     4\r\n         1     1\r\n         5     5\r\n         3     5\r\n         0     4\r\n         2     0];\r\n         %2\r\ncorrect = [2     1     3     7     6     5     4];\r\n    \r\nassert(isequal(findBestOrderedDominoes(list),correct))\r\n\r\n%%\r\nlist  = [1     1\r\n         2     5\r\n         7     5\r\n         8     1\r\n         1     3\r\n         7     8\r\n         3     6];\r\n         %3\r\ncorrect = [2     6     4     1     5     7     3];\r\n    \r\nassert(isequal(findBestOrderedDominoes(list),correct))\r\n\r\n\r\n%%\r\nlist  = [8     5\r\n         3     9\r\n        10     6\r\n         6     2\r\n         2    17\r\n        18    14\r\n         9     5];\r\n         %6\r\ncorrect = [3     1     2     7     4     5     6];\r\n    \r\nassert(isequal(findBestOrderedDominoes(list),correct))","published":true,"deleted":false,"likes_count":2,"comments_count":0,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":346,"test_suite_updated_at":"2012-03-13T16:14:19.000Z","rescore_all_solutions":false,"group_id":5,"created_at":"2012-03-13T16:14:19.000Z","updated_at":"2026-03-10T20:24:23.000Z","published_at":"2012-04-03T18:00:29.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a list of ordered pairs, find the order they should be placed in a line, such that the sum of the absolute values of the differences is\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e \u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eminimized\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[list = [1 2\\n        5 3\\n        2 4\\n\\norder = [1 3 2]\\n\\nyields: [1 2][2 4][5 3]\\n    or: abs(2-2) + abs(4-5)\\n    or:        0 + 1\\n    or: 1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThere is a unique best solution, but the score is NOT always zero.\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":520,"title":"Choose the best fitting dominoes","description":"You will be given a cell array of nx2 matrices. Choose one row from each matrix. These are the ordered pairs that will be placed in a line like this.\r\n{[1 2  [4 5 [0 4\r\n  3 5   2 4  3 2\r\n  1 5]  5 1] 5 3]}\r\nChoices might be: [1 2 3]\r\nyields: [1 2][2 4][5 3]\r\n    or: abs(2-2) + abs(4-5)\r\n    or:        0 + 1\r\n    or: 1\r\nYou are trying to minimize the score, the absolute difference of the sum of the difference at the intersections.","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: 267.033px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 133.517px; transform-origin: 407px 133.517px; 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: 378px 8px; transform-origin: 378px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYou will be given a cell array of nx2 matrices. Choose one row from each matrix. These are the ordered pairs that will be placed in a line like this.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; 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 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 64px 8.5px; tab-size: 4; transform-origin: 64px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e{[1 2  [4 5 [0 4\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 64px 8.5px; tab-size: 4; transform-origin: 64px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e  3 5   2 4  3 2\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e  1 5]  5 1] 5 3]}\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 78.5px 8px; transform-origin: 78.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eChoices might be: [1 2 3]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 92px 8.5px; tab-size: 4; transform-origin: 92px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eyields: [1 2][2 4][5 3]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 108px 8.5px; tab-size: 4; transform-origin: 108px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e    or: abs(2-2) + abs(4-5)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 80px 8.5px; tab-size: 4; transform-origin: 80px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e    or:        0 + 1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 36px 8.5px; tab-size: 4; transform-origin: 36px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e    or: 1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 341px 8px; transform-origin: 341px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYou are trying to minimize the score, the absolute difference of the sum of the difference at the intersections.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function order = ChooseBestFittingDominoes(list)\r\n  order = 1;\r\nend","test_suite":"%%\r\nlist = {[1 3; 2 4; 5 6],[4 6; 2 5;6 7],[3 4; 6 1; 4 6]}\r\n\r\nselections = [2 1 2];\r\n\r\nassert(isequal(ChooseBestFittingDominoes(list),selections))\r\n\r\n\r\n%%\r\nlist = {[1 5; 2 3; 2 2; 3 4; 0 3], \r\n        [0 4; 1 5; 2 2; 4 5; 4 6],\r\n        [7 7; 3 8; 4 7; 5 9; 0 4]};\r\n    \r\nselections = [4 4 4];\r\n\r\nassert(isequal(ChooseBestFittingDominoes(list),selections))\r\n\r\n%%\r\nlist = {[1 4; 2 2; 1 1; 3 3],[1 2; 2 3],[2 2]};\r\n\r\nselections = [3 1 1];\r\n\r\nassert(isequal(ChooseBestFittingDominoes(list),selections))\r\n\r\n%%\r\nlist = {[3 4; 1 2; 5 6],[5 7; 11 13; 17 19; 29 31; 2 3]};\r\n    \r\nselections = [2 5];\r\n\r\nassert(isequal(ChooseBestFittingDominoes(list),selections))","published":true,"deleted":false,"likes_count":3,"comments_count":3,"created_by":240,"edited_by":223089,"edited_at":"2022-12-28T15:22:04.000Z","deleted_by":null,"deleted_at":null,"solvers_count":243,"test_suite_updated_at":"2022-12-28T15:22:04.000Z","rescore_all_solutions":false,"group_id":5,"created_at":"2012-03-22T17:38:21.000Z","updated_at":"2026-02-19T11:48:16.000Z","published_at":"2012-04-03T18:00:30.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be given a cell array of nx2 matrices. Choose one row from each matrix. These are the ordered pairs that will be placed in a line like this.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[{[1 2  [4 5 [0 4\\n  3 5   2 4  3 2\\n  1 5]  5 1] 5 3]}]]\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\u003eChoices might be: [1 2 3]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[yields: [1 2][2 4][5 3]\\n    or: abs(2-2) + abs(4-5)\\n    or:        0 + 1\\n    or: 1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou are trying to minimize the score, the absolute difference of the sum of the difference at the intersections.\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":534,"title":"Find best domino orientation","description":"Given a list of pairs, find the orientation they should be placed in a line, such that the sum of the absolute values of the differences is zero.\r\n\r\nZero means do not invert, One means invert in the order vector.\r\n\r\n  list = [1 2\r\n          4 2\r\n          2 3\r\n  \r\n  order = [0 1 1]\r\n  \r\n  yields: [1 2][2 4][3 2]\r\n      or: abs(2-2) + abs(4-3)\r\n      or:        0 + 1\r\n      or: 1\r\n\r\nThere is a unique solution to this problem where the final score is minimized.","description_html":"\u003cp\u003eGiven a list of pairs, find the orientation they should be placed in a line, such that the sum of the absolute values of the differences is zero.\u003c/p\u003e\u003cp\u003eZero means do not invert, One means invert in the order vector.\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003elist = [1 2\r\n        4 2\r\n        2 3\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eorder = [0 1 1]\r\n\u003c/pre\u003e\u003cpre class=\"language-matlab\"\u003eyields: [1 2][2 4][3 2]\r\n    or: abs(2-2) + abs(4-3)\r\n    or:        0 + 1\r\n    or: 1\r\n\u003c/pre\u003e\u003cp\u003eThere is a unique solution to this problem where the final score is minimized.\u003c/p\u003e","function_template":"function orientation = findBestDominoeOrientation(list)\r\n  y = [];\r\nend","test_suite":"%%\r\nlist =  [5     2\r\n         3     7\r\n         4     9\r\n         2     3\r\n         8     2\r\n         3     5\r\n         8     2\r\n         7     8\r\n         4     2\r\n         8     2];\r\ny_correct = [0 0 1 1 1 1 1 1 0 1];\r\nassert(isequal(findBestDominoeOrientation(list),y_correct))\r\n\r\n%%\r\nlist =  [0     8\r\n         4     8\r\n         2     0\r\n         8     0\r\n         5     7\r\n         7     2\r\n         1     6\r\n         2     6\r\n         2     7\r\n         0     2];\r\ny_correct = [0 1 0 1 1 1 1 0 1 1];\r\nassert(isequal(findBestDominoeOrientation(list),y_correct))\r\n\r\n%%\r\nlist =  [7     5\r\n         3     1\r\n         5     1\r\n         6     5\r\n         4     8\r\n         2     6\r\n         5     1\r\n         1     3\r\n         5     9\r\n         9     2\r\n         0     7\r\n         1     7];\r\ny_correct = [0 0 1 1 1 0 0 0 0 0 0 1];\r\nassert(isequal(findBestDominoeOrientation(list),y_correct))\r\n\r\n%%\r\nlist =  [0     4\r\n         0     3\r\n         8     2\r\n         2     5];\r\ny_correct = [1 0 1 1];\r\nassert(isequal(findBestDominoeOrientation(list),y_correct))","published":true,"deleted":false,"likes_count":3,"comments_count":5,"created_by":240,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":278,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":5,"created_at":"2012-03-27T17:33:43.000Z","updated_at":"2026-03-11T15:55:08.000Z","published_at":"2012-04-04T13:14:23.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eGiven a list of pairs, find the orientation they should be placed in a line, such that the sum of the absolute values of the differences is zero.\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\u003eZero means do not invert, One means invert in the order vector.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[list = [1 2\\n        4 2\\n        2 3\\n\\norder = [0 1 1]\\n\\nyields: [1 2][2 4][3 2]\\n    or: abs(2-2) + abs(4-3)\\n    or:        0 + 1\\n    or: 1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThere is a unique solution to this problem where the final score is minimized.\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":535,"title":"Rotate and display numbered tile","description":"Imagine a square tile with four numbers on it, one on each edge. We will call these edges north, east, south, and west.\r\n\r\nIf the four numbers were [1 5 7 9], this vector would be displayed with the numbers going around clockwise from the north like so:\r\n\r\n    1  \r\n  9   5\r\n    7  \r\n\r\nBut the tile can appear in four different orientations. Let's say that when the north is 1, then the first number appears in the north position. If north is 2, then the second number appears in the north position, and so on. So if the tile numbers are [1 5 7 9] and the orientation parameter north is 3, then it would display like so, since 7 is the third number:\r\n\r\n    7  \r\n  5   9\r\n    1  \r\n\r\nThe numbers you are given will always be one or two digit positive integers. You must return a 3-by-6 character array that fits this template:\r\n\r\n  ..NN..\r\n  WW..EE\r\n  ..SS..\r\n\r\nwhere dots are used to indicate spaces (ASCII 32). One digit numbers should be right aligned. In the example given immediately above, the output should look like this:\r\n\r\n Inputs t = [1 5 7 9], north = 3\r\n Output is  ['   7  '\r\n             ' 5   9'\r\n             '   1  ']\r\n","description_html":"\u003cp\u003eImagine a square tile with four numbers on it, one on each edge. We will call these edges north, east, south, and west.\u003c/p\u003e\u003cp\u003eIf the four numbers were [1 5 7 9], this vector would be displayed with the numbers going around clockwise from the north like so:\u003c/p\u003e\u003cpre\u003e    1  \r\n  9   5\r\n    7  \u003c/pre\u003e\u003cp\u003eBut the tile can appear in four different orientations. Let's say that when the north is 1, then the first number appears in the north position. If north is 2, then the second number appears in the north position, and so on. So if the tile numbers are [1 5 7 9] and the orientation parameter north is 3, then it would display like so, since 7 is the third number:\u003c/p\u003e\u003cpre\u003e    7  \r\n  5   9\r\n    1  \u003c/pre\u003e\u003cp\u003eThe numbers you are given will always be one or two digit positive integers. You must return a 3-by-6 character array that fits this template:\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e..NN..\r\nWW..EE\r\n..SS..\r\n\u003c/pre\u003e\u003cp\u003ewhere dots are used to indicate spaces (ASCII 32). One digit numbers should be right aligned. In the example given immediately above, the output should look like this:\u003c/p\u003e\u003cpre\u003e Inputs t = [1 5 7 9], north = 3\r\n Output is  ['   7  '\r\n             ' 5   9'\r\n             '   1  ']\u003c/pre\u003e","function_template":"function td = rotate_tile(t, north)\r\n  t = '';\r\nend","test_suite":"%%\r\nt = [1 5 7 9];\r\nnorth = 3;\r\ntd = ['   7  '\r\n      ' 5   9'\r\n      '   1  '];\r\nassert(isequal(rotate_tile(t, north),td))\r\n\r\n%%\r\nt = [27 8 5 46];\r\nnorth = 4;\r\ntd = ['  46  '\r\n      ' 5  27'\r\n      '   8  '];\r\nassert(isequal(rotate_tile(t, north),td))\r\n\r\n%%\r\nt = [9 57 75 9];\r\nnorth = 2;\r\ntd = ['  57  '\r\n      ' 9  75'\r\n      '   9  '];\r\nassert(isequal(rotate_tile(t, north),td))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":379,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":5,"created_at":"2012-03-28T20:27:56.000Z","updated_at":"2026-03-10T19:23:07.000Z","published_at":"2012-04-03T18:00:30.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eImagine a square tile with four numbers on it, one on each edge. We will call these edges north, east, south, and west.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIf the four numbers were [1 5 7 9], this vector would be displayed with the numbers going around clockwise from the north like so:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[    1  \\n  9   5\\n    7]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBut the tile can appear in four different orientations. Let's say that when the north is 1, then the first number appears in the north position. If north is 2, then the second number appears in the north position, and so on. So if the tile numbers are [1 5 7 9] and the orientation parameter north is 3, then it would display like so, since 7 is the third number:\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[    7  \\n  5   9\\n    1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThe numbers you are given will always be one or two digit positive integers. You must return a 3-by-6 character array that fits this template:\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[..NN..\\nWW..EE\\n..SS..]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ewhere dots are used to indicate spaces (ASCII 32). One digit numbers should be right aligned. In the example given immediately above, the output should look like this:\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[ Inputs t = [1 5 7 9], north = 3\\n Output is  ['   7  '\\n             ' 5   9'\\n             '   1  ']]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"},{"id":556,"title":"Stuff the Board","description":"You have a stack of tiles to put onto an array-like playing board. Each tile has a number (always an integer), and the board varies in size (you are given dimensions nRows and nCols). You need to put the high-value tiles on the table in any order.\r\n\r\nWhat you return is an array the same size as the board in which each element is a index to an element of the original vector of tiles.\r\n\r\nExamples:\r\n\r\n Input tiles = [7 12 8 6 9]\r\n       nRows = 2\r\n       nCols = 2\r\n Output is [ 1 2\r\n             3 5 ]\r\n\r\nThe numbers in the output matrix can appear in any order. What matters is that the indices [1 2 3 5] do appear and that the index 4 does not appear (since tiles(4) is the lowest number).\r\n\r\n Input tiles = [12  6  1 20 18  7  4 17]\r\n       nRows = 3\r\n       nCols = 2\r\n Output is [ 2 6\r\n             4 8\r\n             1 5 ]\r\n\r\n","description_html":"\u003cp\u003eYou have a stack of tiles to put onto an array-like playing board. Each tile has a number (always an integer), and the board varies in size (you are given dimensions nRows and nCols). You need to put the high-value tiles on the table in any order.\u003c/p\u003e\u003cp\u003eWhat you return is an array the same size as the board in which each element is a index to an element of the original vector of tiles.\u003c/p\u003e\u003cp\u003eExamples:\u003c/p\u003e\u003cpre\u003e Input tiles = [7 12 8 6 9]\r\n       nRows = 2\r\n       nCols = 2\r\n Output is [ 1 2\r\n             3 5 ]\u003c/pre\u003e\u003cp\u003eThe numbers in the output matrix can appear in any order. What matters is that the indices [1 2 3 5] do appear and that the index 4 does not appear (since tiles(4) is the lowest number).\u003c/p\u003e\u003cpre\u003e Input tiles = [12  6  1 20 18  7  4 17]\r\n       nRows = 3\r\n       nCols = 2\r\n Output is [ 2 6\r\n             4 8\r\n             1 5 ]\u003c/pre\u003e","function_template":"function board = fill_board(tiles,nRows,nCols)\r\n  board = 0;\r\nend","test_suite":"%%\r\ntiles = [7 12 8 6 9];\r\nnRows = 2;\r\nnCols = 2;\r\n\r\nomit = 6;\r\nboard = fill_board(tiles,nRows,nCols);\r\ntiles_used = tiles(board(:));\r\nassert(isequal(setdiff(tiles,tiles_used),omit))\r\n\r\n%%\r\ntiles = [12  6  1 20 18  7  4 17];\r\nnRows = 3;\r\nnCols = 2;\r\n\r\nomit = [1 4];\r\nboard = fill_board(tiles,nRows,nCols);\r\ntiles_used = tiles(board(:));\r\nassert(isequal(setdiff(tiles,tiles_used),omit))\r\n\r\n%%\r\ntiles = [2 10 25 38 39 5 24 14 4];\r\nnRows = 2;\r\nnCols = 3;\r\n\r\nomit = [2 4 5];\r\nboard = fill_board(tiles,nRows,nCols);\r\ntiles_used = tiles(board(:));\r\nassert(isequal(setdiff(tiles,tiles_used),omit))\r\n","published":true,"deleted":false,"likes_count":9,"comments_count":4,"created_by":7,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":581,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":5,"created_at":"2012-04-03T17:56:24.000Z","updated_at":"2026-03-10T18:20:00.000Z","published_at":"2012-04-03T18:00:30.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou have a stack of tiles to put onto an array-like playing board. Each tile has a number (always an integer), and the board varies in size (you are given dimensions nRows and nCols). You need to put the high-value tiles on the table in any order.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eWhat you return is an array the same size as the board in which each element is a index to an element of the original vector of tiles.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExamples:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input tiles = [7 12 8 6 9]\\n       nRows = 2\\n       nCols = 2\\n Output is [ 1 2\\n             3 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\u003eThe numbers in the output matrix can appear in any order. What matters is that the indices [1 2 3 5] do appear and that the index 4 does not appear (since tiles(4) is the lowest number).\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ Input tiles = [12  6  1 20 18  7  4 17]\\n       nRows = 3\\n       nCols = 2\\n Output is [ 2 6\\n             4 8\\n             1 5 ]]]\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":520,"title":"Choose the best fitting dominoes","description":"You will be given a cell array of nx2 matrices. Choose one row from each matrix. These are the ordered pairs that will be placed in a line like this.\r\n{[1 2  [4 5 [0 4\r\n  3 5   2 4  3 2\r\n  1 5]  5 1] 5 3]}\r\nChoices might be: [1 2 3]\r\nyields: [1 2][2 4][5 3]\r\n    or: abs(2-2) + abs(4-5)\r\n    or:        0 + 1\r\n    or: 1\r\nYou are trying to minimize the score, the absolute difference of the sum of the difference at the intersections.","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: 267.033px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 133.517px; transform-origin: 407px 133.517px; 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: 378px 8px; transform-origin: 378px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYou will be given a cell array of nx2 matrices. Choose one row from each matrix. These are the ordered pairs that will be placed in a line like this.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 61.3px; 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 30.65px; transform-origin: 404px 30.65px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 64px 8.5px; tab-size: 4; transform-origin: 64px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e{[1 2  [4 5 [0 4\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 64px 8.5px; tab-size: 4; transform-origin: 64px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e  3 5   2 4  3 2\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 72px 8.5px; tab-size: 4; transform-origin: 72px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e  1 5]  5 1] 5 3]}\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 78.5px 8px; transform-origin: 78.5px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eChoices might be: [1 2 3]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgb(247, 247, 247); block-size: 81.7333px; border-bottom-left-radius: 4px; border-bottom-right-radius: 4px; border-end-end-radius: 4px; border-end-start-radius: 4px; border-start-end-radius: 4px; border-start-start-radius: 4px; border-top-left-radius: 4px; border-top-right-radius: 4px; margin-block-end: 10px; margin-block-start: 10px; margin-bottom: 10px; margin-inline-end: 3px; margin-inline-start: 3px; margin-left: 3px; margin-right: 3px; margin-top: 10px; perspective-origin: 404px 40.8667px; transform-origin: 404px 40.8667px; margin-left: 3px; margin-top: 10px; margin-bottom: 10px; margin-right: 3px; \"\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 92px 8.5px; tab-size: 4; transform-origin: 92px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003eyields: [1 2][2 4][5 3]\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 108px 8.5px; tab-size: 4; transform-origin: 108px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e    or: abs(2-2) + abs(4-5)\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 80px 8.5px; tab-size: 4; transform-origin: 80px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e    or:        0 + 1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"background-color: rgba(0, 0, 0, 0); block-size: 20.4333px; border-bottom-left-radius: 0px; border-bottom-right-radius: 0px; border-end-end-radius: 0px; border-end-start-radius: 0px; border-inline-end-color: rgb(233, 233, 233); border-inline-end-style: solid; border-inline-end-width: 1px; border-inline-start-color: rgb(233, 233, 233); border-inline-start-style: solid; border-inline-start-width: 1px; border-left-color: rgb(233, 233, 233); border-left-style: solid; border-left-width: 1px; border-right-color: rgb(233, 233, 233); border-right-style: solid; border-right-width: 1px; border-start-end-radius: 0px; border-start-start-radius: 0px; border-top-left-radius: 0px; border-top-right-radius: 0px; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; min-block-size: 18px; min-height: 18px; padding-inline-start: 4px; padding-left: 4px; perspective-origin: 404px 10.2167px; transform-origin: 404px 10.2167px; white-space: nowrap; \"\u003e\u003cspan style=\"block-size: auto; border-inline-end-color: rgb(0, 0, 0); border-inline-end-style: none; border-inline-end-width: 0px; border-inline-start-color: rgb(0, 0, 0); border-inline-start-style: none; border-inline-start-width: 0px; border-left-color: rgb(0, 0, 0); border-left-style: none; border-left-width: 0px; border-right-color: rgb(0, 0, 0); border-right-style: none; border-right-width: 0px; display: inline; margin-inline-end: 45px; margin-right: 45px; min-block-size: 0px; min-height: 0px; padding-inline-start: 0px; padding-left: 0px; perspective-origin: 36px 8.5px; tab-size: 4; transform-origin: 36px 8.5px; unicode-bidi: normal; white-space: pre; margin-right: 45px; \"\u003e\u003cspan style=\"margin-inline-end: 0px; margin-right: 0px; \"\u003e    or: 1\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 10px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 10px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 10px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 341px 8px; transform-origin: 341px 8px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eYou are trying to minimize the score, the absolute difference of the sum of the difference at the intersections.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function order = ChooseBestFittingDominoes(list)\r\n  order = 1;\r\nend","test_suite":"%%\r\nlist = {[1 3; 2 4; 5 6],[4 6; 2 5;6 7],[3 4; 6 1; 4 6]}\r\n\r\nselections = [2 1 2];\r\n\r\nassert(isequal(ChooseBestFittingDominoes(list),selections))\r\n\r\n\r\n%%\r\nlist = {[1 5; 2 3; 2 2; 3 4; 0 3], \r\n        [0 4; 1 5; 2 2; 4 5; 4 6],\r\n        [7 7; 3 8; 4 7; 5 9; 0 4]};\r\n    \r\nselections = [4 4 4];\r\n\r\nassert(isequal(ChooseBestFittingDominoes(list),selections))\r\n\r\n%%\r\nlist = {[1 4; 2 2; 1 1; 3 3],[1 2; 2 3],[2 2]};\r\n\r\nselections = [3 1 1];\r\n\r\nassert(isequal(ChooseBestFittingDominoes(list),selections))\r\n\r\n%%\r\nlist = {[3 4; 1 2; 5 6],[5 7; 11 13; 17 19; 29 31; 2 3]};\r\n    \r\nselections = [2 5];\r\n\r\nassert(isequal(ChooseBestFittingDominoes(list),selections))","published":true,"deleted":false,"likes_count":3,"comments_count":3,"created_by":240,"edited_by":223089,"edited_at":"2022-12-28T15:22:04.000Z","deleted_by":null,"deleted_at":null,"solvers_count":243,"test_suite_updated_at":"2022-12-28T15:22:04.000Z","rescore_all_solutions":false,"group_id":5,"created_at":"2012-03-22T17:38:21.000Z","updated_at":"2026-02-19T11:48:16.000Z","published_at":"2012-04-03T18:00:30.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou will be given a cell array of nx2 matrices. Choose one row from each matrix. These are the ordered pairs that will be placed in a line like this.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[{[1 2  [4 5 [0 4\\n  3 5   2 4  3 2\\n  1 5]  5 1] 5 3]}]]\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\u003eChoices might be: [1 2 3]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[yields: [1 2][2 4][5 3]\\n    or: abs(2-2) + abs(4-5)\\n    or:        0 + 1\\n    or: 1]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eYou are trying to minimize the score, the absolute difference of the sum of the difference at the intersections.\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\"}]}"}],"no_progress_badge":{"id":53,"name":"Unknown","symbol":"unknown","description":"Partially completed groups","description_html":null,"image_location":"/images/responsive/supporting/matlabcentral/cody/badges/problem_groups_unknown_2.png","bonus":null,"players_count":0,"active":false,"created_by":null,"updated_by":null,"deleted_by":null,"deleted_at":null,"restored_by":null,"restored_at":null,"created_at":"2018-01-10T23:20:29.000Z","updated_at":"2018-01-10T23:20:29.000Z","community_badge_id":null,"award_multiples":false}}