在写这个谜题的时候,很快就会出现269个与素数有关的谜题。为了庆祝/哀悼这一事件(269是黄金),这个挑战将是关于爆炸的质数。为了准备这项任务,我获得了军事级炸药的许可证(我向你保证,这是合法的),以及巨大的炸药本身。不幸的是,我的仓库里也有很多垃圾,我把所有东西(我指的是所有东西)打包成ASCII文本。
从1到6(实际输入大小可以任意大),下面是我的巨大炸药的例子:
+
___L__
+ | |
__L__ | |
+ | || |
__L_ | || |
+ | || || |
_L_ | || || |
+ | || || || |
_L | || || || |
+ | || || || || |
L | || || || || |
| || || || || || |
|_||__||___||____||_____||______|
__________________
_______________ | |
____________ | | | |
_________ | | | | | L-*
______ | | | L-*| L-*| |
___ | L-*| L-*| | | | | |
|___L-*|______| |_________| |____________| |_______________| |__________________|大小n垂直炸药的模式是两根2n-high柱的|,中间的n空间分隔在底部和顶部的_S。下面的_s将被|s包围,而顶部的_D9将被空间所包围。将有一个L在+下面,取代顶部_s的中点(偏右)。尺寸n水平炸药的图案是两行n-wide的_,中间用n-1空间填充的行隔开。左边和右边将有n+1-high列,其中最上面的字符将是一个空格,其他列将是|。将有一个L,右边有一个*,代替右|s的中点(偏上)。
作为我最好和最聪明的助手,你需要帮助我确定每个ASCII包(输入网格)可以摧毁多少素数。您的任务是计算包中的所有有效炸药,同时考虑到大小。您将输出一个类似于:BOOM! # prime(s) primed for destruction的字符串,其中#是包中计算出的炸药大小的总和。
Input:
______
| L-*
|______|
Output:
BOOM! 2 prime(s) primed for destruction
Reasoning:
Single piece of dynamite of size 2
Input:
Output:
BOOM! 0 prime(s) primed for destruction
Reasoning:
Empty string contains no dynamite
Input:
__+_
\_|_\
/_|_/
___L___
~~\_____/~~
Output:
BOOM! 0 prime(s) primed for destruction
Reasoning:
Despite being cute and non-empty, this ASCII ship from my warehouse has no dynamite in it
Input:
____________
| |
| ___ L-*
| |___L-* |
|____________|
Output:
BOOM! 1 prime(s) primed for destruction
Reasoning:
Dynamite is non-recursive - the outer dynamite doesn't count at all,
but the inner dynamite is valid and will blow up 1 prime.
Input:
+
L
| |
|_|
Output:
BOOM! 0 prime(s) primed for destruction
Reasoning:
A space character is missing to the right of the L - the box must be
fully complete, although the + for vertical and -* for horizontal dynamite
are not necessarily space-padded; all that is required for those elements
is that they be aligned with the L.
Input:
+
__L__
+ | |
__L_ | |
+ | || | _____________________
_L_ | || || |
+ | || || || |
_L | || || || |
+ | || || || || L-*
L | || || || || |
| || || || || || |
|_||__||___||____||_____||_____________________|
Output:
BOOM! 18 prime(s) primed for destruction
Reasoning:
The size-4 dynamite is malformed, but all the other pieces of dynamite
are valid. Summing the dynamite sizes within this package yields
1 + 2 + 3 + 5 + 7 = 18 units of dynamite.
Input:
A
C+C
M L M
E | | E
M|_|M
C C
A
Output:
BOOM! 1 prime(s) primed for destruction
Reasoning:
The dynamite's box is properly surrounded by spaces, and the tip is not
required to be surrounded by spaces. Therefore, this is a valid piece of
dynamite that can explode 1 prime.
Input:
+
L ______
| | L-*
|_|______|
Output:
BOOM! 3 prime(s) primed for destruction
Reasoning:
Although the 2 pieces of dynamite intersect, each on their own satisfies
the parameters for enormous dynamite. Therefore, the pieces can explode
1 + 2 = 3 primes together.输入将是任何合理格式的ASCII网格/字符串。输出必须是由BOOM! # prime(s) primed for destruction组成的计算正确的字符串,其中#是输入中计算出的炸药总大小。
您的回答可能是一个函数或完整的程序(两者都将按照相同的指标评分)。
严禁利用标准漏洞。
这是密码-高尔夫 -最短代码获胜。到外面去引爆一些质数:)
发布于 2019-11-14 20:39:45
-Minteger -00p),323字节为测试提供正确的输出,以便获得更多的金牌。
for$s(2..y/
//){$t=$s-1>>1;$u=$s/2-1;$v=2*$s-1;s/^ (___){$s} .*
(\|( ){$s}\|.*
){$t}\|(?3){$s}L-\*.*
(?2){$u}\|(?1){$s}\||^...{$u}\+.*
__{$u}L_{$t} .*
(\| {$s}\|.*
){$v}\|_{$s}\|/$\+=$s;A5/gme}s/^ ___ .*
\|___L-\*|^.\+.*
L .*
\| \|.*
\|_\|/$\++;A5/gme;s/^.//gm&&redo}{$\|=0;$\="BOOM! $\ prime(s) primed for destruction"https://codegolf.stackexchange.com/questions/195806
复制相似问题