{"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":486,"title":"Surface Fit z(x,y)","description":"Given three vectors x,y,z. Find four coefficients c = [cxx cxy cyy c00], such that z = cxx*x.^2+cxy*x.*y+cyy*y.^2+c00. \r\n\r\nFor example,\r\n\r\n x = [ 0  0  1  1  2  2  3  3]\r\n y = [ 0  1  0  1  0  1  0  1]\r\n z = [-4 -1 -3 -2  0 -1  5  2]\r\n\r\nthen\r\n\r\n z = x.^2-2*x.*y+3*y.^2-4 \r\n\r\nand\r\n\r\n c = [cxx cxy cyy c00] = [1 -2 3 -4]","description_html":"\u003cp\u003eGiven three vectors x,y,z. Find four coefficients c = [cxx cxy cyy c00], such that z = cxx*x.^2+cxy*x.*y+cyy*y.^2+c00.\u003c/p\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre\u003e x = [ 0  0  1  1  2  2  3  3]\r\n y = [ 0  1  0  1  0  1  0  1]\r\n z = [-4 -1 -3 -2  0 -1  5  2]\u003c/pre\u003e\u003cp\u003ethen\u003c/p\u003e\u003cpre\u003e z = x.^2-2*x.*y+3*y.^2-4 \u003c/pre\u003e\u003cp\u003eand\u003c/p\u003e\u003cpre\u003e c = [cxx cxy cyy c00] = [1 -2 3 -4]\u003c/pre\u003e","function_template":"function c = sufit(x,y,z)\r\n  cxx=0;\r\n  cxy=0;\r\n  cyy=0;\r\n  c00=0;\r\n  c=[cxx cxy cyy c00];\r\nend","test_suite":"%%\r\nx= [0 0 1 1 2 2 3 3];\r\ny= [0 1 0 1 0 1 0 1];\r\nz=[-4 -1 -3 -2 0 -1 5 2];\r\nc=[1 -2 3 -4]; \r\nassert(isequal(c,round(sufit(x,y,z))))\r\n%%\r\nx= rand(1,100);\r\ny= rand(1,100);\r\nz=7*x.^2-9*x.*y+11*y.^2-17;\r\nc=[7 -9 11 -17]; \r\nassert(isequal(c,round(sufit(x,y,z))))\r\n%%\r\nx= rand(1,10000);\r\ny= rand(1,10000);\r\nz=17*x.^2-19*x.*y+11*y.^2-13;\r\nc=[17 -19 11 -13]; \r\nassert(isequal(c,round(sufit(x,y,z))))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":46,"test_suite_updated_at":"2012-03-12T19:23:56.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-03-12T17:50:33.000Z","updated_at":"2025-12-07T17:59:24.000Z","published_at":"2012-03-19T09:01:03.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 three vectors x,y,z. Find four coefficients c = [cxx cxy cyy c00], such that z = cxx*x.^2+cxy*x.*y+cyy*y.^2+c00.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ x = [ 0  0  1  1  2  2  3  3]\\n y = [ 0  1  0  1  0  1  0  1]\\n z = [-4 -1 -3 -2  0 -1  5  2]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen\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[ z = x.^2-2*x.*y+3*y.^2-4]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ c = [cxx cxy cyy c00] = [1 -2 3 -4]]]\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":56473,"title":"IQpuzzler Preparation #2: Detect isolated zeros in a 2D matrix","description":"Return true if any isolated single zeros are present in the input M-by-N matrix (zeros with all adjacent elements being non-zero).\r\nExample:\r\n[ 2 2 0\r\n  2 0 5        ==\u003e true\r\n  5 5 5 ]\r\n[ 2 2 3\r\n  0 0 5        ==\u003e false\r\n  5 5 5 ]\r\nBackground:\r\nThis function can be useful in different board games, such as Go, or the upcoming IQpuzzler challenge.","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: 312px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 156px; transform-origin: 407px 156px; 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: 376.933px 7.91667px; transform-origin: 376.933px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn true if any isolated single zeros are present in the input M-by-N matrix (zeros with all adjacent elements being non-zero).\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: 29.175px 7.91667px; transform-origin: 29.175px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\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: 19.4417px 7.91667px; transform-origin: 19.4417px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e[ 2 2 0\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: 61.25px 7.91667px; transform-origin: 61.25px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  2 0 5        ==\u0026gt; true\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: 23.325px 7.91667px; transform-origin: 23.325px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  5 5 5 ]\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: 19.4417px 7.91667px; transform-origin: 19.4417px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e[ 2 2 3\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: 63.975px 7.91667px; transform-origin: 63.975px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  0 0 5        ==\u0026gt; false\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: 23.325px 7.91667px; transform-origin: 23.325px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  5 5 5 ]\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: 39.2917px 7.91667px; transform-origin: 39.2917px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eBackground:\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: 319.608px 7.91667px; transform-origin: 319.608px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis function can be useful in different board games, such as Go, or the upcoming IQpuzzler challenge.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function result = FindHoles1(board)\r\n    result=false;\r\nend","test_suite":"%%\r\nboard=[2 2 0;2 0 5;5 5 5]\r\ny_correct=true;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=[2 2 3;0 0 5;5 5 5]\r\ny_correct=false;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=ones(5,11);\r\ny_correct=false;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=zeros(5,11);\r\ny_correct=false;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=ones(5,11);\r\nboard([7 8 20 25])=0;\r\ny_correct=false;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=ones(5,11);\r\nboard([7 8 20 24])=0;\r\ny_correct=true;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=mod(magic(10),3);\r\ny_correct=true;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=mod(spiral(10),2);\r\ny_correct=true;\r\nassert(isequal(FindHoles1(board),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":2414210,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":9,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-11-07T16:12:10.000Z","updated_at":"2025-06-08T09:37:30.000Z","published_at":"2022-11-07T16:12:10.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn true if any isolated single zeros are present in the input M-by-N matrix (zeros with all adjacent elements being non-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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e[ 2 2 0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e  2 0 5        ==\u0026gt; true\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e  5 5 5 ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e[ 2 2 3\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e  0 0 5        ==\u0026gt; false\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e  5 5 5 ]\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\u003eBackground:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis function can be useful in different board games, such as Go, or the upcoming IQpuzzler challenge.\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":56468,"title":"IQpuzzler Preparation #1: Find all non-identical orientations of a matrix","description":"Return all non-identical orientations of a 2-D matrix that can be produced by rotating or flipping it.\r\nInput is an M-by-N matrix. You can assume integer values and no empty rows or columns.\r\nOutput is a 1-by-P cell array containing P unique M-by-N or N-by-M matrices.\r\nOrdering of the output matrices does not matter, as long as there are no repetitions.\r\nExample:\r\n{ [2 0;2 2] , [0 2;2 2] , [2 2;0 2], [2 2;2 0] } = rotflip2d([2 0;2 2])\r\nBackground:\r\nThis function will be useful for the IQpuzzler challenge on Cody.","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: 231px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 115.5px; transform-origin: 407px 115.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 299.525px 7.91667px; transform-origin: 299.525px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn all non-identical orientations of a 2-D matrix that can be produced by rotating or flipping it.\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: 278.242px 7.91667px; transform-origin: 278.242px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInput is an M-by-N matrix. You can assume integer values and no empty rows or columns.\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: 238.433px 7.91667px; transform-origin: 238.433px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOutput is a 1-by-P cell array containing P unique M-by-N or N-by-M matrices.\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: 258.258px 7.91667px; transform-origin: 258.258px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOrdering of the output matrices does not matter, as long as there are no repetitions.\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: 29.175px 7.91667px; transform-origin: 29.175px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\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: 188.017px 7.91667px; transform-origin: 188.017px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e{ [2 0;2 2] , [0 2;2 2] , [2 2;0 2], [2 2;2 0] } = rotflip2d([2 0;2 2])\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 39.2917px 7.91667px; transform-origin: 39.2917px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eBackground:\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: 196.7px 7.91667px; transform-origin: 196.7px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis function will be useful for the IQpuzzler challenge on Cody.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function orientations = rotflip2d(piece)\r\n    orientations={piece};\r\nend","test_suite":"%%\r\npiece = 1;\r\no_correct = {1};\r\nassert(isequal(rotflip2d(piece),o_correct))\r\n\r\n%%\r\npiece = [1 1;1 1];\r\no_correct = {[1 1;1 1]};\r\nassert(isequal(rotflip2d(piece),o_correct))\r\n\r\n%%\r\npiece = [2 0;2 2];\r\no=rotflip2d(piece);\r\nassert(numel(o)==4);\r\nfor n=1:3\r\n    for m=n+1:4\r\n        assert(~isequal(o{n},o{m}));\r\n    end\r\nend\r\no_correct = {[2 0;2 2],[0 2;2 2],[2 2;0 2],[2 2;2 0]};\r\nfor n=1:4\r\n    f=false;\r\n    for m=1:4\r\n        if isequal(o{n},o_correct{m})\r\n            f=true;\r\n            break;\r\n        end\r\n    end\r\n    assert(f);\r\nend\r\n\r\n%%\r\npiece = [3 3;0 3;0 3];\r\no=rotflip2d(piece);\r\nassert(numel(o)==8);\r\nfor n=1:7\r\n    for m=n+1:8\r\n        assert(~isequal(o{n},o{m}));\r\n    end\r\nend\r\no_correct = {[3 3;0 3;0 3],[3 3;3 0;3 0],[0 3;0 3;3 3],[3 0;3 0;3 3],[3 3 3;0 0 3],[3 3 3;3 0 0],[3 0 0;3 3 3],[0 0 3;3 3 3]};\r\nfor n=1:8\r\n    f=false;\r\n    for m=1:8\r\n        if isequal(o{n},o_correct{m})\r\n            f=true;\r\n            break;\r\n        end\r\n    end\r\n    assert(f);\r\nend\r\n\r\n%%\r\npiece = [12 12 0 ; 0 12 12 ; 0 0 12];\r\no=rotflip2d(piece);\r\nassert(numel(o)==4);\r\nfor n=1:3\r\n    for m=n+1:4\r\n        assert(~isequal(o{n},o{m}));\r\n    end\r\nend\r\no_correct = {[12 12 0;0 12 12;0 0 12],[0 12 12;12 12 0;12 0 0],[12 0 0;12 12 0;0 12 12],[0 0 12;0 12 12;12 12 0]};\r\nfor n=1:4\r\n    f=false;\r\n    for m=1:4\r\n        if isequal(o{n},o_correct{m})\r\n            f=true;\r\n            break;\r\n        end\r\n    end\r\n    assert(f);\r\nend","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":2414210,"edited_by":2414210,"edited_at":"2022-11-22T06:34:56.000Z","deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2022-11-07T15:25:43.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-11-07T15:19:15.000Z","updated_at":"2022-11-22T06:34:56.000Z","published_at":"2022-11-07T15:25:43.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn all non-identical orientations of a 2-D matrix that can be produced by rotating or flipping it.\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\u003eInput is an M-by-N matrix. You can assume integer values and no empty rows or columns.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput is a 1-by-P cell array containing P unique M-by-N or N-by-M matrices.\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\u003eOrdering of the output matrices does not matter, as long as there are no repetitions.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e{ [2 0;2 2] , [0 2;2 2] , [2 2;0 2], [2 2;2 0] } = rotflip2d([2 0;2 2])\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBackground:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis function will be useful for the IQpuzzler challenge on Cody.\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":2072,"title":"Packing Santa's Sleigh: First Layer","description":"This Challenge is inspired by the \u003chttp://www.kaggle.com/c/packing-santas-sleigh Packing Santa's Sleigh\u003e contest at kaggle that runs until January 26, 2014.\r\n\r\nThe Bag has a 1000 x 1000 base with the contest having 1,000,000 packages.\r\n\r\nThis Challenge is to place as many of the first N Santa Presents onto the 1000 x 1000 grid. The packages have been presorted to have Z as max, not provided, thus minimizing the X*Y cross section. Only the first 240 packages are provided as package 241 busts the bag bottom making an area greater than 1,000,000. Packages out of sequence cause a severe penalty thus all packages less than the highest package used must fit on the board.\r\n\r\n*Input*: Presents ; Presents(240,2)\r\n\r\n*Output*: L, xyTL; L(1000,1000) of values 0:n\u003c=240, 0 is unused space\r\n\r\n*Scoring*: Unused Area\r\n\r\n*Example*:\r\n\r\n[2 2;3 3;1 2] is Presents\r\n\r\nL\r\n\r\n  1 1 2 2 2 0  thru column 1000\r\n  1 1 2 2 2\r\n  3 3 2 2 2\r\n  0 0 0 0 0 0 rows 4 thru 1000 are zeros\r\n\r\nxyTL\r\n[1 1;1 3;3 1]\r\n\r\nScores 1,000,000 - 15= 999985\r\n\r\nBoxes 1:236 are possible, 97.5719% efficient pack in \u003c 1sec.\r\n\r\n*TestSuite Sample Code:*\r\n\r\nIn the TestSuite at the end is wrapper code for entering the kaggle contest.\r\nUpdate your SantaPack routine and execute the wrapper to see your contest score. The official presents.mat file needs to be downloaded. The wrapper has further discussion on efficient methods and current scores. \r\n","description_html":"\u003cp\u003eThis Challenge is inspired by the \u003ca href = \"http://www.kaggle.com/c/packing-santas-sleigh\"\u003ePacking Santa's Sleigh\u003c/a\u003e contest at kaggle that runs until January 26, 2014.\u003c/p\u003e\u003cp\u003eThe Bag has a 1000 x 1000 base with the contest having 1,000,000 packages.\u003c/p\u003e\u003cp\u003eThis Challenge is to place as many of the first N Santa Presents onto the 1000 x 1000 grid. The packages have been presorted to have Z as max, not provided, thus minimizing the X*Y cross section. Only the first 240 packages are provided as package 241 busts the bag bottom making an area greater than 1,000,000. Packages out of sequence cause a severe penalty thus all packages less than the highest package used must fit on the board.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput\u003c/b\u003e: Presents ; Presents(240,2)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput\u003c/b\u003e: L, xyTL; L(1000,1000) of values 0:n\u0026lt;=240, 0 is unused space\u003c/p\u003e\u003cp\u003e\u003cb\u003eScoring\u003c/b\u003e: Unused Area\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e:\u003c/p\u003e\u003cp\u003e[2 2;3 3;1 2] is Presents\u003c/p\u003e\u003cp\u003eL\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 1 2 2 2 0  thru column 1000\r\n1 1 2 2 2\r\n3 3 2 2 2\r\n0 0 0 0 0 0 rows 4 thru 1000 are zeros\r\n\u003c/pre\u003e\u003cp\u003exyTL\r\n[1 1;1 3;3 1]\u003c/p\u003e\u003cp\u003eScores 1,000,000 - 15= 999985\u003c/p\u003e\u003cp\u003eBoxes 1:236 are possible, 97.5719% efficient pack in \u0026lt; 1sec.\u003c/p\u003e\u003cp\u003e\u003cb\u003eTestSuite Sample Code:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eIn the TestSuite at the end is wrapper code for entering the kaggle contest.\r\nUpdate your SantaPack routine and execute the wrapper to see your contest score. The official presents.mat file needs to be downloaded. The wrapper has further discussion on efficient methods and current scores.\u003c/p\u003e","function_template":"function  [L,xyTL]=SantaPack(p)\r\n% p is an Nx2\r\n% xyTL is Top Left position of pieces 1:n.\r\n% xyTL created for Speed vs find in a 1Kx1K array\r\n% Place 1:n of p onto L, a 1000x1000 array\r\n% Put p row onto L array. \r\n% If p(1,:) is [2 3]\r\n%[2 3] may be placed as [1 1 1;1 1 1] or [1 1; 1 1;1 1] for box 1\r\n% Note: big boxes typically pack to 95% and small boxes to \u003e98%\r\n\r\n L=zeros(1000);\r\n xyTL=p*0;\r\n\r\n% Placing first 16 pieces\r\n% No piece exceeds 250x250\r\n pxy=[1 251 501 751];\r\n piece=1;\r\n for i=1:4\r\n  for j=1:4\r\n% putting piece on layer\r\n   L(pxy(i):pxy(i)+p(piece,1)-1,pxy(j):pxy(j)+p(piece,2)-1)=piece; \r\n% TL Location of piece\r\n   xyTL(piece,:)=[pxy(i) pxy(j)]; \r\n   piece=piece+1;\r\n  end\r\n end\r\n %figure(3);imagesc(L)\r\n \r\nend % SantaPack","test_suite":"assignin('caller','score',100000);\r\n%%\r\nSanta_L1=[3     2;207    73;160    78;8     3;\r\n     9     9;\r\n   170   120;116    91;\r\n   206   142;28     8;\r\n     3     2;41    22;\r\n    31    11;28    20;\r\n    29    13;98    96;\r\n    26     4;34     9;\r\n     4     3;84    78;\r\n   219   114;28    22;\r\n   195   185;3     2;\r\n    31     9;104   101;\r\n    32    31;188   142;\r\n    45    18;8     2;\r\n    13    10;49    22;\r\n   172    72;28    17;\r\n    90    87;33     5;\r\n    32    23;16    14;\r\n    42    18;32     8;\r\n     7     5;6     6;\r\n   201    69;20    11;\r\n    30    18;211   120;\r\n   206    97;3     2;\r\n   124    92;48    43;\r\n     2     2;173   103;\r\n    26    12;8     7;\r\n     8     8;57    33;\r\n    21    20;24    15;\r\n    26    12;44    24;\r\n    30     8;\r\n    43    26;\r\n    23    23;\r\n     9     4;\r\n    16    13;\r\n    58    29;\r\n   133   125;\r\n     5     2;\r\n   197   117;\r\n    39    10;\r\n    31    11;\r\n    41    18;\r\n     6     3;\r\n    31     8;\r\n    40    32;\r\n    41    39;\r\n    36    30;\r\n     2     2;\r\n    25    24;\r\n     6     2;\r\n     3     2;\r\n     2     2;\r\n    85    70;\r\n    37    25;\r\n    24    20;\r\n    60    26;\r\n    29    14;\r\n    49    30;\r\n   153    75;\r\n     6     3;\r\n     7     3;\r\n   185   162;\r\n     4     2;\r\n     6     5;\r\n   176    99;\r\n     4     2;\r\n   219   154;\r\n    24    22;\r\n   148    87;\r\n    32     7;\r\n   143    98;\r\n    23    13;\r\n   150    65;\r\n     5     2;\r\n    53    41;\r\n    25    12;\r\n    36     6;\r\n    21    10;\r\n   211    79;\r\n   183   130;\r\n     6     3;\r\n    36    28;\r\n    32    16;\r\n    21    15;\r\n    27    26;\r\n    39    14;\r\n    36     7;\r\n    57    17;\r\n   214    90;\r\n    36     5;\r\n    27    16;\r\n    52    15;\r\n     8     6;\r\n     5     4;\r\n    52    37;\r\n     7     2;\r\n    92    79;\r\n    37    35;\r\n    33     5;\r\n     5     2;\r\n    52    10;\r\n    29     5;\r\n    44    18;\r\n     8     5;\r\n    16     8;\r\n   137   105;\r\n    78    74;\r\n     9     5;\r\n    39    29;\r\n    43    31;\r\n     6     3;\r\n     8     4;\r\n    26    19;\r\n    22     7;\r\n    30    15;\r\n   199   195;\r\n     7     7;\r\n     7     5;\r\n   134    81;\r\n   206   108;\r\n    54    29;\r\n    16     7;\r\n   116    99;\r\n    35    23;\r\n    31    17;\r\n    56    11;\r\n     7     3;\r\n    52     5;\r\n   102    99;\r\n     5     5;\r\n    35    17;\r\n     8     6;\r\n    51     7;\r\n    28    16;\r\n   107    83;\r\n    26     8;\r\n     8     6;\r\n   149    83;\r\n    45    29;\r\n    55    52;\r\n    27     6;\r\n    82    81;\r\n     9     5;\r\n    27    21;\r\n    19    10;\r\n    56    26;\r\n    19    14;\r\n    11     8;\r\n    47     7;\r\n    26    13;\r\n    36    19;\r\n    87    73;\r\n    14    10;223   100;2     2;33     5;198   135;38    15;19     8;211    95;9     6;21     7;175   145;22    16;7     5;7     4;9     8;42     5;3     3;2     2;3     2;5     2;30    24;29    29;27     9;168    72;6     4;22     7;9     6;10     6;19    16;7     2;43    14;138   115;138   130;39    20;9     4;27     7;26    22;169   144;8     8;41     9;50    26;62    10;33    19;7     2;121   112;102    93;109    88;9     8;40    40;25    19;31     8;55    23;41    11;6     2;8     3;128   114;40    16;7     6;5     2];\r\n[L,xyTL]=SantaPack(Santa_L1);\r\nptrxy=find(xyTL(:,1)\u003e0,1,'last');\r\n\r\npresents=Santa_L1;\r\nfor k=1:ptrxy\r\n  ptrxmin=xyTL(k,1);\r\n  ptrymin=xyTL(k,2);\r\n  assert(isequal(L(ptrxmin,ptrymin),k)) % Verify TL corner\r\n\r\n  if ptrxmin+presents(k,1)-1\u003e1000 || ptrymin+presents(k,2)-1\u003e1000\r\n% BR Corner verify for rotated only fit case\r\n    assert(isequal(L(ptrxmin+presents(k,2)-1,ptrymin+presents(k,1)-1),k))\r\n  elseif ptrxmin+presents(k,2)-1\u003e1000 || ptrymin+presents(k,1)-1\u003e1000\r\n% BR corner verify for non-rotated only fit case\r\n    assert(isequal(L(ptrxmin+presents(k,1)-1,ptrymin+presents(k,2)-1),k))\r\n  else % rot or non-rot case\r\n   v1=L(ptrxmin+presents(k,2)-1,ptrymin+presents(k,1)-1)==k;\r\n   v2=L(ptrxmin+presents(k,1)-1,ptrymin+presents(k,2)-1)==k;\r\n   assert(v1 || v2); % simple corner check\r\n  end\r\n% More robust checks may be implemented if needed\r\nend\r\n   \r\n\r\nA=Santa_L1(:,1).*Santa_L1(:,2);\r\nAs=sum(A(1:ptrxy))\r\nassignin('caller','score',min(100000,1000000-As));\r\n%%\r\n%{\r\nfunction SantaPack_Cody\r\n% www.kaggle.com Santa Packing Contest \r\n% 11/2013 thru January 2014\r\n% Given 1 Million Rectangularoid packages\r\n% Fit Packages into a Minimum Heigth Box with a base of 1000 x 1000\r\n% Rules allow presents out of order but this is virtually non-optimiziable\r\n% Presents out of order incur a penalty\r\n% Packing Construction Here:\r\n% All boxes dimension sorted [Mid, Min, Max]\r\n% Boxes 1:236 all have their tops on the same plane (97.5719% efficient pack)\r\n% Boxes 237:423 have their tops 250 lower in Z. Max Z of 1:236 is 250.\r\n% The very bottom layer, with box 1000000 has bottom box at Z=1\r\n% Note: Max dimension after box 700,000 is 70\r\n% This construction has min cross area per present, max dimension is placed on Z\r\n% Input is presents that have cumulative area \u003c= 1000000\r\n% The optimal score with perfect layer packing is \r\n% Layers 4098  zsum 996483  Score 1,992,966\r\n% Layers 4210, Score of 2,047,696 is possible with sequence layer packing\r\n% Kaggle Lead as of 12/21/2013 is 1,999,256. Unknown method.\r\n% Pack routine returns a 1000x1000 array with values 1:n, n\u003c=N\r\n% N is the Nth  box that fits in the 1,000,000 area limit\r\n% Next call uses n+1:N\r\n\r\nload presents  % available at kaggle site as a Mat file\r\nnumPresents = size(presents,1);\r\n\r\npresents(:,2:4)=sort(presents(:,2:4),2);\r\npresents(:,2:3)=fliplr(sort(presents(:,2:3),2)); % x\u003ey, z\u003ex\r\npresents=[presents presents(:,2).*presents(:,3)]; % Area of box tops\r\npresents=[presents cumsum(presents(:,end))]; % [presID x y z A Asum]\r\n\r\npe=0;\r\nLayer=0;\r\nzsum=0;\r\nz=-1;\r\npresentCoords=zeros(1000000,25);\r\n\r\ntic\r\nwhile pe\u003c1000000\r\n ps=pe+1; \r\n Asum=presents(ps:min(ps+5000,1000000),end); % valid for layer 1\r\n if pe\u003e0, Asum=Asum-presents(pe,end); end% remove prior layers sum\r\n ptr1M=find(Asum\u003c=1000000,1,'last');\r\n pe=ps+ptr1M-1;\r\n \r\n [L,xyTL]=SantaPack(presents(ps:pe,2:3)); % L has values 1 thru n, being ps thru ps+n-1\r\n % xyTL is Top Left position of pieces 1:n\r\n %figure(3);imagesc(L);\r\n\r\n pe=ps-1+find(xyTL(:,1)\u003e0,1,'last'); % find number of boxes placed\r\n zmax=max(presents(ps:pe,4));\r\n \r\n % Convert Layers to coordinates\r\n % Locate pieces in Layer and assign coordinate values\r\n % z axis values fixed in post processing to positives\r\n % Valid placement and sizes assumed\r\n for k=1:pe-ps+1\r\n  idx=k+ps-1; \r\n  ptrxmin=xyTL(k,1);\r\n  ptrymin=xyTL(k,2);\r\n  if ptrxmin+presents(idx,2)-1\u003c=1000 \u0026\u0026 ptrymin+presents(idx,3)-1\u003c=1000\r\n   if L(ptrxmin+presents(idx,2)-1,ptrymin+presents(idx,3)-1)==k\r\n    ptrxmax=ptrxmin+presents(idx,2)-1;\r\n    ptrymax=ptrymin+presents(idx,3)-1;\r\n   else\r\n    ptrxmax=ptrxmin+presents(idx,3)-1;\r\n    ptrymax=ptrymin+presents(idx,2)-1;\r\n   end\r\n  else % assumed placement if xmax(1)\u003e1000\r\n   ptrxmax=ptrxmin+presents(idx,3)-1;\r\n   ptrymax=ptrymin+presents(idx,2)-1;\r\n  end % if\r\n  \r\n % place this section inside SantaPack and output presentCoords vs L\r\n    presentCoords(idx,1) = idx;\r\n    presentCoords(idx,[2 8 14 20]) = ptrxmin;\r\n    presentCoords(idx,[5 11 17 23]) = ptrxmax;\r\n    presentCoords(idx,[3 6 15 18]) = ptrymin;\r\n    presentCoords(idx,[9 12 21 24]) = ptrymax;\r\n    presentCoords(idx,[4 7 10 13]) = z;\r\n    presentCoords(idx,[16 19 22 25]) = z - presents(idx,4) + 1;\r\n end % k\r\n \r\n z=z-zmax;\r\n Layer=Layer+1;\r\n zsum=zsum+zmax;\r\n fprintf('Layer %i Start %i  Final %i Zsum %i  Time %.2f\\n',Layer,ps,pe,zsum,toc) % Processing Status\r\n % Deep routine to 2M takes 30 minutes\r\n % Fast Placement takes 187 sec\r\n \r\nend  % pe\r\n\r\n% Offset Z coordinates \r\n% Bottom is 1 and very top is Positive\r\nzCoords = presentCoords(:,4:3:end);\r\nminZ = min(zCoords(:));\r\npresentCoords(:,4:3:end) = zCoords - minZ + 1;\r\n\r\n% Scoring function\r\n% Ideal order is the original order\r\npresentIDs = presents(:,1); %z\r\nidealOrder = presentIDs; \r\n\r\n% Determine the max z-coordinate; this is the max height of the box\r\nmaxZ = max(max(presentCoords(:,4:3:end)));\r\n\r\n% Go down the layers from top to bottom, reorder presents in numeric order\r\n% for each layer\r\nmaxZCoord = zeros(numPresents,2);\r\nfor i = 1:numPresents\r\n    maxZCoord(i,1) = presentCoords(i);\r\n    maxZCoord(i,2) = max(presentCoords(i,4:3:end));\r\nend\r\nmaxzCoordSorted = sortrows(maxZCoord,[-2 1]); %sort max z-coord for each present\r\nreOrder = maxzCoordSorted(:,1);\r\n\r\n% Compare the new order to the ideal order\r\norder = sum(abs(idealOrder - reOrder));\r\n\r\n% Compute metric\r\nfprintf('Metric %i MaxZ %i  Order Penalty %i\\n',2*maxZ + order,maxZ,order);\r\n\r\n% Creating a Submission File\r\nsubfile = 'submissionfile_SantaPack_Cody.csv';\r\nfileID = fopen(subfile, 'w');\r\nheaders = {'PresentId','x1','y1','z1','x2','y2','z2','x3','y3','z3','x4','y4','z4','x5','y5','z5','x6','y6','z6','x7','y7','z7','x8','y8','z8'};\r\nfprintf(fileID,'%s,',headers{1,1:end-1});\r\nfprintf(fileID,'%s\\n',headers{1,end});\r\nfprintf(fileID,'%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\\n',presentCoords');\r\nfclose(fileID);\r\n\r\nend % SantaPack_Cody\r\n\r\nfunction  [L,xyTL]=SantaPack(p)\r\n% p is an Nx2\r\n% xyTL is Top Left position of pieces 1:n\r\n% Place 1:n of p onto L, a 1000x1000 array\r\n% Put p row onto L array. [2 3] may be placed [1 1 1;1 1 1] or [1 1; 1 1;1 1] for box 1\r\n% Note: big boxes typically pack to 95% and small boxes to \u003e98%\r\n\r\n L=zeros(1000);\r\n xyTL=p*0;\r\n% L(1:p(1,1),1:p(1,2))=1; % putting one piece per layer\r\n% return\r\n\r\n% Placing first 16 pieces\r\n% No piece exceeds 250x250\r\n pxy=[1 251 501 751];\r\n piece=1;\r\n for i=1:4\r\n  for j=1:4\r\n   L(pxy(i):pxy(i)+p(piece,1)-1,pxy(j):pxy(j)+p(piece,2)-1)=piece; % putting piece on layer\r\n   xyTL(piece,:)=[pxy(i) pxy(j)]; % Location of piece\r\n   piece=piece+1;\r\n  end\r\n end\r\n %figure(3);imagesc(L)\r\n \r\nend % SantaPack\r\n%}\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-12-22T04:12:10.000Z","updated_at":"2013-12-22T05:37:27.000Z","published_at":"2013-12-22T05:37:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is inspired by 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=\\\"http://www.kaggle.com/c/packing-santas-sleigh\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePacking Santa's Sleigh\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e contest at kaggle that runs until January 26, 2014.\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 Bag has a 1000 x 1000 base with the contest having 1,000,000 packages.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is to place as many of the first N Santa Presents onto the 1000 x 1000 grid. The packages have been presorted to have Z as max, not provided, thus minimizing the X*Y cross section. Only the first 240 packages are provided as package 241 busts the bag bottom making an area greater than 1,000,000. Packages out of sequence cause a severe penalty thus all packages less than the highest package used must fit on the board.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: Presents ; Presents(240,2)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: L, xyTL; L(1000,1000) of values 0:n\u0026lt;=240, 0 is unused space\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eScoring\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: Unused Area\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e[2 2;3 3;1 2] is Presents\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\u003eL\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 1 2 2 2 0  thru column 1000\\n1 1 2 2 2\\n3 3 2 2 2\\n0 0 0 0 0 0 rows 4 thru 1000 are zeros]]\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\u003exyTL [1 1;1 3;3 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eScores 1,000,000 - 15= 999985\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\u003eBoxes 1:236 are possible, 97.5719% efficient pack in \u0026lt; 1sec.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTestSuite Sample Code:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn the TestSuite at the end is wrapper code for entering the kaggle contest. Update your SantaPack routine and execute the wrapper to see your contest score. The official presents.mat file needs to be downloaded. The wrapper has further discussion on efficient methods and current scores.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"problem_search":{"errors":[],"problems":[{"id":486,"title":"Surface Fit z(x,y)","description":"Given three vectors x,y,z. Find four coefficients c = [cxx cxy cyy c00], such that z = cxx*x.^2+cxy*x.*y+cyy*y.^2+c00. \r\n\r\nFor example,\r\n\r\n x = [ 0  0  1  1  2  2  3  3]\r\n y = [ 0  1  0  1  0  1  0  1]\r\n z = [-4 -1 -3 -2  0 -1  5  2]\r\n\r\nthen\r\n\r\n z = x.^2-2*x.*y+3*y.^2-4 \r\n\r\nand\r\n\r\n c = [cxx cxy cyy c00] = [1 -2 3 -4]","description_html":"\u003cp\u003eGiven three vectors x,y,z. Find four coefficients c = [cxx cxy cyy c00], such that z = cxx*x.^2+cxy*x.*y+cyy*y.^2+c00.\u003c/p\u003e\u003cp\u003eFor example,\u003c/p\u003e\u003cpre\u003e x = [ 0  0  1  1  2  2  3  3]\r\n y = [ 0  1  0  1  0  1  0  1]\r\n z = [-4 -1 -3 -2  0 -1  5  2]\u003c/pre\u003e\u003cp\u003ethen\u003c/p\u003e\u003cpre\u003e z = x.^2-2*x.*y+3*y.^2-4 \u003c/pre\u003e\u003cp\u003eand\u003c/p\u003e\u003cpre\u003e c = [cxx cxy cyy c00] = [1 -2 3 -4]\u003c/pre\u003e","function_template":"function c = sufit(x,y,z)\r\n  cxx=0;\r\n  cxy=0;\r\n  cyy=0;\r\n  c00=0;\r\n  c=[cxx cxy cyy c00];\r\nend","test_suite":"%%\r\nx= [0 0 1 1 2 2 3 3];\r\ny= [0 1 0 1 0 1 0 1];\r\nz=[-4 -1 -3 -2 0 -1 5 2];\r\nc=[1 -2 3 -4]; \r\nassert(isequal(c,round(sufit(x,y,z))))\r\n%%\r\nx= rand(1,100);\r\ny= rand(1,100);\r\nz=7*x.^2-9*x.*y+11*y.^2-17;\r\nc=[7 -9 11 -17]; \r\nassert(isequal(c,round(sufit(x,y,z))))\r\n%%\r\nx= rand(1,10000);\r\ny= rand(1,10000);\r\nz=17*x.^2-19*x.*y+11*y.^2-13;\r\nc=[17 -19 11 -13]; \r\nassert(isequal(c,round(sufit(x,y,z))))\r\n","published":true,"deleted":false,"likes_count":3,"comments_count":2,"created_by":166,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":46,"test_suite_updated_at":"2012-03-12T19:23:56.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2012-03-12T17:50:33.000Z","updated_at":"2025-12-07T17:59:24.000Z","published_at":"2012-03-19T09:01:03.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 three vectors x,y,z. Find four coefficients c = [cxx cxy cyy c00], such that z = cxx*x.^2+cxy*x.*y+cyy*y.^2+c00.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eFor example,\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ x = [ 0  0  1  1  2  2  3  3]\\n y = [ 0  1  0  1  0  1  0  1]\\n z = [-4 -1 -3 -2  0 -1  5  2]]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003ethen\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[ z = x.^2-2*x.*y+3*y.^2-4]]\u003e\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eand\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"code\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e\u003c![CDATA[ c = [cxx cxy cyy c00] = [1 -2 3 -4]]]\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":56473,"title":"IQpuzzler Preparation #2: Detect isolated zeros in a 2D matrix","description":"Return true if any isolated single zeros are present in the input M-by-N matrix (zeros with all adjacent elements being non-zero).\r\nExample:\r\n[ 2 2 0\r\n  2 0 5        ==\u003e true\r\n  5 5 5 ]\r\n[ 2 2 3\r\n  0 0 5        ==\u003e false\r\n  5 5 5 ]\r\nBackground:\r\nThis function can be useful in different board games, such as Go, or the upcoming IQpuzzler challenge.","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: 312px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 156px; transform-origin: 407px 156px; 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: 376.933px 7.91667px; transform-origin: 376.933px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn true if any isolated single zeros are present in the input M-by-N matrix (zeros with all adjacent elements being non-zero).\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: 29.175px 7.91667px; transform-origin: 29.175px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\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: 19.4417px 7.91667px; transform-origin: 19.4417px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e[ 2 2 0\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: 61.25px 7.91667px; transform-origin: 61.25px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  2 0 5        ==\u0026gt; true\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: 23.325px 7.91667px; transform-origin: 23.325px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  5 5 5 ]\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: 19.4417px 7.91667px; transform-origin: 19.4417px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e[ 2 2 3\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: 63.975px 7.91667px; transform-origin: 63.975px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  0 0 5        ==\u0026gt; false\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: 23.325px 7.91667px; transform-origin: 23.325px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e  5 5 5 ]\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: 39.2917px 7.91667px; transform-origin: 39.2917px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eBackground:\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: 319.608px 7.91667px; transform-origin: 319.608px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis function can be useful in different board games, such as Go, or the upcoming IQpuzzler challenge.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function result = FindHoles1(board)\r\n    result=false;\r\nend","test_suite":"%%\r\nboard=[2 2 0;2 0 5;5 5 5]\r\ny_correct=true;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=[2 2 3;0 0 5;5 5 5]\r\ny_correct=false;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=ones(5,11);\r\ny_correct=false;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=zeros(5,11);\r\ny_correct=false;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=ones(5,11);\r\nboard([7 8 20 25])=0;\r\ny_correct=false;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=ones(5,11);\r\nboard([7 8 20 24])=0;\r\ny_correct=true;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=mod(magic(10),3);\r\ny_correct=true;\r\nassert(isequal(FindHoles1(board),y_correct))\r\n%%\r\nboard=mod(spiral(10),2);\r\ny_correct=true;\r\nassert(isequal(FindHoles1(board),y_correct))","published":true,"deleted":false,"likes_count":0,"comments_count":2,"created_by":2414210,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":9,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2022-11-07T16:12:10.000Z","updated_at":"2025-06-08T09:37:30.000Z","published_at":"2022-11-07T16:12:10.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn true if any isolated single zeros are present in the input M-by-N matrix (zeros with all adjacent elements being non-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\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e[ 2 2 0\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e  2 0 5        ==\u0026gt; true\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e  5 5 5 ]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e[ 2 2 3\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e  0 0 5        ==\u0026gt; false\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e  5 5 5 ]\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\u003eBackground:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis function can be useful in different board games, such as Go, or the upcoming IQpuzzler challenge.\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":56468,"title":"IQpuzzler Preparation #1: Find all non-identical orientations of a matrix","description":"Return all non-identical orientations of a 2-D matrix that can be produced by rotating or flipping it.\r\nInput is an M-by-N matrix. You can assume integer values and no empty rows or columns.\r\nOutput is a 1-by-P cell array containing P unique M-by-N or N-by-M matrices.\r\nOrdering of the output matrices does not matter, as long as there are no repetitions.\r\nExample:\r\n{ [2 0;2 2] , [0 2;2 2] , [2 2;0 2], [2 2;2 0] } = rotflip2d([2 0;2 2])\r\nBackground:\r\nThis function will be useful for the IQpuzzler challenge on Cody.","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: 231px; display: block; min-width: 0px; padding-block-start: 0px; padding-top: 0px; perspective-origin: 407px 115.5px; transform-origin: 407px 115.5px; vertical-align: baseline; \"\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 299.525px 7.91667px; transform-origin: 299.525px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eReturn all non-identical orientations of a 2-D matrix that can be produced by rotating or flipping it.\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: 278.242px 7.91667px; transform-origin: 278.242px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eInput is an M-by-N matrix. You can assume integer values and no empty rows or columns.\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: 238.433px 7.91667px; transform-origin: 238.433px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOutput is a 1-by-P cell array containing P unique M-by-N or N-by-M matrices.\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: 258.258px 7.91667px; transform-origin: 258.258px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eOrdering of the output matrices does not matter, as long as there are no repetitions.\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: 29.175px 7.91667px; transform-origin: 29.175px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eExample:\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: 188.017px 7.91667px; transform-origin: 188.017px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003e{ [2 0;2 2] , [0 2;2 2] , [2 2;0 2], [2 2;2 0] } = rotflip2d([2 0;2 2])\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003cdiv style=\"block-size: 21px; font-family: Helvetica, Arial, sans-serif; line-height: 21px; margin-block-end: 9px; margin-block-start: 2px; margin-bottom: 9px; margin-inline-end: 10px; margin-inline-start: 4px; margin-left: 4px; margin-right: 10px; margin-top: 2px; perspective-origin: 384px 10.5px; text-align: left; transform-origin: 384px 10.5px; white-space: pre-wrap; margin-left: 4px; margin-top: 2px; margin-bottom: 9px; margin-right: 10px; \"\u003e\u003cspan style=\"block-size: auto; display: inline; margin-block-end: 0px; margin-block-start: 0px; margin-bottom: 0px; margin-inline-end: 0px; margin-inline-start: 0px; margin-left: 0px; margin-right: 0px; margin-top: 0px; perspective-origin: 39.2917px 7.91667px; transform-origin: 39.2917px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eBackground:\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: 196.7px 7.91667px; transform-origin: 196.7px 7.91667px; unicode-bidi: normal; \"\u003e\u003cspan style=\"\"\u003eThis function will be useful for the IQpuzzler challenge on Cody.\u003c/span\u003e\u003c/span\u003e\u003c/div\u003e\u003c/div\u003e\u003c/div\u003e","function_template":"function orientations = rotflip2d(piece)\r\n    orientations={piece};\r\nend","test_suite":"%%\r\npiece = 1;\r\no_correct = {1};\r\nassert(isequal(rotflip2d(piece),o_correct))\r\n\r\n%%\r\npiece = [1 1;1 1];\r\no_correct = {[1 1;1 1]};\r\nassert(isequal(rotflip2d(piece),o_correct))\r\n\r\n%%\r\npiece = [2 0;2 2];\r\no=rotflip2d(piece);\r\nassert(numel(o)==4);\r\nfor n=1:3\r\n    for m=n+1:4\r\n        assert(~isequal(o{n},o{m}));\r\n    end\r\nend\r\no_correct = {[2 0;2 2],[0 2;2 2],[2 2;0 2],[2 2;2 0]};\r\nfor n=1:4\r\n    f=false;\r\n    for m=1:4\r\n        if isequal(o{n},o_correct{m})\r\n            f=true;\r\n            break;\r\n        end\r\n    end\r\n    assert(f);\r\nend\r\n\r\n%%\r\npiece = [3 3;0 3;0 3];\r\no=rotflip2d(piece);\r\nassert(numel(o)==8);\r\nfor n=1:7\r\n    for m=n+1:8\r\n        assert(~isequal(o{n},o{m}));\r\n    end\r\nend\r\no_correct = {[3 3;0 3;0 3],[3 3;3 0;3 0],[0 3;0 3;3 3],[3 0;3 0;3 3],[3 3 3;0 0 3],[3 3 3;3 0 0],[3 0 0;3 3 3],[0 0 3;3 3 3]};\r\nfor n=1:8\r\n    f=false;\r\n    for m=1:8\r\n        if isequal(o{n},o_correct{m})\r\n            f=true;\r\n            break;\r\n        end\r\n    end\r\n    assert(f);\r\nend\r\n\r\n%%\r\npiece = [12 12 0 ; 0 12 12 ; 0 0 12];\r\no=rotflip2d(piece);\r\nassert(numel(o)==4);\r\nfor n=1:3\r\n    for m=n+1:4\r\n        assert(~isequal(o{n},o{m}));\r\n    end\r\nend\r\no_correct = {[12 12 0;0 12 12;0 0 12],[0 12 12;12 12 0;12 0 0],[12 0 0;12 12 0;0 12 12],[0 0 12;0 12 12;12 12 0]};\r\nfor n=1:4\r\n    f=false;\r\n    for m=1:4\r\n        if isequal(o{n},o_correct{m})\r\n            f=true;\r\n            break;\r\n        end\r\n    end\r\n    assert(f);\r\nend","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":2414210,"edited_by":2414210,"edited_at":"2022-11-22T06:34:56.000Z","deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":"2022-11-07T15:25:43.000Z","rescore_all_solutions":false,"group_id":1,"created_at":"2022-11-07T15:19:15.000Z","updated_at":"2022-11-22T06:34:56.000Z","published_at":"2022-11-07T15:25:43.000Z","restored_at":null,"restored_by":null,"spam":null,"simulink":false,"admin_reviewed":false,"description_opc":"{\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eReturn all non-identical orientations of a 2-D matrix that can be produced by rotating or flipping it.\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\u003eInput is an M-by-N matrix. You can assume integer values and no empty rows or columns.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eOutput is a 1-by-P cell array containing P unique M-by-N or N-by-M matrices.\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\u003eOrdering of the output matrices does not matter, as long as there are no repetitions.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eExample:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e{ [2 0;2 2] , [0 2;2 2] , [2 2;0 2], [2 2;2 0] } = rotflip2d([2 0;2 2])\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eBackground:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003cw:jc w:val=\\\"left\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis function will be useful for the IQpuzzler challenge on Cody.\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":2072,"title":"Packing Santa's Sleigh: First Layer","description":"This Challenge is inspired by the \u003chttp://www.kaggle.com/c/packing-santas-sleigh Packing Santa's Sleigh\u003e contest at kaggle that runs until January 26, 2014.\r\n\r\nThe Bag has a 1000 x 1000 base with the contest having 1,000,000 packages.\r\n\r\nThis Challenge is to place as many of the first N Santa Presents onto the 1000 x 1000 grid. The packages have been presorted to have Z as max, not provided, thus minimizing the X*Y cross section. Only the first 240 packages are provided as package 241 busts the bag bottom making an area greater than 1,000,000. Packages out of sequence cause a severe penalty thus all packages less than the highest package used must fit on the board.\r\n\r\n*Input*: Presents ; Presents(240,2)\r\n\r\n*Output*: L, xyTL; L(1000,1000) of values 0:n\u003c=240, 0 is unused space\r\n\r\n*Scoring*: Unused Area\r\n\r\n*Example*:\r\n\r\n[2 2;3 3;1 2] is Presents\r\n\r\nL\r\n\r\n  1 1 2 2 2 0  thru column 1000\r\n  1 1 2 2 2\r\n  3 3 2 2 2\r\n  0 0 0 0 0 0 rows 4 thru 1000 are zeros\r\n\r\nxyTL\r\n[1 1;1 3;3 1]\r\n\r\nScores 1,000,000 - 15= 999985\r\n\r\nBoxes 1:236 are possible, 97.5719% efficient pack in \u003c 1sec.\r\n\r\n*TestSuite Sample Code:*\r\n\r\nIn the TestSuite at the end is wrapper code for entering the kaggle contest.\r\nUpdate your SantaPack routine and execute the wrapper to see your contest score. The official presents.mat file needs to be downloaded. The wrapper has further discussion on efficient methods and current scores. \r\n","description_html":"\u003cp\u003eThis Challenge is inspired by the \u003ca href = \"http://www.kaggle.com/c/packing-santas-sleigh\"\u003ePacking Santa's Sleigh\u003c/a\u003e contest at kaggle that runs until January 26, 2014.\u003c/p\u003e\u003cp\u003eThe Bag has a 1000 x 1000 base with the contest having 1,000,000 packages.\u003c/p\u003e\u003cp\u003eThis Challenge is to place as many of the first N Santa Presents onto the 1000 x 1000 grid. The packages have been presorted to have Z as max, not provided, thus minimizing the X*Y cross section. Only the first 240 packages are provided as package 241 busts the bag bottom making an area greater than 1,000,000. Packages out of sequence cause a severe penalty thus all packages less than the highest package used must fit on the board.\u003c/p\u003e\u003cp\u003e\u003cb\u003eInput\u003c/b\u003e: Presents ; Presents(240,2)\u003c/p\u003e\u003cp\u003e\u003cb\u003eOutput\u003c/b\u003e: L, xyTL; L(1000,1000) of values 0:n\u0026lt;=240, 0 is unused space\u003c/p\u003e\u003cp\u003e\u003cb\u003eScoring\u003c/b\u003e: Unused Area\u003c/p\u003e\u003cp\u003e\u003cb\u003eExample\u003c/b\u003e:\u003c/p\u003e\u003cp\u003e[2 2;3 3;1 2] is Presents\u003c/p\u003e\u003cp\u003eL\u003c/p\u003e\u003cpre class=\"language-matlab\"\u003e1 1 2 2 2 0  thru column 1000\r\n1 1 2 2 2\r\n3 3 2 2 2\r\n0 0 0 0 0 0 rows 4 thru 1000 are zeros\r\n\u003c/pre\u003e\u003cp\u003exyTL\r\n[1 1;1 3;3 1]\u003c/p\u003e\u003cp\u003eScores 1,000,000 - 15= 999985\u003c/p\u003e\u003cp\u003eBoxes 1:236 are possible, 97.5719% efficient pack in \u0026lt; 1sec.\u003c/p\u003e\u003cp\u003e\u003cb\u003eTestSuite Sample Code:\u003c/b\u003e\u003c/p\u003e\u003cp\u003eIn the TestSuite at the end is wrapper code for entering the kaggle contest.\r\nUpdate your SantaPack routine and execute the wrapper to see your contest score. The official presents.mat file needs to be downloaded. The wrapper has further discussion on efficient methods and current scores.\u003c/p\u003e","function_template":"function  [L,xyTL]=SantaPack(p)\r\n% p is an Nx2\r\n% xyTL is Top Left position of pieces 1:n.\r\n% xyTL created for Speed vs find in a 1Kx1K array\r\n% Place 1:n of p onto L, a 1000x1000 array\r\n% Put p row onto L array. \r\n% If p(1,:) is [2 3]\r\n%[2 3] may be placed as [1 1 1;1 1 1] or [1 1; 1 1;1 1] for box 1\r\n% Note: big boxes typically pack to 95% and small boxes to \u003e98%\r\n\r\n L=zeros(1000);\r\n xyTL=p*0;\r\n\r\n% Placing first 16 pieces\r\n% No piece exceeds 250x250\r\n pxy=[1 251 501 751];\r\n piece=1;\r\n for i=1:4\r\n  for j=1:4\r\n% putting piece on layer\r\n   L(pxy(i):pxy(i)+p(piece,1)-1,pxy(j):pxy(j)+p(piece,2)-1)=piece; \r\n% TL Location of piece\r\n   xyTL(piece,:)=[pxy(i) pxy(j)]; \r\n   piece=piece+1;\r\n  end\r\n end\r\n %figure(3);imagesc(L)\r\n \r\nend % SantaPack","test_suite":"assignin('caller','score',100000);\r\n%%\r\nSanta_L1=[3     2;207    73;160    78;8     3;\r\n     9     9;\r\n   170   120;116    91;\r\n   206   142;28     8;\r\n     3     2;41    22;\r\n    31    11;28    20;\r\n    29    13;98    96;\r\n    26     4;34     9;\r\n     4     3;84    78;\r\n   219   114;28    22;\r\n   195   185;3     2;\r\n    31     9;104   101;\r\n    32    31;188   142;\r\n    45    18;8     2;\r\n    13    10;49    22;\r\n   172    72;28    17;\r\n    90    87;33     5;\r\n    32    23;16    14;\r\n    42    18;32     8;\r\n     7     5;6     6;\r\n   201    69;20    11;\r\n    30    18;211   120;\r\n   206    97;3     2;\r\n   124    92;48    43;\r\n     2     2;173   103;\r\n    26    12;8     7;\r\n     8     8;57    33;\r\n    21    20;24    15;\r\n    26    12;44    24;\r\n    30     8;\r\n    43    26;\r\n    23    23;\r\n     9     4;\r\n    16    13;\r\n    58    29;\r\n   133   125;\r\n     5     2;\r\n   197   117;\r\n    39    10;\r\n    31    11;\r\n    41    18;\r\n     6     3;\r\n    31     8;\r\n    40    32;\r\n    41    39;\r\n    36    30;\r\n     2     2;\r\n    25    24;\r\n     6     2;\r\n     3     2;\r\n     2     2;\r\n    85    70;\r\n    37    25;\r\n    24    20;\r\n    60    26;\r\n    29    14;\r\n    49    30;\r\n   153    75;\r\n     6     3;\r\n     7     3;\r\n   185   162;\r\n     4     2;\r\n     6     5;\r\n   176    99;\r\n     4     2;\r\n   219   154;\r\n    24    22;\r\n   148    87;\r\n    32     7;\r\n   143    98;\r\n    23    13;\r\n   150    65;\r\n     5     2;\r\n    53    41;\r\n    25    12;\r\n    36     6;\r\n    21    10;\r\n   211    79;\r\n   183   130;\r\n     6     3;\r\n    36    28;\r\n    32    16;\r\n    21    15;\r\n    27    26;\r\n    39    14;\r\n    36     7;\r\n    57    17;\r\n   214    90;\r\n    36     5;\r\n    27    16;\r\n    52    15;\r\n     8     6;\r\n     5     4;\r\n    52    37;\r\n     7     2;\r\n    92    79;\r\n    37    35;\r\n    33     5;\r\n     5     2;\r\n    52    10;\r\n    29     5;\r\n    44    18;\r\n     8     5;\r\n    16     8;\r\n   137   105;\r\n    78    74;\r\n     9     5;\r\n    39    29;\r\n    43    31;\r\n     6     3;\r\n     8     4;\r\n    26    19;\r\n    22     7;\r\n    30    15;\r\n   199   195;\r\n     7     7;\r\n     7     5;\r\n   134    81;\r\n   206   108;\r\n    54    29;\r\n    16     7;\r\n   116    99;\r\n    35    23;\r\n    31    17;\r\n    56    11;\r\n     7     3;\r\n    52     5;\r\n   102    99;\r\n     5     5;\r\n    35    17;\r\n     8     6;\r\n    51     7;\r\n    28    16;\r\n   107    83;\r\n    26     8;\r\n     8     6;\r\n   149    83;\r\n    45    29;\r\n    55    52;\r\n    27     6;\r\n    82    81;\r\n     9     5;\r\n    27    21;\r\n    19    10;\r\n    56    26;\r\n    19    14;\r\n    11     8;\r\n    47     7;\r\n    26    13;\r\n    36    19;\r\n    87    73;\r\n    14    10;223   100;2     2;33     5;198   135;38    15;19     8;211    95;9     6;21     7;175   145;22    16;7     5;7     4;9     8;42     5;3     3;2     2;3     2;5     2;30    24;29    29;27     9;168    72;6     4;22     7;9     6;10     6;19    16;7     2;43    14;138   115;138   130;39    20;9     4;27     7;26    22;169   144;8     8;41     9;50    26;62    10;33    19;7     2;121   112;102    93;109    88;9     8;40    40;25    19;31     8;55    23;41    11;6     2;8     3;128   114;40    16;7     6;5     2];\r\n[L,xyTL]=SantaPack(Santa_L1);\r\nptrxy=find(xyTL(:,1)\u003e0,1,'last');\r\n\r\npresents=Santa_L1;\r\nfor k=1:ptrxy\r\n  ptrxmin=xyTL(k,1);\r\n  ptrymin=xyTL(k,2);\r\n  assert(isequal(L(ptrxmin,ptrymin),k)) % Verify TL corner\r\n\r\n  if ptrxmin+presents(k,1)-1\u003e1000 || ptrymin+presents(k,2)-1\u003e1000\r\n% BR Corner verify for rotated only fit case\r\n    assert(isequal(L(ptrxmin+presents(k,2)-1,ptrymin+presents(k,1)-1),k))\r\n  elseif ptrxmin+presents(k,2)-1\u003e1000 || ptrymin+presents(k,1)-1\u003e1000\r\n% BR corner verify for non-rotated only fit case\r\n    assert(isequal(L(ptrxmin+presents(k,1)-1,ptrymin+presents(k,2)-1),k))\r\n  else % rot or non-rot case\r\n   v1=L(ptrxmin+presents(k,2)-1,ptrymin+presents(k,1)-1)==k;\r\n   v2=L(ptrxmin+presents(k,1)-1,ptrymin+presents(k,2)-1)==k;\r\n   assert(v1 || v2); % simple corner check\r\n  end\r\n% More robust checks may be implemented if needed\r\nend\r\n   \r\n\r\nA=Santa_L1(:,1).*Santa_L1(:,2);\r\nAs=sum(A(1:ptrxy))\r\nassignin('caller','score',min(100000,1000000-As));\r\n%%\r\n%{\r\nfunction SantaPack_Cody\r\n% www.kaggle.com Santa Packing Contest \r\n% 11/2013 thru January 2014\r\n% Given 1 Million Rectangularoid packages\r\n% Fit Packages into a Minimum Heigth Box with a base of 1000 x 1000\r\n% Rules allow presents out of order but this is virtually non-optimiziable\r\n% Presents out of order incur a penalty\r\n% Packing Construction Here:\r\n% All boxes dimension sorted [Mid, Min, Max]\r\n% Boxes 1:236 all have their tops on the same plane (97.5719% efficient pack)\r\n% Boxes 237:423 have their tops 250 lower in Z. Max Z of 1:236 is 250.\r\n% The very bottom layer, with box 1000000 has bottom box at Z=1\r\n% Note: Max dimension after box 700,000 is 70\r\n% This construction has min cross area per present, max dimension is placed on Z\r\n% Input is presents that have cumulative area \u003c= 1000000\r\n% The optimal score with perfect layer packing is \r\n% Layers 4098  zsum 996483  Score 1,992,966\r\n% Layers 4210, Score of 2,047,696 is possible with sequence layer packing\r\n% Kaggle Lead as of 12/21/2013 is 1,999,256. Unknown method.\r\n% Pack routine returns a 1000x1000 array with values 1:n, n\u003c=N\r\n% N is the Nth  box that fits in the 1,000,000 area limit\r\n% Next call uses n+1:N\r\n\r\nload presents  % available at kaggle site as a Mat file\r\nnumPresents = size(presents,1);\r\n\r\npresents(:,2:4)=sort(presents(:,2:4),2);\r\npresents(:,2:3)=fliplr(sort(presents(:,2:3),2)); % x\u003ey, z\u003ex\r\npresents=[presents presents(:,2).*presents(:,3)]; % Area of box tops\r\npresents=[presents cumsum(presents(:,end))]; % [presID x y z A Asum]\r\n\r\npe=0;\r\nLayer=0;\r\nzsum=0;\r\nz=-1;\r\npresentCoords=zeros(1000000,25);\r\n\r\ntic\r\nwhile pe\u003c1000000\r\n ps=pe+1; \r\n Asum=presents(ps:min(ps+5000,1000000),end); % valid for layer 1\r\n if pe\u003e0, Asum=Asum-presents(pe,end); end% remove prior layers sum\r\n ptr1M=find(Asum\u003c=1000000,1,'last');\r\n pe=ps+ptr1M-1;\r\n \r\n [L,xyTL]=SantaPack(presents(ps:pe,2:3)); % L has values 1 thru n, being ps thru ps+n-1\r\n % xyTL is Top Left position of pieces 1:n\r\n %figure(3);imagesc(L);\r\n\r\n pe=ps-1+find(xyTL(:,1)\u003e0,1,'last'); % find number of boxes placed\r\n zmax=max(presents(ps:pe,4));\r\n \r\n % Convert Layers to coordinates\r\n % Locate pieces in Layer and assign coordinate values\r\n % z axis values fixed in post processing to positives\r\n % Valid placement and sizes assumed\r\n for k=1:pe-ps+1\r\n  idx=k+ps-1; \r\n  ptrxmin=xyTL(k,1);\r\n  ptrymin=xyTL(k,2);\r\n  if ptrxmin+presents(idx,2)-1\u003c=1000 \u0026\u0026 ptrymin+presents(idx,3)-1\u003c=1000\r\n   if L(ptrxmin+presents(idx,2)-1,ptrymin+presents(idx,3)-1)==k\r\n    ptrxmax=ptrxmin+presents(idx,2)-1;\r\n    ptrymax=ptrymin+presents(idx,3)-1;\r\n   else\r\n    ptrxmax=ptrxmin+presents(idx,3)-1;\r\n    ptrymax=ptrymin+presents(idx,2)-1;\r\n   end\r\n  else % assumed placement if xmax(1)\u003e1000\r\n   ptrxmax=ptrxmin+presents(idx,3)-1;\r\n   ptrymax=ptrymin+presents(idx,2)-1;\r\n  end % if\r\n  \r\n % place this section inside SantaPack and output presentCoords vs L\r\n    presentCoords(idx,1) = idx;\r\n    presentCoords(idx,[2 8 14 20]) = ptrxmin;\r\n    presentCoords(idx,[5 11 17 23]) = ptrxmax;\r\n    presentCoords(idx,[3 6 15 18]) = ptrymin;\r\n    presentCoords(idx,[9 12 21 24]) = ptrymax;\r\n    presentCoords(idx,[4 7 10 13]) = z;\r\n    presentCoords(idx,[16 19 22 25]) = z - presents(idx,4) + 1;\r\n end % k\r\n \r\n z=z-zmax;\r\n Layer=Layer+1;\r\n zsum=zsum+zmax;\r\n fprintf('Layer %i Start %i  Final %i Zsum %i  Time %.2f\\n',Layer,ps,pe,zsum,toc) % Processing Status\r\n % Deep routine to 2M takes 30 minutes\r\n % Fast Placement takes 187 sec\r\n \r\nend  % pe\r\n\r\n% Offset Z coordinates \r\n% Bottom is 1 and very top is Positive\r\nzCoords = presentCoords(:,4:3:end);\r\nminZ = min(zCoords(:));\r\npresentCoords(:,4:3:end) = zCoords - minZ + 1;\r\n\r\n% Scoring function\r\n% Ideal order is the original order\r\npresentIDs = presents(:,1); %z\r\nidealOrder = presentIDs; \r\n\r\n% Determine the max z-coordinate; this is the max height of the box\r\nmaxZ = max(max(presentCoords(:,4:3:end)));\r\n\r\n% Go down the layers from top to bottom, reorder presents in numeric order\r\n% for each layer\r\nmaxZCoord = zeros(numPresents,2);\r\nfor i = 1:numPresents\r\n    maxZCoord(i,1) = presentCoords(i);\r\n    maxZCoord(i,2) = max(presentCoords(i,4:3:end));\r\nend\r\nmaxzCoordSorted = sortrows(maxZCoord,[-2 1]); %sort max z-coord for each present\r\nreOrder = maxzCoordSorted(:,1);\r\n\r\n% Compare the new order to the ideal order\r\norder = sum(abs(idealOrder - reOrder));\r\n\r\n% Compute metric\r\nfprintf('Metric %i MaxZ %i  Order Penalty %i\\n',2*maxZ + order,maxZ,order);\r\n\r\n% Creating a Submission File\r\nsubfile = 'submissionfile_SantaPack_Cody.csv';\r\nfileID = fopen(subfile, 'w');\r\nheaders = {'PresentId','x1','y1','z1','x2','y2','z2','x3','y3','z3','x4','y4','z4','x5','y5','z5','x6','y6','z6','x7','y7','z7','x8','y8','z8'};\r\nfprintf(fileID,'%s,',headers{1,1:end-1});\r\nfprintf(fileID,'%s\\n',headers{1,end});\r\nfprintf(fileID,'%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\\n',presentCoords');\r\nfclose(fileID);\r\n\r\nend % SantaPack_Cody\r\n\r\nfunction  [L,xyTL]=SantaPack(p)\r\n% p is an Nx2\r\n% xyTL is Top Left position of pieces 1:n\r\n% Place 1:n of p onto L, a 1000x1000 array\r\n% Put p row onto L array. [2 3] may be placed [1 1 1;1 1 1] or [1 1; 1 1;1 1] for box 1\r\n% Note: big boxes typically pack to 95% and small boxes to \u003e98%\r\n\r\n L=zeros(1000);\r\n xyTL=p*0;\r\n% L(1:p(1,1),1:p(1,2))=1; % putting one piece per layer\r\n% return\r\n\r\n% Placing first 16 pieces\r\n% No piece exceeds 250x250\r\n pxy=[1 251 501 751];\r\n piece=1;\r\n for i=1:4\r\n  for j=1:4\r\n   L(pxy(i):pxy(i)+p(piece,1)-1,pxy(j):pxy(j)+p(piece,2)-1)=piece; % putting piece on layer\r\n   xyTL(piece,:)=[pxy(i) pxy(j)]; % Location of piece\r\n   piece=piece+1;\r\n  end\r\n end\r\n %figure(3);imagesc(L)\r\n \r\nend % SantaPack\r\n%}\r\n\r\n","published":true,"deleted":false,"likes_count":0,"comments_count":0,"created_by":3097,"edited_by":null,"edited_at":null,"deleted_by":null,"deleted_at":null,"solvers_count":4,"test_suite_updated_at":null,"rescore_all_solutions":false,"group_id":1,"created_at":"2013-12-22T04:12:10.000Z","updated_at":"2013-12-22T05:37:27.000Z","published_at":"2013-12-22T05:37:27.000Z","restored_at":null,"restored_by":null,"spam":false,"simulink":false,"admin_reviewed":false,"description_opc":"{\"relationships\":[{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/document\",\"targetMode\":\"\",\"relationshipId\":\"rId1\",\"target\":\"/matlab/document.xml\"},{\"relationshipType\":\"http://schemas.mathworks.com/matlab/code/2013/relationships/output\",\"targetMode\":\"\",\"relationshipId\":\"rId2\",\"target\":\"/matlab/output.xml\"}],\"parts\":[{\"partUri\":\"/matlab/document.xml\",\"relationship\":[],\"contentType\":\"application/vnd.mathworks.matlab.code.document+xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\"?\u003e\\n\u003cw:document xmlns:w=\\\"http://schemas.openxmlformats.org/wordprocessingml/2006/main\\\"\u003e\u003cw:body\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is inspired by 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=\\\"http://www.kaggle.com/c/packing-santas-sleigh\\\"\u003e\u003cw:r\u003e\u003cw:t\u003ePacking Santa's Sleigh\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:hyperlink\u003e\u003cw:r\u003e\u003cw:t\u003e contest at kaggle that runs until January 26, 2014.\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 Bag has a 1000 x 1000 base with the contest having 1,000,000 packages.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eThis Challenge is to place as many of the first N Santa Presents onto the 1000 x 1000 grid. The packages have been presorted to have Z as max, not provided, thus minimizing the X*Y cross section. Only the first 240 packages are provided as package 241 busts the bag bottom making an area greater than 1,000,000. Packages out of sequence cause a severe penalty thus all packages less than the highest package used must fit on the board.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eInput\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: Presents ; Presents(240,2)\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eOutput\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: L, xyTL; L(1000,1000) of values 0:n\u0026lt;=240, 0 is unused space\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eScoring\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e: Unused Area\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eExample\u003c/w:t\u003e\u003c/w:r\u003e\u003cw:r\u003e\u003cw:t\u003e:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003e[2 2;3 3;1 2] is Presents\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\u003eL\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 1 2 2 2 0  thru column 1000\\n1 1 2 2 2\\n3 3 2 2 2\\n0 0 0 0 0 0 rows 4 thru 1000 are zeros]]\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\u003exyTL [1 1;1 3;3 1]\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eScores 1,000,000 - 15= 999985\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\u003eBoxes 1:236 are possible, 97.5719% efficient pack in \u0026lt; 1sec.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:rPr\u003e\u003cw:b/\u003e\u003c/w:rPr\u003e\u003cw:t\u003eTestSuite Sample Code:\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003cw:p\u003e\u003cw:pPr\u003e\u003cw:pStyle w:val=\\\"text\\\"/\u003e\u003c/w:pPr\u003e\u003cw:r\u003e\u003cw:t\u003eIn the TestSuite at the end is wrapper code for entering the kaggle contest. Update your SantaPack routine and execute the wrapper to see your contest score. The official presents.mat file needs to be downloaded. The wrapper has further discussion on efficient methods and current scores.\u003c/w:t\u003e\u003c/w:r\u003e\u003c/w:p\u003e\u003c/w:body\u003e\u003c/w:document\u003e\"},{\"partUri\":\"/matlab/output.xml\",\"contentType\":\"text/xml\",\"content\":\"\u003c?xml version=\\\"1.0\\\" encoding=\\\"UTF-8\\\" standalone=\\\"no\\\" ?\u003e\u003cembeddedOutputs\u003e\u003cmetaData\u003e\u003cevaluationState\u003emanual\u003c/evaluationState\u003e\u003clayoutState\u003ecode\u003c/layoutState\u003e\u003coutputStatus\u003eready\u003c/outputStatus\u003e\u003c/metaData\u003e\u003coutputArray type=\\\"array\\\"/\u003e\u003cregionArray type=\\\"array\\\"/\u003e\u003c/embeddedOutputs\u003e\"}]}"}],"term":"tag:\"2d\"","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:\"2d\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"2d\"","","\"","2d","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f5e6ae9de80\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f5e6ae9dde0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f5e6ae9d520\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f5e6ae9e100\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f5e6ae9e060\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f5e6ae9dfc0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f5e6ae9df20\u003e":"tag:\"2d\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f5e6ae9df20\u003e":"tag:\"2d\""},"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:\"2d\"","current_player":null,"sort":"map(difficulty_value,0,0,999) asc"},"parser":"MathWorks::Search::Solr::QueryParser","directives":{"term":{"directives":{"tag":[["tag:\"2d\"","","\"","2d","\""]]}}},"facets":{"#\u003cMathWorks::Search::Field:0x00007f5e6ae9de80\u003e":null,"#\u003cMathWorks::Search::Field:0x00007f5e6ae9dde0\u003e":null},"filters":{"#\u003cMathWorks::Search::Field:0x00007f5e6ae9d520\u003e":"\"cody:problem\""},"fields":{"#\u003cMathWorks::Search::Field:0x00007f5e6ae9e100\u003e":1,"#\u003cMathWorks::Search::Field:0x00007f5e6ae9e060\u003e":50,"#\u003cMathWorks::Search::Field:0x00007f5e6ae9dfc0\u003e":"map(difficulty_value,0,0,999) asc","#\u003cMathWorks::Search::Field:0x00007f5e6ae9df20\u003e":"tag:\"2d\""},"user_query":{"#\u003cMathWorks::Search::Field:0x00007f5e6ae9df20\u003e":"tag:\"2d\""},"queried_facets":{}},"options":{"fields":["id","difficulty_rating"]},"join":" "},"results":[{"id":486,"difficulty_rating":"easy-medium"},{"id":56473,"difficulty_rating":"easy-medium"},{"id":56468,"difficulty_rating":"medium"},{"id":2072,"difficulty_rating":"medium"}]}}