因为rickrolling是地球上最大的模因,所以您[知道规则,我也是如此]是要编写最短的代码,从而可以在文本上对不知情的读者进行rickroll。让[you down]有一个包含字母,标点和空格的输入文本。每当前两个节中的[撒谎和伤害您]短语出现在文本中时...
We're no strangers to love
You know the rules and so do I
A full commitment's what I'm thinking of
You wouldn't get this from any other guy
I just wanna tell you how I'm feeling
Gotta make you understand
Never gonna give you up
Never gonna let you down
Never gonna run around and desert you
Never gonna make you cry
Never gonna say goodbye
Never gonna tell a lie and hurt you
...然后将其余行插入方括号中。
输入值
输入是仅包含可打印ASCII和可选尾随换行符的单行字符串。
输出量
输出是单行字符串。每当一组单词(定义为在空格中分隔的输入字符串)与上面的歌词行中的一组单词匹配时,请将行中的其余单词插入字符串中,并用方括号括起来。
附加说明:
这是代码高尔夫球,最少字节获胜。您可以编写程序或函数。
- 匹配应该不区分大小写:即使在歌词中大写,也要
we're
转换为。we're [no strangers to love]
We're
- 匹配应该是贪婪的。
Does he know the answer?
应该转换为Does he know the [rules and so do I] answer?
而不是Does he know [the rules and so do I] the [rules and so do I] answer?
- 如果单词在提供的歌词中不止一次出现,请选择任何出现的单词来完成该行。
- 如果单词是歌词行中的最后一个单词,请不要在其后插入任何内容。
- 标点符号是“单词”的一部分。
I'm
是一个单词,不能与匹配I
。同样,you.
由于句号的原因,它与任何歌词都不匹配。
有些词I
在整个歌词中以及在一行结尾处会多次出现。由于规则是可以使用上述歌词中的任何出现,并且这些出现之一在行的末尾,因此无需进行匹配I
。的另一个选项I
是[just wanna tell you how I'm feeling]
。
如果两个匹配项重叠,则可以选择其中一个。这意味着how I'm thinking
可能成为how I'm [feeling] thinking [of]
OR,how [I'm feeling] I'm thinking [of]
因为I'm
可能是how I'm
or的一部分I'm thinking
。但是,如果输入文本很简单I'm thinking
,则输出应为I'm thinking [of]
。
其他测试用例:
I don't know what I'm doing with my life.
is converted to
I [just wanna tell you how I'm feeling] don't know [the rules and so do I] what I'm [thinking of] doing with my life.
Many additional solutions are possible, since words like `I` appear multiple times.
Will someone please save me from these memes?
is converted to
Will someone please save me from [any other guy] these memes?
Two strangers walked into a bar. One said "hello." The other said "goodbye."
is converted to
Two strangers [to love] walked into a [lie and hurt you] bar. One said "hello." The [rules and so do I] other [guy] said "goodbye."
挑战受到了这个家伙的启发。
11
ಠ_ಠ
—
亚历A.
第二个测试用例似乎是错误的(
—
Doorknob
from
应该变为from [any other guy]
)。