熄灯问题 Lights Out Puzzle

From : http://mathworld.wolfram.com/LightsOutPuzzle.html

 

转化为高斯消元法,POJ 1222

 

---

 

 

Lights Out Puzzle

DOWNLOAD Mathematica Notebook

LightsOutSwitch

A one-person game played on a rectangular lattice of lamps which can be turned on and off. A move consists of flipping a "switch" inside one of the squares, thereby toggling the on/off state of this and all four vertically and horizontally adjacent squares. Starting from a randomly chosen light pattern, the aim is to turn all the lamps off. The problem of determining if it is possible to start from set of all lights being on to all lights being off is known as the "all-ones problem." As shown by Sutner (1989), this is always possible for a square lattice (Rangel-Mondragon).

This can be translated into the following algebraic problem.

1. Each lamp configuration can be viewed as a matrix L with entries in Z_2 (i.e., a binary matrix ), where each 1 represents a burning light and 0 represents a light turned off. For example, for the 3×3 case,

 L=[0 1 0; 1 1 0; 0 1 1]
(1)

2. The action of the switch placed at (i,j) can be interpreted as the matrix addition L+A_(ij) , where A_(ij) is the matrix in which the only entries equal to 1 are those placed at (i,j) and in the adjacent positions; there are essentially three different types of matrices A_(ij) , depending on whether (i,j) is a corner entry,

 A_(11)=[1 1 0; 1 0 0; 0 0 0]
(2)

a side entry,

 A_(12)=[1 1 1; 0 1 0; 0 0 0]
(3)

or a middle entry,

 A_(22)=[0 1 0; 1 1 1; 0 1 0]
(4)

3. Since matrix addition is commutative, it follows that the order in which the moves are performed is irrelevant.

4. Every winning combination of moves can be expressed mathematically in the form:

 L+sum_(i,j)x_(ij)A_(ij)=0.
(5)

Here, 0 denotes the zero matrix , which corresponds to the situation where all lights are turned off, and each coefficient x_(ij) represents the number of times that switch (i,j) has to be pressed. Because we are solving the equations (mod 2), they can therefore be written in the equivalent form

 sum_(i,j)x_(ij)A_(ij)=L.
(6)

Furthermore, it suffices to consider 0 and 1 as the only possible values for x_(ij) . Hence, the above equality is in fact a system of linear equations in the indeterminates x_(ij) over the field Z_2 .

LightsOut3By3

For example, the system corresponding to the initial (left) light pattern above can be written as

 [1 1 0 1 0 0 0 0 0; 1 1 1 0 1 0 0 0 0; 0 1 1 0 0 1 0 0 0; 1 0 0 1 1 0 1 0 0; 0 1 0 1 1 1 0 1 0; 0 0 1 0 1 1 0 0 1; 0 0 0 1 0 0 1 1 0; 0 0 0 0 1 0 1 1 1; 0 0 0 0 0 1 0 1 1][x_(11); x_(12); x_(13); x_(21); x_(22); x_(23); x_(31); x_(32); x_(33)]=[0; 1; 0; 1; 1; 0; 0; 1; 1].
(7)

It has exactly one solution: ((1,1,1) , (0,0,0) , (0,0,1) ), which means that the game is solved by pressing the switches (1,1) , (1,2) , (1,3) , and (3,3) (corresponding to the red dots in the figure above). Since the matrix of the above system of equations has maximal rank (it is a 9×9 matrix with nonzero determinant), the game on a 3×3 -lattice is always solvable.

LightsOut3By2Solvable

In general, the solvable patterns of the m×n lattice are those which are obtained from the no-light pattern by pushing some switches. In the language of linear algebra, they are the m×n -matrices which are sums of some matrices A_(ij) . For instance, the solvable patterns of the 3×2 -lattice are illustrated above. All other rectangles of size 4×3 or less are solvable for every possible starting pattern.

LightsOut3By2Solutions

Multiple solutions are sometimes possible. For example, going from lights all on to all off in the 3×2 case, there are four possible solutions to the all-lights pattern, illustrated above.

LightsOut3By2

Some patterns have no solutions. For example, in the 3×2 pattern shown above, it is impossible to turn off all the lights.

LightsOutSquareSolutions

