画出兰顿蚂蚁的路。
描述
平面上的正方形被涂成黑色或白色。我们任意地将一个正方形标识为“蚂蚁”。蚂蚁在采取的每个步骤中都可以沿四个基本方向中的任何一个行进。蚂蚁按照以下规则移动:
- 在白色正方形处,向右旋转90°,翻转正方形的颜色,向前移动一个单位
- 在黑色正方形处,向左旋转90°,翻转正方形的颜色,向前移动一个单位
技术指标
- 输入:0到725(含)之间的整数N。
- 输出:一个17 x 17的网格,代表步骤N时蚂蚁的“路径”。
规则
- 蚂蚁开始朝右(3点钟)。
- 蚂蚁从网格的中心开始。
- 分别
_#@
用于白色方块,黑色方块和蚂蚁。 - 网格最初是完全白色的。
- 您可以使用解释语言制作完整的程序或函数。
- 通过标准输入或参数输入。
例子
更新:案例的N = 450输出错误。
N = 0
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
________@________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
N = 1
_________________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
________#________
________@________
_________________
_________________
_________________
_________________
_________________
_________________
_________________
N = 450
_________________
_________________
___________##____
____##______##___
___#__##___##_#__
__###_#@#__#__#__
__#_#_#_#__#_#___
_____###___#_____
_____#___________
_____#__###______
___#_#_#__#_#_#__
__#__#_#____###__
__#_##__##___#___
___##______##____
____##___________
_________________
_________________