Mini-golf del lunedì: una serie di domande sul golf a codice corto , pubblicate (si spera!) Ogni lunedì.
A volte la gente si stanca delle regole della vita: "non farlo", "non puoi farlo", "non ti permetteremo di farlo". A volte può sembrare davvero restrittivo! Ma ogni tanto è bello divertirsi un po ', quindi scriviamo un po' di codice per modificare queste regole. E mentre ci siamo, potrebbe anche modificare altre negatività. (Naturalmente, queste modifiche non saranno solo temporanee, quindi lasceremo anche la formulazione originale.)
Sfida
La tua sfida è quella di scrivere un programma o una funzione che metta le <s>barrette HTML </s>intorno a parole restrittive - ovvero parole che finiscono n'to seguite da not- e dopo ognuna di esse, inserisce il suo equivalente positivo in TUTTI MAIUSCOLI. Alla fine, dopo uno spazio, dovrebbe essere incluso il numero di sostituzioni effettuate. Per esempio:
Please don't jump into the pool.
diventa
Please <s>don't</s> DO jump into the pool. 1
Per le parole che terminano in n'to seguite da not(oltre che cannot), l'equivalente positivo è tutto fino a quanto sopra not(spazi esclusi). Ecco cosa intendo:
do not speakdiventa<s>do not</s> DO speakit doesn't workdiventait <s>doesn't</s> DOES workwe cannotdiventawe <s>cannot</s> CAN
Comunque, ci sono alcune eccezioni. Assicurarsi che siano gestiti correttamente.
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
Dettagli
- L'input non conterrà mai spazi bianchi tranne gli spazi normali (senza tabulazioni, newline, ecc.).
- L'input non conterrà mai doppi negativi (ad es
we can't not do this.). - Se a
notappare immediatamente dopo un segno di punteggiatura o come parte di un'altra parola, lascialo. - Assicurati di conservare il testo originale, incluso maiuscolo / minuscolo, tra i
<s></s>tag. - Se lo desideri, puoi utilizzare
<strike></strike>al posto di<s></s>.
Casi test
ingressi:
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.
Uscite:
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
punteggio
Questo è code-golf , quindi vince il codice valido più breve in byte. Tiebreaker va all'invio che ha raggiunto per primo il numero di byte finale. Il vincitore non sarà scelto il prossimo lunedì 26 ottobre. Buona fortuna!
Can't we capitalize special cases?
Oh this? It's nothing...o I wonder if we'll notice any words like this??