星期一迷你高尔夫:每周一发布(希望!)一系列简短的代码高尔夫问题。
有时人们会厌倦生活规则:“不要这样做”,“你不能那样做”,“我们不会让你那样做”。有时似乎确实有限制!但是,时不时地获得一些乐趣是一件好事,所以让我们编写一些代码来修改这些规则。而在我们讨论的同时,也可能会修改其他负面因素。(当然,这些修改将不会只是暂时的,因此我们也将保留原始措辞。)
挑战
您面临的挑战是编写一个程序或函数,以将HTML <s>
删除线置于</s>
限制性词(即n't
以not
该词结尾或之后的词)周围,并在每一个词之后将其正当数插入所有大写字母中。最后,在空格后,应包括更换的数量。例如:
Please don't jump into the pool.
变成
Please <s>don't</s> DO jump into the pool. 1
对于以n't
或结尾not
(以及cannot
)结尾的单词,正等价词是指上述所有字符not
(不包括空格)。这就是我的意思:
do not speak
变成<s>do not</s> DO speak
it doesn't work
变成it <s>doesn't</s> DOES work
we cannot
变成we <s>cannot</s> CAN
但是,也有一些例外。确保正确处理这些内容。
can't -> <s>can't</s> CAN
won't -> <s>won't</s> WILL
ain't -> <s>ain't</s> AM
shan't -> <s>shan't</s> SHALL
I'm not -> <s>I'm not</s> I AM
you're not -> <s>you're not</s> YOU ARE
细节
- 输入将不包含任何空格,除了普通空格(没有制表符,换行符等)。
- 输入将永远不会包含任何双负数(例如
we can't not do this
)。 - 如果a
not
在标点符号后立即出现,或者作为另一个词的一部分出现,则保留它。 - 确保在
<s></s>
标签之间保留原始文本,包括大写/小写。 - 如果愿意,可以使用
<strike></strike>
代替<s></s>
。
测试用例
输入:
I'm sorry, but you can't do that.
Driving on the beach isn't allowed.
Driving on the beach is not allowed.
Please don't jump in; I cannot imagine what might come of that.
Don't worry; we won't get into trouble.
I'm not perfect, but you're not either.
You shan't do it 'cause I ain't doin' it!
Can't we capitalize special cases?
I don't like the words can't, shan't, won't, don't, ain't, or ppcgn't.
Oh, this? It's nothing.
Tie a slipknot in the rope.
Would you like Pinot Noir?
This sentence contains none of the replacement words. Not even knot or ca't.
This sentence doesn't contain one of the replacement words.
输出:
I'm sorry, but you <s>can't</s> CAN do that. 1
Driving on the beach <s>isn't</s> IS allowed. 1
Driving on the beach <s>is not</s> IS allowed. 1
Please <s>don't</s> DO jump in; I <s>cannot</s> CAN imagine what might come of that. 2
<s>Don't</s> DO worry; we <s>won't</s> WILL get into trouble. 2
<s>I'm not</s> I AM perfect, but <s>you're not</s> YOU ARE either. 2
You <s>shan't</s> SHALL do it 'cause I <s>ain't</s> AM doin' it! 2
<s>Can't</s> CAN we capitalize special cases? 1
I <s>don't</s> DO like the words <s>can't</s> CAN, <s>shan't</s> SHALL, <s>won't</s> WILL, <s>don't</s> DO, <s>ain't</s> AM, or <s>ppcgn't</s> PPCG. 7
Oh, this? It's nothing. 0
Tie a slipknot in the rope. 0
Would you like Pinot Noir? 0
This sentence contains none of the replacement words. Not even knot or ca't. 0
This sentence <s>doesn't</s> DOES contain one of the replacement words. 1
计分
这是代码高尔夫球,因此以字节为单位的最短有效代码获胜。Tiebreaker提交的提交首先达到其最终字节数。10月26日下星期一将不会选择获胜者。祝您好运!
@FryAmTheEggman是的,除非还有其他值得添加到列表中的东西。我宁愿简短,但是您有什么建议吗?
—
ETHproductions
不,只是不想让它遭受“您现在改变了规格,现在很烂”的挑战综合征:P
—
FryAmTheEggman 2015年
建议的测试用例:
—
DLosc
Can't we capitalize special cases?
我们是否需要小心字符串:
—
唐·黑斯廷斯
Oh this? It's nothing...
或I wonder if we'll notice any words like this?
?
一个<strike> not </ strike>只是将模因转换为比赛!
—
1