Labfans是一个针对大学生、工程师和科研工作者的技术社区。 论坛首页 | 联系我们(Contact Us)
MATLAB爱好者论坛-LabFans.com
返回   MATLAB爱好者论坛-LabFans.com > 其它 > 资料存档 > MATLAB技术文章
MATLAB技术文章 MATLAB Technical Articles From Mathworks
回复
 
主题工具 显示模式
旧 2025-05-12, 08:02   #1
poster
高级会员
 
注册日期: 2019-11-21
帖子: 3,008
声望力: 66
poster 正向着好的方向发展
默认 Revolving Century Puzzle and Magic Squares - Cleve Moler on Mathematics and Computing

The Revolving Century puzzle is a beautifully made wooden puzzle from Creative Crafthouse in Hudson, Florida.

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.



Contents
Digital Version

Our digital version of the Revolving Century puzzle uses 36 polyshapes like this one.





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.

v = 0:35; v(v==30) = 0; c = sum(v)/6 c = 100State

The state of the puzzle is described by a 6-by-6 matrix.

A = start A = 1 4 25 29 6 35 18 5 34 33 0 10 19 24 2 26 8 21 28 13 32 0 11 16 12 14 23 7 27 17 15 20 22 31 3 9The row sums are all equal, but the column sums are not.

rows = sum(A') cols = sum(A) rows = 100 100 100 100 100 100 cols = 93 80 138 126 55 108Move

A puzzle move rotates one row of the state matrix, for example, the third row.

shift = [2:6 1]; r = 3; A A(r,:) = A(r,shift) A = 1 4 25 29 6 35 18 5 34 33 0 10 19 24 2 26 8 21 28 13 32 0 11 16 12 14 23 7 27 17 15 20 22 31 3 9 A = 1 4 25 29 6 35 18 5 34 33 0 10 24 2 26 8 21 19 28 13 32 0 11 16 12 14 23 7 27 17 15 20 22 31 3 9Since we have a computer handy, we can also track the column sums.



Search

The only way to find a solution that I know of is an exhaustive search. There are only 6^5 = 7776 possible states. It takes 4787 steps and less than a tenth of a second on my laptop to find the solution.

Here are the last few steps of the exhaustive search for a solution.



Magic

I could have used an actual magic square.

A = magic(6) A = 35 1 6 26 19 24 3 32 7 21 23 25 31 9 2 22 27 20 8 28 33 17 10 15 30 5 34 12 14 16 4 36 29 13 18 11I would need to change the name of the puzzle to "Revolution 111".



Solution

Here is the solution of the original Revolution Century puzzle.

A = solution A = 25 29 6 35 1 4 33 0 10 18 5 34 21 19 24 2 26 8 11 16 28 13 32 0 7 27 17 12 14 23 3 9 15 20 22 31

I can transfer that to the analog puzzle.



Software

A self-extracting archive for polypuzzle is available here.


Get the MATLAB code (requires JavaScript)

Published with MATLAB® R2024b
poster 当前离线   回复时引用此帖
回复


发帖规则
不可以发表新主题
不可以发表回复
不可以上传附件
不可以编辑自己的帖子

启用 BB 代码
论坛启用 表情符号
论坛启用 [IMG] 代码
论坛启用 HTML 代码



所有时间均为北京时间。现在的时间是 09:07


Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.