{"id":9227,"date":"2022-09-25T12:00:41","date_gmt":"2022-09-25T16:00:41","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=9227"},"modified":"2022-09-28T19:22:18","modified_gmt":"2022-09-28T23:22:18","slug":"trio-a-wooden-puzzle-from-the-czech-republic","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2022\/09\/25\/trio-a-wooden-puzzle-from-the-czech-republic\/","title":{"rendered":"Trio, A Wooden Puzzle from the Czech Republic"},"content":{"rendered":"\r\n\r\n<div class=\"content\"><!--introduction--><p>\"Clever Toys\" is a puzzle company in the Czech Republic. <a href=\"http:\/\/www.clevertoys.cz\/index_eng.php?page=eng\">Their Web site<\/a> describes five different hand-made, wooden puzzles that are related mathematically to the Rubik's Cube.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#52520048-f34a-4981-840a-9007a0387f6b\">Puzzle<\/a><\/li><li><a href=\"#2dfd1830-7360-4517-9796-4632c066c884\">Model<\/a><\/li><li><a href=\"#99075c53-97fe-4397-a096-3baedc01f129\">Scramble<\/a><\/li><li><a href=\"#a45994ba-ec9b-49ab-b897-d0f79de81dcd\">Animation<\/a><\/li><li><a href=\"#ff195cfa-9e7f-4693-9c9e-5109eebc19c4\">Unscramble<\/a><\/li><li><a href=\"#87972e4e-c85c-4982-8459-add195223548\">Solutions<\/a><\/li><li><a href=\"#2e58ba8b-073a-402d-8259-2f095e0e72d2\">Software<\/a><\/li><li><a href=\"#0c756fc0-bf5b-4ccc-8d56-8eab84048dee\">Thanks<\/a><\/li><\/ul><\/div><h4>Puzzle<a name=\"52520048-f34a-4981-840a-9007a0387f6b\"><\/a><\/h4><p>Here is the photo of the puzzle \"Trio\".<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/trio_puzzle.png\" alt=\"\"> <\/p><p>Here is an English translation of their description.<\/p><p>\r\n<p style=\"margin-left:3ex;\">\r\nThe task of this 2D puzzle is to assemble all the ovals according\r\nto their color into a basic assembly. By moving the balls in the\r\ngrooves and turning the center wheel, you can gradually get each\r\nball where you need it.\r\n<\/p>\r\n<\/p><p>I am not sure that Clever Toys is still in business. They have not responded to my emails and I have not been able to purchase an actual Trio puzzle.  Of course, that is all the motivation I need to make a MATLAB model.<\/p><h4>Model<a name=\"2dfd1830-7360-4517-9796-4632c066c884\"><\/a><\/h4><p>Here is the initial configuration.  There are three fixed outer, partial, discs and one inner, full, disc.  Each of the outer discs has a channel containing 10 marbles.  When the inner disc is positioned properly, the marbles in a channel can be rotated.  Rotating the inner disc itself moves some, but not all, of the marbles, thereby scrambling the colors.<\/p><p>Like Rubik's Cube, the objective of the puzzle is to return to this initial \"solved\" state.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/trio_initial.gif\" alt=\"\"> <\/p><p>Mathematically, both Rubik's Cube and Trio are ultimately based upon rotation matrices.  Rubik's Cube is a 3-D puzzle whose state is specified by the position and orientation of 27 cubelets; this gives Rubik's Cube about <tt>4.3*10^19<\/tt> possible positions. At each step, there are six faces and 12 possible rotations.<\/p><p>Trio is a 2-D puzzle whose state is specified by the colors of the marbles.  There are 10 marbles of each of three colors; this implies that Trio has <tt>30!\/(10!)^3 = 5.6*10^12<\/tt> possible positions.  At each step, there are eight possible rotations, four discs, clockwise or counter-clockwise.<\/p><h4>Scramble<a name=\"99075c53-97fe-4397-a096-3baedc01f129\"><\/a><\/h4><p>A \"scramble\" is an integer vector with elements between -4 and +4 that specify moves or rotations.  Move 0 initializes the model.  Move <tt>d<\/tt> with <tt>d<\/tt> equal to 1, 2, or 3 rotates all the marbles in the <tt>d<\/tt>-th channel counter-clockwise for one-tenth of a full rotation.  Move <tt>d<\/tt> with <tt>d<\/tt> equal to -1, -2, or -3 is the corresponding clockwise rotation. Moves -4 and 4 turn the central disc clockwise or counter-clockwise for one-third of a full rotation.  This rotates some, but not all, of the marbles and mixes the colors.<\/p><p>Here is a scramble of length 29 that provides our example.<\/p><p>D = [ 4 1 3 1 1 -2  3  1  4  4  2  4  4 -3 -3 -2 -3 -3  2  1  4 -1  3 -4  2]<\/p><p>And here is the scrambled result.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/trio_scrambled.gif\" alt=\"\"> <\/p><h4>Animation<a name=\"a45994ba-ec9b-49ab-b897-d0f79de81dcd\"><\/a><\/h4><p>This animated gif shows the scrambling process one move at a time. The animation does not repeat automatically, so to start it over again, refresh your browser. If it still doesn't move, find another browser.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/trio_scramble.gif\" alt=\"\"> <\/p><h4>Unscramble<a name=\"ff195cfa-9e7f-4693-9c9e-5109eebc19c4\"><\/a><\/h4><p>Reverse the scramble by running it backwards, changing the sign of each move.  This will return the scrambled position to the initial position. I call this \"unscramble\"; it solves the scrambled position by a \"follow the breadcrumbs\" algorithm.<\/p><p>Both animations take a long time to run -- about 80 seconds with my browser.<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/trio_unscramble.gif\" alt=\"\"> <\/p><h4>Solutions<a name=\"87972e4e-c85c-4982-8459-add195223548\"><\/a><\/h4><p>I don't have any idea about how to actually solve a given position without using knowledge of how it was generated, and I don't have any idea about how to quantify the difficulty of finding a solution. This is in sharp contrast to Rubik's Cube where there are measures of difficulty and algorithms for finding optimum solutions.<\/p><h4>Software<a name=\"2e58ba8b-073a-402d-8259-2f095e0e72d2\"><\/a><\/h4><p>The program available at <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/trioo.m\">this link<\/a> is interactive.  Click or alt-click in any one of the four discs to make a move in that disc.<\/p><h4>Thanks<a name=\"0c756fc0-bf5b-4ccc-8d56-8eab84048dee\"><\/a><\/h4><p>Thanks to Steve Eddins and Tom Lane for help with this post.<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_233d0111a3a04a7896bd6aac6263df7c() {\r\n        \/\/ Remember the title so we can use it in the new page\r\n        title = document.title;\r\n\r\n        \/\/ Break up these strings so that their presence\r\n        \/\/ in the Javascript doesn't mess up the search for\r\n        \/\/ the MATLAB code.\r\n        t1='233d0111a3a04a7896bd6aac6263df7c ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 233d0111a3a04a7896bd6aac6263df7c';\r\n    \r\n        b=document.getElementsByTagName('body')[0];\r\n        i1=b.innerHTML.indexOf(t1)+t1.length;\r\n        i2=b.innerHTML.indexOf(t2);\r\n \r\n        code_string = b.innerHTML.substring(i1, i2);\r\n        code_string = code_string.replace(\/REPLACE_WITH_DASH_DASH\/g,'--');\r\n\r\n        \/\/ Use \/x3C\/g instead of the less-than character to avoid errors \r\n        \/\/ in the XML parser.\r\n        \/\/ Use '\\x26#60;' instead of '<' so that the XML parser\r\n        \/\/ doesn't go ahead and substitute the less-than character. \r\n        code_string = code_string.replace(\/\\x3C\/g, '\\x26#60;');\r\n\r\n        copyright = 'Copyright 2022 The MathWorks, Inc.';\r\n\r\n        w = window.open();\r\n        d = w.document;\r\n        d.write('<pre>\\n');\r\n        d.write(code_string);\r\n\r\n        \/\/ Add copyright line at the bottom if specified.\r\n        if (copyright.length > 0) {\r\n            d.writeln('');\r\n            d.writeln('%%');\r\n            if (copyright.length > 0) {\r\n                d.writeln('% _' + copyright + '_');\r\n            }\r\n        }\r\n\r\n        d.write('<\/pre>\\n');\r\n\r\n        d.title = title + ' (MATLAB code)';\r\n        d.close();\r\n    }   \r\n     --> <\/script><p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\"><br><a href=\"javascript:grabCode_233d0111a3a04a7896bd6aac6263df7c()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript><\/span><\/a><br><br>\r\n      Published with MATLAB&reg; R2022b<br><\/p><\/div><!--\r\n233d0111a3a04a7896bd6aac6263df7c ##### SOURCE BEGIN #####\r\n%% Trio, A Wooden Puzzle from the Czech Republic\r\n% \"Clever Toys\" is a puzzle company in the Czech Republic.\r\n% <http:\/\/www.clevertoys.cz\/index_eng.php?page=eng\r\n% Their Web site> describes five different hand-made, wooden puzzles\r\n% that are related mathematically to the Rubik's Cube.\r\n%% Puzzle\r\n% Here is the photo of the puzzle \"Trio\".\r\n%\r\n% <<trio_puzzle.png>>\r\n%\r\n\r\n%%\r\n% Here is an English translation of their description.\r\n%\r\n% <html>\r\n% <p style=\"margin-left:3ex;\">\r\n% The task of this 2D puzzle is to assemble all the ovals according\r\n% to their color into a basic assembly. By moving the balls in the \r\n% grooves and turning the center wheel, you can gradually get each \r\n% ball where you need it.\r\n% <\/p>\r\n% <\/html>\r\n%\r\n% I am not sure that Clever Toys is still in business.\r\n% They have not responded to my emails and I have not been able\r\n% to purchase an actual Trio puzzle.  Of course, that is all the\r\n% motivation I need to make a MATLAB model.\r\n\r\n%% Model\r\n% Here is the initial configuration.  There are three fixed outer, partial,\r\n% discs and one inner, full, disc.  Each of the outer discs has a channel\r\n% containing 10 marbles.  When the inner disc is positioned properly,\r\n% the marbles in a channel can be rotated.  Rotating the inner disc\r\n% itself moves some, but not all, of the marbles, thereby scrambling\r\n% the colors.\r\n%\r\n% Like Rubik's Cube, the objective of the puzzle is to return to this\r\n% initial \"solved\" state.\r\n%\r\n% <<trio_initial.gif>>\r\n%\r\n\r\n%%\r\n% Mathematically, both Rubik's Cube and Trio are ultimately based upon\r\n% rotation matrices.  Rubik's Cube is a 3-D puzzle whose state is\r\n% specified by the position and orientation of 27 cubelets;\r\n% this gives Rubik's Cube about |4.3*10^19| possible positions.\r\n% At each step, there are six faces and 12 possible rotations.\r\n%\r\n% Trio is a 2-D puzzle whose state is specified by the colors of the\r\n% marbles.  There are 10 marbles of each of three colors;\r\n% this implies that Trio has |30!\/(10!)^3 = 5.6*10^12| possible\r\n% positions.  At each step, there are eight possible rotations,\r\n% four discs, clockwise or counter-clockwise.\r\n\r\n%% Scramble\r\n% A \"scramble\" is an integer vector with elements between -4 and +4 that\r\n% specify moves or rotations.  Move 0 initializes the model.  Move |d| with\r\n% |d| equal to 1, 2, or 3 rotates all the marbles in the |d|-th channel\r\n% counter-clockwise for one-tenth of a full rotation.  Move |d| with\r\n% |d| equal to -1, -2, or -3 is the corresponding clockwise rotation.\r\n% Moves -4 and 4 turn the central disc clockwise or counter-clockwise\r\n% for one-third of a full rotation.  This rotates some, but not all, of \r\n% the marbles and mixes the colors.\r\n\r\n%%\r\n% Here is a scramble of length 29 that provides our example.\r\n%\r\n% D = [ 4 1 3 1 1 -2  3  1  4  4  2  4  4 -3 -3 -2 -3 -3  2  1  4 -1  3 -4  2]\r\n%\r\n% And here is the scrambled result.\r\n%\r\n% <<trio_scrambled.gif>>\r\n\r\n%% Animation\r\n% This animated gif shows the scrambling process one move at a time.\r\n% The animation does not repeat automatically, so to start it over again, \r\n% refresh your browser.\r\n% If it still doesn't move, find another browser.\r\n%\r\n% <<trio_scramble.gif>>\r\n%\r\n\r\n%% Unscramble\r\n% Reverse the scramble by running it backwards, changing the sign of\r\n% each move.  This will return the scrambled position to the initial\r\n% position. I call this \"unscramble\"; it solves the scrambled position\r\n% by a \"follow the breadcrumbs\" algorithm.\r\n%\r\n% Both animations take a long time to run REPLACE_WITH_DASH_DASH about 80 seconds\r\n% with my browser.\r\n%\r\n% <<trio_unscramble.gif>>\r\n%\r\n\r\n%% Solutions\r\n% I don't have any idea about how to actually solve a given position\r\n% without using knowledge of how it was generated, and I don't have \r\n% any idea about how to quantify the difficulty of finding a solution.\r\n% This is in sharp contrast to Rubik's Cube where there are measures\r\n% of difficulty and algorithms for finding optimum solutions.\r\n\r\n%% Software\r\n% The program available at\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/trioo.m  this link>\r\n% is interactive.  Click or alt-click in any one of the four discs\r\n% to make a move in that disc.\r\n\r\n%% Thanks\r\n% Thanks to Steve Eddins and Tom Lane for help with this post.\r\n##### SOURCE END ##### 233d0111a3a04a7896bd6aac6263df7c\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/before_after.gif\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction--><p>\"Clever Toys\" is a puzzle company in the Czech Republic. <a href=\"http:\/\/www.clevertoys.cz\/index_eng.php?page=eng\">Their Web site<\/a> describes five different hand-made, wooden puzzles that are related mathematically to the Rubik's Cube.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2022\/09\/25\/trio-a-wooden-puzzle-from-the-czech-republic\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":9263,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,23,47,39],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/9227"}],"collection":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/users\/78"}],"replies":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/comments?post=9227"}],"version-history":[{"count":11,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/9227\/revisions"}],"predecessor-version":[{"id":9272,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/9227\/revisions\/9272"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/9263"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=9227"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=9227"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=9227"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}