Nie sprawdziłem piaskownicy przed opublikowaniem tego wyzwania - wygląda na to, że wyzwanie to zaproponował Cᴏɴᴏʀ O'Bʀɪᴇɴ .
Biorąc pod uwagę liczbę całkowitą, napisz program, który wypisze zagadkę „cztery to magiczna liczba”
- Cztery to magiczna liczba
- Pięć to cztery, a cztery to magiczna liczba
- Sześć to trzy, a trzy to pięć, a pięć to cztery, a cztery to magiczna liczba
- Jedenaście to sześć, a sześć to trzy, a trzy to pięć, a pięć to cztery, a cztery to magiczna liczba
- Pięćset to jedenaście, a jedenaście to sześć, a sześć to trzy, a trzy to pięć, a pięć to cztery, a cztery to magiczna liczba
Jeśli znasz już zagadkę lub jesteś zbyt leniwy, aby ją rozwiązać, pragniesz dowiedzieć się, czym jest zagadka, oto wyjaśnienie
Następny numer to liczba liter w poprzednim numerze. Na przykład pięć ma cztery litery, więc następna liczba to cztery .
sześć ma trzy litery, więc następna liczba to 3 , a trzy mają pięć liter, więc następna liczba to 5 , a pięć ma cztery litery, więc następna liczba to 4
Powód, dla którego zagadka kończy się na czwartej, jest taki, że cztery mają cztery litery , a cztery to cztery, a cztery to cztery, a cztery to cztery ... (cztery to magiczna liczba)
Przypadki testowe
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
Zasady
- Dane wejściowe mogą być pobierane z funkcji
STDINlub jako argument funkcji - Wartość wejściowa będzie liczbą dodatnią od 0 do 999,999
- Dane wejściowe będą zawierały tylko liczby (będą zgodne z wyrażeniem regularnym
^[0-9]+$) - Dane wejściowe można traktować jako liczbę całkowitą lub ciąg znaków
- Po przekształceniu na ciąg słów spacje i łączniki nie powinny być uwzględniane w liczeniu (100 [sto] to 10 znaków, a nie 11. 1,742 [tysiąc siedemset czterdzieści dwa] to 31 znaków, a nie 36)
- Po przekształceniu na ciąg 100 powinno być Sto, a nie Sto lub Sto, 1000 powinno być Tysiąca, a nie Tysiąca lub Tysiąca.
- Po przeliczeniu na ciąg 142 powinny być sto czterdzieści dwa, nie Sto i czterdzieści dwa
- Dane wyjściowe nie rozróżniają wielkości liter i powinny mieć format „ N to K, a K to M, a M to ... a cztery to liczba magiczna” (chyba że dane wejściowe to 4, w takim przypadku dane wyjściowe powinny być po prostu „cztery to magiczna liczba ”)
- Dane wyjściowe mogą używać liczb zamiast liter („5 to 4, a 4 to magiczna liczba” zamiast „pięć to cztery, a cztery to magiczna liczba”), o ile Twój program jest zawsze spójny
- Dane wyjściowe mogą być albo wartością zwracaną przez funkcję, albo drukowane na
STDOUT - Standardowe luki zastosowanie
- To jest golf golfowy , więc wygrywa najkrótszy program w bajtach. Powodzenia!
Premia
-30 bajtów, jeśli program działa, gdy wartość wejściowa wynosi od -999,999 do 999,999.
Liczby ujemne po przeliczeniu na słowa mają po prostu „ujemne” przed sobą. Na przykład -4„Negatywna czwórka”, Negatywna czwórka to dwanaście, a dwanaście to sześć, a sześć to trzy, a trzy to pięć, a pięć to cztery, a cztery to magiczna liczba.
-150 bajtów, jeśli program nie korzysta z żadnych wbudowanych funkcji do generowania ciągu reprezentującego liczbę
Tabela liderów
To jest fragment kodu, który generuje zarówno tabelę wyników, jak i przegląd zwycięzców według języka.
Aby mieć pewność, że Twoja odpowiedź się pojawi, zacznij od nagłówka, korzystając z następującego szablonu Markdown
## Language Name, N bytes
Gdzie N jest rozmiarem twojego przesłania w bajtach
Jeśli chcesz dołączyć wiele liczb do nagłówka (na przykład przekreślając stare wyniki lub włączając flagi w liczbie bajtów), po prostu upewnij się, że rzeczywisty wynik jest ostatnią liczbą w nagłówku
## Language Name, <s>K</s> X + 2 = N bytes