As shown by Sutner (1989), going from all lights on to all lights off is always possible for any size square lattice. The above illustration shows all possible solutions for n=2 to 7. The numbers of solutions (ignoring rotation and reflection) for n=1 , 2, ... are 1, 1, 1, 16, 4, 1, 1, 1, 256, 1, 64, 1, 1, 16, 1, ... (Sloane's A075462 ), and the corresponding minimal numbers of buttons to be pressed are 1, 4, 5, 4, 15, 28, 33, 40, 25, 44, 55, 72, 105, 56, 117, ... (Sloane's A075464 ). The board sizes with unique solutions (counting boards having equivalent solutions by rotation or reflections as distinct) are therefore 1, 2, 3, 6, 7, 8, 10, 12, 13, 15, 18, 20, ... (Sloane's A076436 ; Cowen and Kennedy 2000).

LightsOutUniqueSquareSolutions

Removing solutions that are equivalent by rotation or reflection gives the distinct solutions illustrated above, of which there are 1, 1, 1, 5, 1, 1, 1, 1, 43, 1, 10, 1, 1, 5, 1, ... (Sloane's A075463 ). The board sizes with unique solutions (counting boards having equivalent solutions by rotation or reflections as equivalent) are therefore 1, 2, 3, 5, 6, 7, 8, 10, 12, 13, 15, 17, 18, ... (Sloane's A076437 ).

This entry contributed by Margherita Barile

REFERENCES:

Caro, Y. "Simple Proofs to Three Parity Theorems." Ars Combin. 42 , 175-180, 1996.

Conlon, M. M.; Falidas, M.; Forde, M. J.; Kennedy, J. W.; McIlwaine, S.; and Stern, J. "Inversion Numbers of Graphs." Graph Th. Notes New York 37 , 42-48, 1999.

Cowen, R. and Kennedy, J. "The Lights Out Puzzle." Math. Educ. Res. 9 , 28-32, 2000. http://library.wolfram.com/infocenter/Articles/1231/ .

Cowen, R.; Hechler, S. H.; Kennedy, J. W.; and Ryba, A. "Inversion and Neighborhood Inversion in Graphs." Graph Th. Notes New York 37 , 37-41, 1999.

Goldwasser, J. and Klostermeyer, W. "Maximization Versions of 'Lights Out' Games in Grids and Graphs." Congr. Numer. 126 , 99-111, 1997.

JavaScript Source. "Lights Out." http://javascript.internet.com/games/lights-out.html .

Millstone Website. "Lights Out." http://www.millstone.demon.co.uk/games/lightsout/start.htm .

Rangel-Mondragon, J. "A Catalog of Cellular Automata." http://library.wolfram.com/infocenter/MathSource/505/ .

Raguet-Schofield, R. "Lights Out Palette Demonstration." http://library.wolfram.com/infocenter/Demos/4817/ .

Sloane, N. J. A. Sequences A075462 , A075463 , A075464 , A076436 , and A076437 in "The On-Line Encyclopedia of Integer Sequences."

Sutner, K. "Linear Cellular Automata and the Garden-of-Eden." Math. Intelligencer 11 , 49-53, 1989.

Whitman College Department of Mathematics. "Lights Out." http://www.whitman.edu/offices_departments/mathematics/lights_out/ .




CITE THIS AS:

Barile, Margherita . "Lights Out Puzzle." From MathWorld --A Wolfram Web Resource, created by Eric W. Weisstein . http://mathworld.wolfram.com/LightsOutPuzzle.html

利用 TensorFlow 训练自己的目标识别器。本文内容来自于我的毕业设计,基于 TensorFlow 1.15.0,其他 TensorFlow 版本运行可能存在问题。.zip项目工程资源经过严格测试可直接运行成功且功能正常的情况才上传,可轻松复刻,拿到资料包后可轻松复现出一样的项目,本人系统开发经验充足(全领域),有任何使用问题欢迎随时与我联系,我会及时为您解惑,提供帮助。 【资源内容】:包含完整源码+工程文件+说明(如有)等。答辩评审平均分达到96分,放心下载使用!可轻松复现,设计报告也可借鉴此项目,该资源内项目代码都经过测试运行成功,功能ok的情况下才上传的。 【提供帮助】:有任何使用问题欢迎随时与我联系,我会及时解答解惑,提供帮助 【附带帮助】:若还需要相关开发工具、学习资料等,我会提供帮助,提供资料,鼓励学习进步 【项目价值】:可用在相关项目设计中,皆可应用在项目、毕业设计、课程设计、期末/期中/大作业、工程实训、大创等学科竞赛比赛、初期项目立项、学习/练手等方面,可借鉴此优质项目实现复刻,设计报告也可借鉴此项目,也可基于此项目来扩展开发出更多功能 下载后请首先打开README文件(如有),项目工程可直接复现复刻,如果基础还行,也可在此程序基础上进行修改,以实现其它功能。供开源学习/技术交流/学习参考,勿用于商业用途。质量优质,放心下载使用。
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值