{"id":8768,"date":"2022-06-10T04:07:52","date_gmt":"2022-06-10T08:07:52","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=8768"},"modified":"2022-06-12T19:29:30","modified_gmt":"2022-06-12T23:29:30","slug":"the-soma-cube-again","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2022\/06\/10\/the-soma-cube-again\/","title":{"rendered":"The Soma Cube, Again"},"content":{"rendered":"\r\n\r\n<div class=\"content\"><!--introduction--><p>The Soma Cube brings back memories.<\/p><!--\/introduction--><h3>Contents<\/h3><div><ul><li><a href=\"#d24e61ac-9d35-47eb-bca6-357702418141\">Piet Hein<\/a><\/li><li><a href=\"#1d20680b-94e4-464d-84a6-7481a2c30e00\">Bill McKeeman<\/a><\/li><li><a href=\"#3432acb9-d2ca-49a7-ac3a-b8327c5e7f9a\">The original <tt>soma<\/tt> demo<\/a><\/li><li><a href=\"#412ef701-867b-45f9-9d16-b38a8bd051b1\">A new <tt>Soma<\/tt> demo<\/a><\/li><li><a href=\"#0c997775-0706-4f98-855c-23e311f68cb0\">Software<\/a><\/li><li><a href=\"#3b67595f-6619-4959-8d78-0417f13c73a3\">Update<\/a><\/li><\/ul><\/div><h4>Piet Hein<a name=\"d24e61ac-9d35-47eb-bca6-357702418141\"><\/a><\/h4><p>Piet Hein (1905-1996) was an extraordinary Danish inventor, mathematician, poet and philosopher.  He invented the <a href=\"https:\/\/en.wikipedia.org\/wiki\/Soma_cube\">Soma Cube puzzle<\/a> in 1933. I wrote a blog post about Hein and some of his creations several years ago, <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2016\/03\/28\/piet-hein-super-ellipses-and-soma-cubes\">Soma Cube 2016<\/a>.<\/p><p>The Soma Cube puzzle has seven pieces.  One of them is a V-shaped piece made from three cubelets.   The other six pieces are L, T, Z, R, S, and Y with four cubelets each.  That's a total of 27 cubelets, just enough to make a 3-by-3-by-3 cube.  Sound familiar?<\/p><h4>Bill McKeeman<a name=\"1d20680b-94e4-464d-84a6-7481a2c30e00\"><\/a><\/h4><p>Bill McKeeman and I were buddies in grad school.  He was a professor at U. C. Santa Cruz for a while, and then at the ill-fated Wang Institute of Graduate Studies in Tyngsborough, Mass.  He worked for DEC in New Hampshire for  a long time, taught compilers at Dartmouth, and even consulted for the MathWorks.  As an exercise to learn MATLAB, he wrote the modern version of our <tt>why<\/tt> command.<\/p><h4>The original <tt>soma<\/tt> demo<a name=\"3432acb9-d2ca-49a7-ac3a-b8327c5e7f9a\"><\/a><\/h4><p>Bill and I became obsessed with the Soma cube after Martin Gardiner described the puzzle in his <i>Scientific American<\/i> column. You may not have noticed it before, but one of Bill's programs, <tt>soma<\/tt>, is in the MATLAB <tt>demos<\/tt> directory. Bill generated all of the 240 distinctly different puzzle solutions and stored them in a 240-by-27 matrix, <tt>demos\/somasols<\/tt>. His program lets you page through the solutions.<\/p><h4>A new <tt>Soma<\/tt> demo<a name=\"412ef701-867b-45f9-9d16-b38a8bd051b1\"><\/a><\/h4><p>My new <tt>Soma<\/tt> code uses technology from <tt>Qube<\/tt>, the digital Rubik's Cube simulator, to plot the 240 solutions. Here are the seven Soma pieces, surrounding an animation stepping through every tenth solution.<\/p><p>Do you recognize the colors?<\/p><p><img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"http:\/\/blogs.mathworks.com\/cleve\/files\/Soma24.gif\" alt=\"\"> <\/p><h4>Software<a name=\"0c997775-0706-4f98-855c-23e311f68cb0\"><\/a><\/h4><p><tt>Soma<\/tt> is available from <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/Soma.m\">this link<\/a>. You already have <tt>somasols<\/tt>, but another copy is available from <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/somasols.m\">this link<\/a>.<\/p><h4>Update<a name=\"3b67595f-6619-4959-8d78-0417f13c73a3\"><\/a><\/h4><p>I have combined my new display code and McKeeman's old program that finds all the solutions.  The self-extracting archive is available at <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/Soma_osf.m\">&lt;https:\/\/blogs.mathworks.com\/cleve\/files\/Soma_osf.m<\/a>&gt;<\/p><script language=\"JavaScript\"> <!-- \r\n    function grabCode_ba03413b3d6846149e5b9f9e92eb3300() {\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='ba03413b3d6846149e5b9f9e92eb3300 ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' ba03413b3d6846149e5b9f9e92eb3300';\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_ba03413b3d6846149e5b9f9e92eb3300()\"><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\nba03413b3d6846149e5b9f9e92eb3300 ##### SOURCE BEGIN #####\r\n%% The Soma Cube, Again\r\n% The Soma Cube brings back memories.\r\n\r\n%% Piet Hein\r\n% Piet Hein (1905-1996) was an extraordinary Danish inventor, \r\n% mathematician, poet and philosopher.  He invented the \r\n% <https:\/\/en.wikipedia.org\/wiki\/Soma_cube\r\n% Soma Cube puzzle> in 1933.\r\n% I wrote a blog post about Hein and some of his creations several years ago,\r\n% <https:\/\/blogs.mathworks.com\/cleve\/2016\/03\/28\/piet-hein-super-ellipses-and-soma-cubes\r\n% Soma Cube 2016>.\r\n%%\r\n% The Soma Cube puzzle has seven pieces.  One of them is a V-shaped piece\r\n% made from three cubelets.   The other six pieces are L, T, Z, R, S, and Y\r\n% with four cubelets each.  That's a total of 27 cubelets, just enough\r\n% to make a 3-by-3-by-3 cube.  Sound familiar?\r\n\r\n%% Bill McKeeman\r\n% Bill McKeeman and I were buddies in grad school.  He was a professor at\r\n% U. C. Santa Cruz for a while, and then at the ill-fated Wang Institute\r\n% of Graduate Studies in Tyngsborough, Mass.  He worked for \r\n% DEC in New Hampshire for  a long time, taught compilers at Dartmouth, \r\n% and even consulted for the MathWorks.  As an exercise to learn MATLAB,\r\n% he wrote the modern version of our |why| command.\r\n\r\n%% The original |soma| demo\r\n% Bill and I became obsessed with the Soma cube after Martin Gardiner\r\n% described the puzzle in his _Scientific American_ column.\r\n% You may not have noticed it before, but one of Bill's programs,\r\n% |soma|, is in the MATLAB |demos| directory.\r\n% Bill generated all of the 240 distinctly different puzzle solutions\r\n% and stored them in a 240-by-27 matrix, |demos\/somasols|.  \r\n% His program lets you page through the solutions.\r\n\r\n%% A new |Soma| demo\r\n% My new |Soma| code uses technology from |Qube|,\r\n% the digital Rubik's Cube simulator, to plot the 240 solutions.\r\n% Here are the seven Soma pieces, surrounding an animation stepping\r\n% through every tenth solution.\r\n%\r\n% Do you recognize the colors?\r\n%\r\n% <<Soma24.gif>>\r\n%\r\n\r\n%% Software\r\n% |Soma| is available from\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/Soma.m\r\n% this link>.\r\n% You already have |somasols|, but another copy is available from\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/somasols.m\r\n% this link>.\r\n\r\n%% Update\r\n% I have combined my new display code and McKeeman's old program that\r\n% finds all the solutions.  The self-extracting archive is available at \r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/Soma_osf.m\r\n% https:\/\/blogs.mathworks.com\/cleve\/files\/Soma_osf.m>\r\n\r\n##### SOURCE END ##### ba03413b3d6846149e5b9f9e92eb3300\r\n-->","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/Soma.gif\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction--><p>The Soma Cube brings back memories.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2022\/06\/10\/the-soma-cube-again\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":8765,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[32,5,23,8,47],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/8768"}],"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=8768"}],"version-history":[{"count":6,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/8768\/revisions"}],"predecessor-version":[{"id":8789,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/8768\/revisions\/8789"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/8765"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=8768"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=8768"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=8768"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}