挑战: 编写实现约翰 · H · 康威的 生命的游戏细胞自动机的最短程序
编辑: 经过大约一周的竞争,我选择了一个胜利者: Pdehaan,用 perl 设法用 一字符击败 Matlab 解决方案。
对于那些没有听说过游戏的生活,你采取一个网格(理想的无限)的方格。细胞可以是活的(填充的) ,也可以是死的(空的)。我们通过应用以下规则来确定下一步哪些细胞是活的:
您的程序将读入一个40x80字符的 ASCII 文本文件,该文件指定为命令行参数,以及要执行的迭代次数(N)。最后,它将在 N 次迭代后将系统的状态输出到一个 ASCII 文件 out.txt。
下面是一个运行相关文件的示例:
返回文章页面
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
..................................XX............................................
..................................X.............................................
.......................................X........................................
................................XXXXXX.X........................................
................................X...............................................
.................................XX.XX...XX.....................................
..................................X.X....X.X....................................
..................................X.X......X....................................
...................................X.......XX...................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
重复100次:
Q:\>life in.txt 100
结果输出(out.txt)
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
..................................XX............................................
..................................X.X...........................................
....................................X...........................................
................................XXXXX.XX........................................
................................X.....X.........................................
.................................XX.XX...XX.....................................
..................................X.X....X.X....................................
..................................X.X......X....................................
...................................X.......XX...................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
................................................................................
规则:
优胜者将由角色数量决定。
祝你好运!