目标
在本次比赛中,您将获得一个随机的房间,里面放着一支蜡烛。目的是编写最短的程序(这是高尔夫球),通过用代替暗点来确定房间的哪些部分被蜡烛照亮@
。该程序应占用STDIN的空间,并将输出打印到STDOUT。
输入/房间示例
+------+
| C |
| +--+
| \ |
+---------+
蜡烛被表示用C
,墙壁/反射镜被用来表示|
,-
,/
,或\
。墙壁本身就是镜子。房间的角落用表示+
。
房间永远不会有对角墙,光线也永远不会逸出房间。
同样,一行上的第一个字符将始终是房间墙壁的一部分。每行上的绝对最后一个字符将是房间的另一面墙。这两个之间的任何字符都不会在房间外面。
光线与反射
蜡烛在八个基本方向上分别发出八束(类似激光的)光束:N,S,E,W,NE,SE,SW和NW。这些光线从镜子反射出来,如下所述:
Old Direction of Travel | Mirror | New Direction
N S E W NE SE SW NW / E W N S -- -- -- --
N S E W NE SE SW NW \ W E S N -- -- -- --
N S E W NE SE SW NW | - - - - NW SW NE SW
N S E W NE SE SW NW - - - - - SE NE SW NE
A -
代表被吸收的光。光总是被C或+吸收。重要的是要注意,只有当镜子占用与镜子相同的空间时,光线才会从镜子反射回来。当您在纸上绘制反射时,这些规则更容易理解。
示例输出
作为输出,程序应打印照明房间的图像,暗点写为@
,亮点留为空白,镜面不受影响。对于上面的示例,输出为:
+------+
| C |
|@ @ +--+
| @\ |
+---------+
这意味着,如果您抽出光束,它们将永远不会到达标记为的空间@
。
更多例子
Input:
+-----+
| |
| |
| C |
| |
| |
+-----+
Output:
+-----+
| @ @ |
|@ @|
| C |
|@ @|
| @ @ |
+-----+
Input:
+-----+
| \ |
|/ C \+-+
| |
| \ - ++
+------+
Output:
+-----+
| \ @|
|/ C \+-+
| @|
| @\ -@++
+------+
@Peter Taylor:SW光束击中了那个位置。
—
Briguy37,2011年
可以使用更多的验证案例。
—
dmckee ---前主持人小猫,
@dmckee我又添加了两个示例。
—
PhiNotPi 2011年
@
也不应该吗?