Non ho controllato la sandbox prima di pubblicare questa sfida - sembra che questa sfida sia stata proposta da Cᴏɴᴏʀ O'Bʀɪᴇɴ .
Dato un input intero, scrivi un programma che stampa l'indovinello "quattro è un numero magico"
- Quattro è il numero magico
- Cinque è quattro e quattro è il numero magico
- Sei è tre e tre è cinque e cinque è quattro e quattro è il numero magico
- Undici è sei e sei è tre e tre è cinque e cinque è quattro e quattro è il numero magico
- Cinquecento è undici e undici sono sei e sei è tre e tre è cinque e cinque è quattro e quattro è il numero magico
Se conosci già l'enigma o sei troppo pigro per risolverlo ansioso di scoprire qual è l'enigma, ecco una spiegazione
Il numero successivo è il numero di lettere nel numero precedente. Quindi, ad esempio, cinque ha quattro lettere, quindi il numero successivo è quattro .
sei ha tre lettere, quindi il numero successivo è 3 e tre ha cinque lettere, quindi il numero successivo è 5 e cinque ha quattro lettere, quindi il numero successivo è 4
Il motivo per cui l'indovinello termina a quattro è perché quattro ha quattro lettere e quattro è quattro e quattro è quattro e quattro è quattro ... (quattro è il numero magico)
Casi test
0 =>
Zero is four and four is the magic number
1 =>
One is three and three is five and five is four and four is the magic number
2 =>
Two is three and three is five and five is four and four is the magic number
3 =>
Three is five and five is four and four is the magic number
4 =>
Four is the magic number
5 =>
Five is four and four is the magic number
6 =>
Six is three and three is five and five is four and four is the magic number
7 =>
Seven is five and five is four and four is the magic number
8 =>
Eight is five and five is four and four is the magic number
9 =>
Nine is four and four is the magic number
10 =>
Ten is three and three is five and five is four and four is the magic number
17 =>
Seventeen is nine and nine is four and four is the magic number
100 =>
One Hundred is ten and ten is three and three is five and five is four and four is the magic number
142 =>
One Hundred Forty Two is eighteen and eighteen is eight and eight is five and five is four and four is the magic number
1,000 =>
One Thousand is eleven and eleven is six and six is three and three is five and five is four and four is the magic number
1,642 =>
One Thousand Six Hundred Forty Two is twenty nine and twenty nine is ten and ten is three and three is five and five is four and four is the magic number
70,000 =>
Seventy Thousand is fifteen and fifteen is seven and seven is five and five is four and four is the magic number
131,072 =>
One Hundred Thirty One Thousand Seventy Two is thirty seven and thirty seven is eleven and eleven is six and six is three and three is five and five is four and four is the magic number
999,999 =>
Nine Hundred Ninety Nine Thousand Nine Hundred Ninety Nine is fifty and fifty is five and five is four and four is the magic number
Regole
- L'input può essere preso da
STDINo come argomento di una funzione - L'ingresso sarà un numero positivo compreso tra 0 e 999.999
- L'input conterrà solo numeri (seguirà la regex
^[0-9]+$) - L'input può essere preso come numero intero o come stringa
- Quando convertiti in una stringa di parole, gli spazi e i trattini non devono essere inclusi nel conteggio (100 [Cento] è 10 caratteri, non 11. 1,742 [Mille settecentoquarantadue] è 31 caratteri, non 36)
- Quando convertito in una stringa, 100 dovrebbe essere Cento, non Cento o Cento, 1000 dovrebbero essere Mille, non Mille o Mille.
- Quando convertito in una stringa 142 dovrebbe essere centoquaranta due, non cento e Forty Two
- L'output non fa distinzione tra maiuscole e minuscole e dovrebbe seguire il formato " N è K e K è M e M è ... e quattro è il numero magico" (a meno che l'ingresso sia 4, nel qual caso l'output dovrebbe essere semplicemente "quattro è il numero magico ")
- L'output può utilizzare numeri anziché lettere ("5 è 4 e 4 è il numero magico" anziché "cinque è quattro e quattro è il numero magico") purché il programma sia sempre coerente
- L'output può essere il valore di ritorno di una funzione o essere stampato su
STDOUT - Si applicano scappatoie standard
- Questo è code-golf , quindi vince il programma più breve in byte. In bocca al lupo!
indennità
-30 byte se il programma funziona quando l'input è compreso tra -999.999 e 999.999.
I numeri negativi, quando convertiti in parole, hanno solo "negativo" davanti a loro. Ad esempio -4è "Negativo quattro", Negativo quattro è dodici e dodici è sei e sei è tre e tre è cinque e cinque è quattro e quattro è il numero magico
-150 byte se il programma non utilizza alcuna funzione integrata per generare la rappresentazione in forma di stringa del numero
Classifica
Questo è un frammento di stack che genera sia una classifica che una panoramica dei vincitori per lingua.
Per assicurarti che la tua risposta venga visualizzata, inizia la tua risposta con un titolo usando il seguente modello Markdown
## Language Name, N bytes
Dove N è la dimensione, in byte, dell'invio
Se vuoi includere più numeri nella tua intestazione (ad esempio, colpendo i vecchi punteggi o includendo i flag nel conteggio dei byte), assicurati solo che il punteggio effettivo sia l' ultimo numero nella tua intestazione
## Language Name, <s>K</s> X + 2 = N bytes