Montag Minigolf: Eine Reihe von kurzen Code-Golf- Fragen, die (hoffentlich!) Jeden Montag gestellt werden.
Manchmal haben die Leute die Lebensregeln satt: "Tu das nicht", "Das kannst du nicht", "Wir lassen dich das nicht machen". Es kann manchmal wirklich einschränkend wirken! Aber hin und wieder ist es gut, ein bisschen Spaß zu haben. Schreiben wir also Code, um diese Regeln zu ändern. Und wenn wir schon dabei sind, könnten auch andere Negativität ändern auch. (Natürlich werden diese Änderungen nicht nur vorübergehend sein, daher behalten wir auch den ursprünglichen Wortlaut bei.)
Herausforderung
Ihre Herausforderung besteht darin, ein Programm oder eine Funktion zu schreiben, mit der restriktive Wörter, <s>dh</s> Wörter, die auf ALL CAPS enden n'toder notvon diesen gefolgt werden , durchgestrichen werden. Am Ende, nach einem Raum, machte die Anzahl des Ersatzes sollte einbezogen werden. Beispielsweise:
Please don't jump into the pool.
wird
Please <s>don't</s> DO jump into the pool. 1
Bei Wörtern, die auf (sowie ) enden n'toder von not(sowie cannot) gefolgt werden , ist das positive Äquivalent alles bis zu den oben genannten not(ohne Leerzeichen). Folgendes meine ich:
do not speakwird<s>do not</s> DO speakit doesn't workwirdit <s>doesn't</s> DOES workwe cannotwirdwe <s>cannot</s> CAN
Es gibt jedoch einige Ausnahmen. Stellen Sie sicher, dass diese richtig behandelt werden.
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
Einzelheiten
- Die Eingabe enthält nie Leerzeichen außer normalen Räumen (ohne Tabs, Zeilenumbrüche, etc.).
- Die Eingabe enthält niemals doppelte Negative (zB
we can't not do this). - Wenn eine
notunmittelbar nach einem Satzzeichen angezeigt wird , oder als Teil eines anderen Wortes, lassen Sie es sein. - Achten Sie darauf, den Originaltext, einschließlich Groß- / Kleinschreibung, zwischen den
<s></s>Tags beizubehalten. - Wenn Sie möchten, können Sie
<strike></strike>anstelle von verwenden<s></s>.
Testfälle
Eingänge:
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.
Ausgänge:
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
Wertung
Das ist Code-Golf , also gewinnt der kürzeste gültige Code in Bytes. Tiebreaker geht zu einer Übermittlung über, die als erste ihre letzte Byteanzahl erreicht hat. Der Gewinner wird am kommenden Montag, den 26. Oktober, nicht ermittelt. Viel Glück!
Can't we capitalize special cases?
Oh this? It's nothing...oder I wonder if we'll notice any words like this??