{"id":12851,"date":"2025-05-11T10:53:11","date_gmt":"2025-05-11T14:53:11","guid":{"rendered":"https:\/\/blogs.mathworks.com\/cleve\/?p=12851"},"modified":"2025-05-14T21:21:54","modified_gmt":"2025-05-15T01:21:54","slug":"revolving-century-puzzle-and-magic-squares","status":"publish","type":"post","link":"https:\/\/blogs.mathworks.com\/cleve\/2025\/05\/11\/revolving-century-puzzle-and-magic-squares\/","title":{"rendered":"Revolving Century Puzzle and Magic Squares"},"content":{"rendered":"\r\n<div class=\"content\"><!--introduction-->\r\n<p>The Revolving Century puzzle is a beautifully made wooden puzzle from <a href=\"https:\/\/www.creativecrafthouse.com\/\">Creative Crafthouse<\/a> in Hudson, Florida.<\/p>\r\n<p>The sum of the numbers on each of the six rotating puzzle pieces is 100. The goal is to rotate the pieces so that the sum for each of the six columns is also 100. It is like a circular 6-by-6 magic square.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/original_v4.png\" alt=\"\"> <\/p>\r\n<!--\/introduction-->\r\n<h3>Contents<\/h3>\r\n<div>\r\n<ul>\r\n<li>\r\n<a href=\"#f1d494ba-8ead-4325-9dd4-1e6ce38b7bd5\">Digital Version<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#1eac3171-a453-40d7-968f-43be9489c5da\">State<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#7c252be7-55a2-44dd-865c-104aaae787d9\">Move<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#02f0d871-8092-4eec-9712-6115d1e65357\">Search<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#0e7cae01-0228-4b86-8523-1fea6d553e1b\">Magic<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#e4bb3725-c47e-48df-b0e3-20e52d06f99e\">Solution<\/a>\r\n<\/li>\r\n<li>\r\n<a href=\"#74910e47-b1f7-4bc8-b968-02edbe2453bf\">Software<\/a>\r\n<\/li>\r\n<\/ul>\r\n<\/div>\r\n<h4>Digital Version<a name=\"f1d494ba-8ead-4325-9dd4-1e6ce38b7bd5\"><\/a>\r\n<\/h4>\r\n<p>Our digital version of the Revolving Century puzzle uses 36 <a href=\"https:\/\/blogs.mathworks.com\/cleve\/2022\/08\/21\/polygons-polyshapes-and-puzzles\/\">polyshapes<\/a> like this one.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/piece19_v4.png\" alt=\"\"> <\/p>\r\n<p>The pieces are numbered with the integers from zero to 35, except the piece numbered 30 has been replaced by a second zero. This gives the desired \"century\" sum.<\/p>\r\n<pre class=\"codeinput\">\r\n   v = 0:35;\r\n   v(v==30) = 0;\r\n   c = sum(v)\/6\r\n<\/pre>\r\n<pre class=\"codeoutput\">\r\n   c =\r\n      100\r\n<\/pre>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/m_original_v4.png\" alt=\"\"> <\/p>\r\n<h4>State<a name=\"1eac3171-a453-40d7-968f-43be9489c5da\"><\/a>\r\n<\/h4>\r\n<p>The state of the puzzle is described by a 6-by-6 matrix.<\/p>\r\n<pre class=\"codeinput\">\r\n    A = original\r\n<\/pre>\r\n<pre class=\"codeoutput\">\r\n   A =\r\n        1     4    25    29     6    35\r\n       18     5    34    33     0    10\r\n       19    24     2    26     8    21\r\n       28    13    32     0    11    16\r\n       12    14    23     7    27    17\r\n       15    20    22    31     3     9\r\n<\/pre>\r\n<p>The row sums are all equal, but the column sums are not.<\/p>\r\n<pre class=\"codeinput\">\r\n   rows = sum(A')\r\n   cols = sum(A)\r\n<\/pre>\r\n<pre class=\"codeoutput\">\r\n   rows =\r\n      100   100   100   100   100   100\r\n   cols =\r\n       93    80   138   126    55   108\r\n<\/pre>\r\n<h4>Move<a name=\"7c252be7-55a2-44dd-865c-104aaae787d9\"><\/a>\r\n<\/h4>\r\n<p>A puzzle move rotates one row of the state matrix, for example, the third row.<\/p>\r\n<pre class=\"codeinput\">\r\n   shift = [2:61];\r\n   r = 3;\r\n   A(r,:) = A(r,shift)\r\n<\/pre>\r\n<pre class=\"codeoutput\">\r\n   A =\r\n        1     4    25    29     6    35\r\n       18     5    34    33     0    10\r\n       19    24     2    26     8    21\r\n       28    13    32     0    11    16\r\n       12    14    23     7    27    17\r\n       15    20    22    31     3     9\r\n   A =\r\n        1     4    25    29     6    35\r\n       18     5    34    33     0    10\r\n       24     2    26     8    21    19\r\n       28    13    32     0    11    16\r\n       12    14    23     7    27    17\r\n       15    20    22    31     3     9\r\n<\/pre>\r\n<p>Since we have a computer handy, we can also track the column sums.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/piece19_v4.gif\" alt=\"\"> <\/p>\r\n<h4>Search<a name=\"02f0d871-8092-4eec-9712-6115d1e65357\"><\/a>\r\n<\/h4>\r\n<p>The only way to find a solution that I know of is an exhaustive search. There are only <tt>6^5 = 7776<\/tt> possible states. It takes 4787 steps and less than a tenth of a second on my laptop to find the solution.<\/p>\r\n<p>Here are the last few steps of the exhaustive search for a solution.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/polypuzzle_v4.gif\" alt=\"\"> <\/p>\r\n<h4>Magic<a name=\"0e7cae01-0228-4b86-8523-1fea6d553e1b\"><\/a>\r\n<\/h4>\r\n<p>I could have used an actual magic square.<\/p>\r\n<pre class=\"codeinput\">\r\n   A = magic(6)\r\n<\/pre>\r\n<pre class=\"codeoutput\">\r\n   A =\r\n       35     1     6    26    19    24\r\n        3    32     7    21    23    25\r\n       31     9     2    22    27    20\r\n        8    28    33    17    10    15\r\n       30     5    34    12    14    16\r\n        4    36    29    13    18    11\r\n<\/pre>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/magic6_v4.png\" alt=\"\"> <\/p>\r\n<p>I would need to change the name of the puzzle to \"Revolution 111\".<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/magic6_v4.gif\" alt=\"\"> <\/p>\r\n<h4>Solution<a name=\"e4bb3725-c47e-48df-b0e3-20e52d06f99e\"><\/a>\r\n<\/h4>\r\n<p>Here is the solution of the original Revolution Century puzzle.<\/p>\r\n<pre class=\"codeinput\">\r\n   A = solution\r\n<\/pre>\r\n<pre class=\"codeoutput\">\r\n   A =\r\n        6    35     1     4    25    29\r\n       10    18     5    34    33     0\r\n       24     2    26     8    21    19\r\n       28    13    32     0    11    16\r\n       17    12    14    23     7    27\r\n       15    20    22    31     3     9\r\n<\/pre>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/m_solution_v4.png\" alt=\"\"> <\/p>\r\n<p>I can transfer that to the analog puzzle.<\/p>\r\n<p>\r\n<img decoding=\"async\" vspace=\"5\" hspace=\"5\" src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/solution_v4.png\" alt=\"\"> <\/p>\r\n<h4>Software<a name=\"74910e47-b1f7-4bc8-b968-02edbe2453bf\"><\/a>\r\n<\/h4>\r\n<p>A self-extracting archive for <tt>polypuzzle<\/tt> is available <a href=\"https:\/\/blogs.mathworks.com\/cleve\/files\/Puzzle_v4_mzip.m\">here<\/a>.<\/p>\r\n<script language=\"JavaScript\"> <!-- \r\n    function grabCode_1ad7b6da73dc48c08f5e9b13d1cb38fa() {\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='1ad7b6da73dc48c08f5e9b13d1cb38fa ' + '##### ' + 'SOURCE BEGIN' + ' #####';\r\n        t2='##### ' + 'SOURCE END' + ' #####' + ' 1ad7b6da73dc48c08f5e9b13d1cb38fa';\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 2025 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>\r\n<p style=\"text-align: right; font-size: xx-small; font-weight:lighter;   font-style: italic; color: gray\">\r\n<br>\r\n<a href=\"javascript:grabCode_1ad7b6da73dc48c08f5e9b13d1cb38fa()\"><span style=\"font-size: x-small;        font-style: italic;\">Get \r\n      the MATLAB code <noscript>(requires JavaScript)<\/noscript>\r\n<\/span><\/a>\r\n<br>\r\n<br>\r\n      Published with MATLAB&reg; R2024b<br>\r\n<\/p>\r\n<\/div>\r\n<!--\r\n1ad7b6da73dc48c08f5e9b13d1cb38fa ##### SOURCE BEGIN #####\r\n%% Revolving Century Puzzle and Magic Squares\r\n% The Revolving Century puzzle is a beautifully made wooden puzzle\r\n% from <https:\/\/www.creativecrafthouse.com\/ Creative Crafthouse>\r\n% in Hudson, Florida.\r\n%\r\n% The sum of the numbers on each of the six rotating puzzle\r\n% pieces is 100.  The goal is to rotate the pieces so that\r\n% the sum for each of the six columns is also 100.  It is like \r\n% a circular 6-by-6 magic square.\r\n%\r\n% <<original_v4.png>>\r\n%\r\n\r\n%% Digital Version\r\n% Our digital version of the Revolving Century puzzle uses 36  \r\n% <https:\/\/blogs.mathworks.com\/cleve\/2022\/08\/21\/polygons-polyshapes-and-puzzles\/\r\n% polyshapes> like this one.\r\n%\r\n% <<piece19_v4.png>>\r\n%\r\n\r\n%%\r\n% The pieces are numbered with the integers from zero to 35, except\r\n% the piece numbered 30 has been replaced by a second zero. \r\n% This gives the desired \"century\" sum. \r\n \r\n    v = 0:35;\r\n    v(v==30) = 0; \r\n    c = sum(v)\/6\r\n\r\n%%\r\n%\r\n% <<m_original_v4.png>>\r\n%\r\n\r\n%% State\r\n% The state of the puzzle is described by a 6-by-6 matrix.\r\n\r\n    A = original\r\n\r\n%%\r\n% The row sums are all equal, but the column sums are not.\r\n\r\n    rows = sum(A')\r\n    cols = sum(A)\r\n\r\n%% Move\r\n% A puzzle move rotates one row of the state matrix,\r\n% for example, the third row.\r\n\r\n    shift = [2:6 1];\r\n    r = 3;\r\n    A\r\n    A(r,:) = A(r,shift)\r\n\r\n%%\r\n% Since we have a computer handy, we can also track the column sums.\r\n%\r\n% <<piece19_v4.gif>>\r\n%\r\n\r\n%% Search\r\n% The only way to find a solution that I know of is\r\n% an exhaustive search.  There are only |6^5 = 7776|\r\n% possible states.  \r\n% It takes 4787 steps and less than a tenth of a second\r\n% on my laptop to find the solution.\r\n%\r\n% Here are the last few steps of the exhaustive search\r\n% for a solution.\r\n% \r\n% <<polypuzzle_v4.gif>>\r\n%\r\n\r\n%% Magic\r\n% I could have used an actual magic square.\r\n\r\n    A = magic(6)\r\n  \r\n%%\r\n%\r\n% <<magic6_v4.png>>\r\n%\r\n\r\n%%\r\n% I would need to change the name of the puzzle to \"Revolution 111\".\r\n%\r\n% <<magic6_v4.gif>>\r\n%\r\n\r\n%% Solution\r\n% Here is the solution of the original Revolution Century puzzle.\r\n\r\n    A = solution\r\n\r\n%%\r\n% <<m_solution_v4.png>>\r\n%\r\n% I can transfer that to the analog puzzle.\r\n%\r\n% <<solution_v4.png>>\r\n%\r\n\r\n%% Software\r\n% A self-extracting archive for |polypuzzle| is available\r\n% <https:\/\/blogs.mathworks.com\/cleve\/files\/Puzzle_v4_mzip.m here>.\r\n##### SOURCE END ##### 1ad7b6da73dc48c08f5e9b13d1cb38fa\r\n-->\r\n","protected":false},"excerpt":{"rendered":"<div class=\"overview-image\"><img src=\"https:\/\/blogs.mathworks.com\/cleve\/files\/snapshot_v4.png\" class=\"img-responsive attachment-post-thumbnail size-post-thumbnail wp-post-image\" alt=\"\" decoding=\"async\" loading=\"lazy\" \/><\/div><!--introduction-->\r\n<p>The Revolving Century puzzle is a beautifully made wooden puzzle from <a href=\"https:\/\/www.creativecrafthouse.com\/\">Creative Crafthouse<\/a> in Hudson, Florida.... <a class=\"read-more\" href=\"https:\/\/blogs.mathworks.com\/cleve\/2025\/05\/11\/revolving-century-puzzle-and-magic-squares\/\">read more >><\/a><\/p>","protected":false},"author":78,"featured_media":12914,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[5,23,9,37,47],"tags":[],"_links":{"self":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/12851"}],"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=12851"}],"version-history":[{"count":10,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/12851\/revisions"}],"predecessor-version":[{"id":12887,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/posts\/12851\/revisions\/12887"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media\/12914"}],"wp:attachment":[{"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/media?parent=12851"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/categories?post=12851"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blogs.mathworks.com\/cleve\/wp-json\/wp\/v2\/tags?post=12851"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}