Conte até 100 em dinamarquês


37

Imprima todos os números de 0 a 100 na ordem correta, usando a maneira dinamarquesa de contar

Como eles contam

  • Como o inglês, eles têm palavras dedicadas para 0-20, 30, 40 e 100
  • Em vez de dizer twenty-onee twenty-two, eles dizem one and twentyetwo and twenty
  • Começando com cinquenta, eles dizem múltiplos de 10 como n * 20

    50 = half third times twenty = half way to the 3rd multiple of 20
    60 = three times twenty
    70 = half fourth times twenty
    80 = four times twenty
    90 = half fifth times twenty
    

    Assim, por exemplo, 55 seria five and half third times twenty.

Saída esperada

zero
one
two
three
four
five
six
seven
eight
nine
ten
eleven
twelve
thirteen
fourteen
fifteen
sixteen
seventeen
eighteen
nineteen
twenty
one and twenty
two and twenty
three and twenty
four and twenty
five and twenty
six and twenty
seven and twenty
eight and twenty
nine and twenty
thirty
one and thirty
two and thirty
three and thirty
four and thirty
five and thirty
six and thirty
seven and thirty
eight and thirty
nine and thirty
forty
one and forty
two and forty
three and forty
four and forty
five and forty
six and forty
seven and forty
eight and forty
nine and forty
half third times twenty
one and half third times twenty
two and half third times twenty
three and half third times twenty
four and half third times twenty
five and half third times twenty
six and half third times twenty
seven and half third times twenty
eight and half third times twenty
nine and half third times twenty
three times twenty
one and three times twenty
two and three times twenty
three and three times twenty
four and three times twenty
five and three times twenty
six and three times twenty
seven and three times twenty
eight and three times twenty
nine and three times twenty
half fourth times twenty
one and half fourth times twenty
two and half fourth times twenty
three and half fourth times twenty
four and half fourth times twenty
five and half fourth times twenty
six and half fourth times twenty
seven and half fourth times twenty
eight and half fourth times twenty
nine and half fourth times twenty
four times twenty
one and four times twenty
two and four times twenty
three and four times twenty
four and four times twenty
five and four times twenty
six and four times twenty
seven and four times twenty
eight and four times twenty
nine and four times twenty
half fifth times twenty
one and half fifth times twenty
two and half fifth times twenty
three and half fifth times twenty
four and half fifth times twenty
five and half fifth times twenty
six and half fifth times twenty
seven and half fifth times twenty
eight and half fifth times twenty
nine and half fifth times twenty
one hundred

Regras

  • Você pode usar qualquer separador para separar os números
  • Devido a um erro de digitação na especificação original, você pode usar em forthvez de fourth.
  • Você pode escrever uma função ou gravar em std-out
  • Aplicam-se brechas padrão
  • Isso é codegolf; o menor código em bytes ganha!


4
Por que todos os espaços? 55 é femoghalvtredsindstyve em dinamarquês, não fem e halv tred sinds tyve .
Adám 08/09/16

11
O resultado esperado parece decididamente não dinamarquês para mim. (E 55 são femoghalvtreds , não femoghalvtreds instyve a menos que você esteja sendo deliberadamente arcaico).
Henning Makholm 8/09/16

8
@ Adám Decidi usar palavras em inglês, em vez de dinamarquesas, para tornar o desafio mais acessível, e não contratamos palavras em inglês.
BlackCap 8/09/16

6
@BlackCap: Algumas palavras se tornam contratadas ao longo do tempo. Por exemplo, é captura de tela , não captura de tela .
Peter Mortensen

Respostas:


14

JavaScript (ES6), 347 336 326 325 308 bytes

for(a=btoa`...`.split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))

Antes de executar, substitua o ...pelo resultado da execução deste código:

atob("zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh")

Ou você pode simplesmente usar a versão não compactada:

for(a="zero0one0two0three0four0five0six0seven0eight0nine0ten0eleven0twelve0thir00fif000eigh".split(i=0);i<101;i++)alert(i<13?a[i]:i<20?(a[i]||a[i-10])+"teen":i>99?"one hundred":(i%10?a[i%10]+" and ":"")+(i<30?"twenty":i<40?"thirty":i<50?"forty":(i%20>9?"half "+["third","forth","fifth"][i/20-2|0]:a[i/20|0])+" times twenty"))

Ainda provavelmente não é o ideal. 11 bytes salvos em parte por @Titus.


Eu estava errado. é uma maneira razoável de jogar golfe as exceções.
Titus

-7 bytes: em (x%20>9?"half ":"")+[third,forth,fifth][x/20-2.5|0]vez de(x%20>9?"half "+[third,forth,fifth][x/20-2.5|0]:f(x/20|0))
Titus

@Titus Se eu entendo o que você quer dizer, que gera saída incorreta para 60, 61, ..., 69, 80, 81 ... (por exemplo, third times twentyem vez de three times twenty)
ETHproductions

Oh, eu estava sentindo falta dessa diferença. Você está certo. Mas livre-se da recursão; isso abrirá espaço para um pouco mais de golfe.
Titus

@ Titus Obrigado pela dica. Eu não percebi, mas a recursão estava me poupando exatamente 0 bytes em vez de não recursão. Eu mudei e joguei um pouco mais agora.
ETHproductions

13

Fourier , 7028 bytes

A recompensa irá para a resposta de Paul Schmitz

Isso foi jogado de forma programática usando o programa de golfe do issacg

122a101a114a-3a10a111ava-9a10a116a+3a-8a10a116a104a114a101aa10a102a+9a+6a-3a10a102a+3a118a101a10a115a105a120a10a115a101a118a101a+9a10a101a+4a-2a^a116a10a110a-5a+5a-9a10a116a101a+9a10a101a+7a-7a118a101a+9a10a116a+3a101a+7a118a101a10a116a104a^a+9a+2a101aa+9a10a102a+9a+6a-3a+2a101aa+9a10a102a+3a-3a116a101aa+9a10a115a105a120a-4a101aa+9a10a115a101a118a101a+9a+6a101aa+9a10a101a+4a-2a^a116a101aa+9a10a110a-5a+5a-9a116a101aa+9a10a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a116a+3a101a+9a+6a+5a10a116a104a^a+9a+2a+5a10a111ava-9a32a97a110a100a32a116a104a^a+9a+2a+5a10a116a+3a-8a32a97a110a100a32a116a104a^a+9a+2a+5a10a116a104a114a101aa32a97a110a100a32a116a104a^a+9a+2a+5a10a102a+9a+6a-3a32a97a110a100a32a116a104a^a+9a+2a+5a10a102a+3a118a101a32a97a110a100a32a116a104a^a+9a+2a+5a10a115a105a120a32a97a110a100a32a116a104a^a+9a+2a+5a10a115a101a118a101a+9a32a97a110a100a32a116a104a^a+9a+2a+5a10a101a+4a-2a^a116a32a97a110a100a32a116a104a^a+9a+2a+5a10a110a-5a+5a-9a32a97a110a100a32a116a104a^a+9a+2a+5a10a102a+9a+3a+2a+5a10a111ava-9a32a97a110a100a32a102a+9a+3a+2a+5a10a116a+3a-8a32a97a110a100a32a102a+9a+3a+2a+5a10a116a104a114a101aa32a97a110a100a32a102a+9a+3a+2a+5a10a102a+9a+6a-3a32a97a110a100a32a102a+9a+3a+2a+5a10a102a+3a118a101a32a97a110a100a32a102a+9a+3a+2a+5a10a115a105a120a32a97a110a100a32a102a+9a+3a+2a+5a10a115a101a118a101a+9a32a97a110a100a32a102a+9a+3a+2a+5a10a101a+4a-2a^a116a32a97a110a100a32a102a+9a+3a+2a+5a10a110a-5a+5a-9a32a97a110a100a32a102a+9a+3a+2a+5a10a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a104a117a-7a100a114a101ava

Experimente online!


Aqui está uma sugestão: basta imprimir a saída. Consiste em 1989 caracteres que usam o mesmo número de bytes.
DavidC

2
@ DavidC Até onde eu sei, é assim que você "simplesmente imprime a saída" em Fourier. Não há literais de cadeia de caracteres se foi isso que você quis dizer.
Martin Ender

@DavidC Martin está certo, as strings não existem em Fourier
Decay Beta

Meu Deus, parece uma linguagem muito estranha!
DavidC

Eu tenho 7020 bytes. pastebin.com/WGtHSGFT
Paul Schmitz

8

JavaScript (ES6), não concorrente

Decidi fazer o que o título realmente pedia e contei até 100 på dansk. Isso é baseado na resposta da ETHproductions . São 292 bytes (286 se você usar o alerta)

for(a="nul0en0to0tre0fire0fem0seks0syv0otte0ni0ti0elleve0tolv0tret0fjor0fem0seks0syt0at0nit".split(i=0);i<101;i++)console.log(i<13?a[i]:i<20?(a[i])+"ten":i>99?"hundrede":(i%10?a[i%10]+"og":"")+(["tyve","tredive","fyrre","halvtreds","tres","halvfjerds","firs","halvfems"][Math.floor(i/10)-2]))


Para ser justo, você deve anexar instyve a cada número que termina em s .
Adám 08/09/16

@ Adám: Por que sim? O instante- é etimologia, não dinamarquês de verdade, como se fala atualmente.
Henning Makholm 8/09/16

Sim, mas o OP inglês inclui, caso contrário, deve-se dizer que 55 seriafive and half third t .
Adám 08/09/16

8

Mathematica 251 238 230 bytes

Isso agora apresenta a saída no formato de uma lista, para salvar mais 8 bytes.

c@s_:=s<>" times twenty";f@n_:=Which[n<21∨{30,40,100}~MemberQ~n,IntegerName@n,n==50,c@"half third",n==60,c@"three",n==70,c@"half forth",n==80,c@"four",n==90,c@"half fifth",3>2,NumberExpand@n/.{t_,u_}:>f@u<>" plus "<>f@t];f/@0~Range~100

Estou realmente com ciúmes de que a função IntegerName
Cabeção

Sim, faz uma boa quantidade de trabalho. NumberExpandtambém é útil para decompor um número (em qualquer base). `NumberExpand [943] -> {900,40,3}
DavidC

7

/// , 434 bytes

/(/\/\///D/\/7(7/ and (2/twenty(4/ times (_/half ([/42
(&/three(;/thir()/four(!/fort($/_fifth[(#/seven(^/eight(@D;ty
(%D_!h[(*D_;d[(-/nine(`D!y
(F/five(T/teen
(O/one(X/six(GD&[(HD)[(ID2
(Y/two(AD$/zero
O
Y
&
)
F
X
#
^
-
ten
eleven
twelve
;T)TfifTXT#T^een
-T2
OIYI&I)IFIXI#I^I-I;ty
O@Y@&@)@F@X@#@^@-@!y
O`Y`&`)`F`X`#`^`-`_;d42
O*Y*&*)*F*X*#*^*-*&[OGYG&G)GFGXG#G^G-G_!h[O%Y%&%)%F%X%#%^%-%)[OHYH&H)HFHXH#H^H-H$OAYA&A)AFAXA#A^A-AO hundred

Experimente online!


7

PHP, 397 375 372 381 386 365 bytes

Isso era engraçado demais para ser ignorado. Possivelmente pode ser jogado ainda mais.

zero_<?=join(_,$a=[one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen,eighteen,nineteen])._;foreach([twenty,thirty,forty]as$t)for($i=-2;$i++<8;)echo($i<0?'':$c[]="$a[$i] and ").$t._;foreach([third,three,fourth,four,fifth]as$k=>$t)for($i=-2;$i++<8;)echo$c[$i],($k&1?'':'half '),"$t times twenty_";?>one hundred
  • Ele usa sublinhado como separador
  • 10 a 19 ainda estão codificados; qualquer forma de calculá-los não dá tanto quanto a junção.

5

PHP, 333 328 321 bytes

A expressão do @ ETHproductions foi portada para PHP e reduzida. Estou surpreso que o PHP possa vencer o JavaScript sem nenhum built-in .

Eu acho que os componentes mais poderosos são as previsões implícitas:

  • Não preciso de aspas para a maioria das strings, que por si só valem 12 bytes;
  • e me permite usar uma matriz diretamente, em vez de dividir uma string.
  • a indexação da matriz está implicitamente convertendo quaisquer flutuadores para inteiro, economizando 6 bytes.

MAS: Eu preciso de $s (21 deles) para dizer ao PHP que é uma variável.

Ainda não está claro de onde vêm os 15 bytes. Eu não joguei muito fora. Ou eu fiz? ETH apanhados.

<?$a=[zero,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thirteen,'',fifteen,'','',eighteen];for($n=-1;$n++<99;)echo$n>19?($n%10?$a[$n%10].' and ':'').($n>49?($n%20>9?"half ".[third,forth,fifth][$n/20-2.5]:$a[$n/20]).' times twenty':[twen,thir,'for'][$n/10-2].ty):($a[$n]?:$a[$n%10].teen),_;?>one hundred

Vencendo você agora;)
ETHproductions

5

C (gcc) , 445 426 452 449 444 439 bytes

*t[]={0,0,"twenty","thirty","fourty",[10]="one hundred","third","fourth","fifth"},*o[101]={"zero","one","two","three","four","five","six","seven","eight","nine","ten","eleven","twelve","thirteen","fourteen","fifteen","sixteen","seventeen","eighteen","nineteen"};i,p;main(j){for(;i<'e';i++)p=i%10,o[i]?puts(o[i]):printf("%s%s%s%s%s%s\n",p?o[p]:t,p?" and ":t,!t[j]&j%2?"half ":t,t[j]?t:j%2?t[j/2+9]:o[j/2],t[j]?t:" times ",t[j=i/10]?:t[2]);}

Experimente online!

19 22 27 bytes cortados graças a @ceilingcat, mas 26 bytes foram adicionados novamente, 3 para evitar um segfault (o [] realmente precisa ter 101 entradas) e, ao verificar as regras novamente, notei que tínhamos que imprimir todos os números de 0 a 100, não apenas forneça uma função que imprima um número.

Ungolfed:

char *t[] = {0, 0, "twenty", "thirty", "fourty", 0, 0, 0, 0, 0, "one hundred", "third", "fourth", "fifth"};
char *o[101] = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten",
                "eleven", "twelve", "thirteen", "fourteen", "fifteen", "sixteen", "seventeen", "eighteen", "nineteen"};
int i = 0;
int j = 0;
int p = 0;

main()
{
  for(; i < 101; i++) {
    p = i % 10;
    if(o[i])
        puts(o[i]);
    else
        printf("%s%s%s%s%s%s\n",
               p ? o[p] : "",
               p ? " and " : "",
               !t[j] & j % 2 ? "half " : "",
               t[j] ? "" : j % 2 ? t[j / 2 + 9] : o[j / 2],
               t[j] ? "" : " times ",
               t[j = i / 10] ? : t[2]
        );
  }
}
```

4

Fourier, 7020 bytes

122a101~za114a-3a10a111ava-9a10a116a+3a-8a10a116a104a114a101aa10a102a+9a+6a-3a10a102a+3a118a101a10a115a105a120a10a115a101a118a101a+9a10a101a+4a-2a^a116a10a110a-5a+5a-9a10a116a101a+9a10a101a+7a-7a118aza+9a10a116a+3a101a+7a118a101a10a116a104a^a+9a+2a101aa+9a10a102a+9a+6a-3a+2a101aa+9a10a102a+3a-3a116a101aa+9a10a115a105a120a-4a101aa+9a10a115a101a118aza+9a+6a101aa+9a10aza+4a-2a^a116a101aa+9a10a110a-5a+5a-9a116a101aa+9a10a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a116a+3a101a+9a+6a+5a10a116a104a114azaa32a97a110a100a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a116a+3a101a+9a+6a+5a10a102a+3a118aza32a97a110a100a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a116a+3a101a+9a+6a+5a10a116a104a^a+9a+2a+5a10a111ava-9a32a97a110a100a32a116a104a^a+9a+2a+5a10a116a+3a-8a32a97a110a100a32a116a104a^a+9a+2a+5a10a116a104a114a101aa32a97a110a100a32a116a104a^a+9a+2a+5a10a102a+9a+6a-3a32a97a110a100a32a116a104a^a+9a+2a+5a10a102a+3a118a101a32a97a110a100a32a116a104a^a+9a+2a+5a10a115a105a120a32a97a110a100a32a116a104a^a+9a+2a+5a10a115a101a118a101a+9a32a97a110a100a32a116a104a^a+9a+2a+5a10a101a+4a-2a^a116a32a97a110a100a32a116a104a^a+9a+2a+5a10a110a-5a+5a-9a32a97a110a100a32a116a104a^a+9a+2a+5a10a102a+9a+3a+2a+5a10a111ava-9a32a97a110a100a32a102a+9a+3a+2a+5a10a116a+3a-8a32a97a110a100a32a102a+9a+3a+2a+5a10a116a104a114a101aa32a97a110a100a32a102a+9a+3a+2a+5a10a102a+9a+6a-3a32a97a110a100a32a102a+9a+3a+2a+5a10a102a+3a118a101a32a97a110a100a32a102a+9a+3a+2a+5a10a115a105a120a32a97a110a100a32a102a+9a+3a+2a+5a10a115a101a118a101a+9a32a97a110a100a32a102a+9a+3a+2a+5a10a101a+4a-2a^a116a32a97a110a100a32a102a+9a+3a+2a+5a10a110a-5a+5a-9a32a97a110a100a32a102a+9a+3a+2a+5a10a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a104a97a108a-6a32a116a104a^a+9a100a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a116a104a114a101aa32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a104a97a108a-6a32a102a+9a+6a-3a+2a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a102a+9a+6a-3a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a+3a-8a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a116a104a114a101aa32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+9a+6a-3a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a102a+3a118a101a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a105a120a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a115a101a118a101a+9a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a101a+4a-2a^a116a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a110a-5a+5a-9a32a97a110a100a32a104a97a108a-6a32a102a+3a-3a116a104a32a116a105a+4a-8a115a32a116a+3a101a+9a+6a+5a10a111ava-9a32a104a117a-7a100a114a101ava

Esta é uma versão aprimorada do programa Beta Decays.


4

Haskell, 308 291 285 bytes

w=words;q x=map(++x);m=w"thir four fif six seven eigh nine";t=w"zero one two three four five six seven eight nine ten eleven twelve"++q"teen"m++q"ty"(do b<-"twen":take 2m++q" times twen"["half third",t!!3,"half fourth",t!!4,"half fifth"];b:q b(q" and ".take 9$tail t))++["one hundred"]

Versão legível:

w   = words
m   = w "thir four fif six seven eigh nine"
q x = map (++x)

t = w "zero one two three four five six seven eight nine ten eleven twelve"
 ++ q "teen" m 
 ++ q "ty" (do b <- "twen" : take 2 m
                     ++ q " times twen"
                          ["half third",t!!3,"half fourth",t!!4,"half fifth"]
               b:q b(q" and ".take 9$tail t)
           )
 ++ ["one hundred"]

Também 285

w=words;m=w"thir four fif six seven eigh nine";x!l=map(++x)l
t  = w"zero one two three four five six seven eight nine ten eleven twelve"
  ++ "teen"!m
  ++ "ty"!(
  do x<-"twen":take 2m++" times twen"!
         ["half third",t!!3,"half fourth",t!!4,"half fifth"]
     x:x!(" and "!take 9(tail t)))
  ++ ["one hundred"]

Pode não parecer muito diferente, mas representa horas de fatoração que eventualmente me trouxeram um círculo completo. Eu acho que já fiz isso antes ..


Droga, desafio Nordic-relacionado e assim já há uma solução fp Mal posso melhorar (fp ser bastante popular nos países nórdicos, não?)
Leif Willerts

@LeifWillerts Não conheço mais ninguém que pratique fp, nem o ensina nas escolas - infelizmente. Você poderia tentar Lisp, ele tem format nil "~R"que converte números para sua representação de texto Inglês
Cabeção

Por que você sugere que o Lisp? Bem, fui ensinado FP na Alemanha por um professor que passou muito tempo em Chalmers, na Suécia, e aqui em Copenhague eles ensinam isso em um nível bastante alto e há uma comunidade ativa na cidade. Erlang foi famoso pela Ericsson na Suécia. Onde você está e o que você faz?
Leif Willerts 9/09/16

@LeifWillerts Estou na Noruega, acabei de me formar no ensino médio e decidi trabalhar no webdev por um ano antes de ir para a universidade. Obviamente, verifiquei quais opções tenho e nenhuma delas é fp. Nenhuma das minhas faculdades ou amigos sequer ouviu falar de programação funcional antes de me conhecerem. Além disso, sugeri o Lisp porque metade dos meus bytes vem do armazenamento de números em strings, e você pode contornar isso no Lisp.
BlackCap 9/09/16

Por que não é competitivo? Só porque você é OP não significa AFAIK não concorrente. Os mods me corrigem se eu estiver errado ...
Erik, o Outgolfer, em 11/09/16

3

Python 2, 359 349 345 bytes

a='one two three four five six seven eight nine'.split()
c=['ten','eleven','twelve']+[i+'teen'for i in['thir',a[3],'fif',a[5],a[6],'eigh',a[8]]]
p=' times twenty'
h='half '
x=[p[7:],'thirty','forty',h+'third'+p,a[2]+p,h+'forth'+p,a[3]+p,h+'fifth'+p]
f=['zero']+a+c
for i in x:f+=[i];f+=[b+' and '+i for b in a] 
for i in f+['one hundred']:print i

Explicação:

Crie uma lista dos 9 primeiros números.
Crie uma lista dos próximos 10 números.
Criar uma lista das terminações - twenty, thirty, forty, half third times twentyetc
Junte-se às duas primeiras listas com zero
Anexar à lista de cada um dos números de 50 em diante.
Imprimir lista

Código não destruído:

firstNumbers=['one','two','three','four','five','six','seven','eight','nine']
teenNumbers=['ten','eleven','twelve','thirteen','fourteen','fifteen','sixteen','seventeen','eighteen','nineteen']
endings=['twenty','thirty','forty','half third times twenty','three times twenty','half forth times twenty','four times twenty','half fifth times twenty']
joined=['zero']+firstNumbers+teenNumbers
for ending in endings:
    joined.append(ending)
    for number in firstNumbers:
        joined.append(number + 'and' + ending)
joined.append('one hundred')
for line in joined:
    print line

Alguns jogos de golfe: linha adolescente - remova o espaço depois in; mude qpara o único local em que é usado; dofor i in f+['one hundred']:print i
Jonathan Allan

1
@ JonathanAllan A pontuação realmente mediu com q = 'e' - eu tinha notado, esqueci de mudar aqui! Obrigado!
Tim

3

Python 2, com num2words, 206 bytes

Mesmo com num2words, são necessários alguns bytes!

Este é um programa completo.

from num2words import num2words as w
for i in range(1,101):d=i/10;e=w(i).split('-');print' and '.join(e[1:]+[10>d>4 and((d%2 and'half '+{5:'third',7:'forth',9:'fifth'}[d]or w(d/2))+' times twenty')or e[0]])

Aqui está uma versão zombada do ideone
(com zombaria, quero dizer que, como o intérprete on-line não possui num2words, substituí-o wpor um lambdaque procura a num2wordsaída de uma lista)

ungolfed e com 'quarto' em vez do permitido 'adiante' (que salva um byte):

from num2words import num2words
for i in range(1,101):
    d = i / 10 # i div 10
    e = num2words(i).split('-') # i in English words with a "-" separator, split into parts
    if d > 4 and d < 10:
        if d % 2:
            p = 'half '+ {5:'third', 7:'fourth', 9:'fifth'}[d] + ' times twenty'
        else:
            p = num2words(d / 2) + ' times twenty'
    else:
        p = e[0]
    print' and '.join(e[1:]+[p])

Observe que o separador usado por num2words(100)é um espaço, enquanto para os outros números é um "-", portanto, não precisamos fazer nada sofisticado para esse caso senão impedir que ele seja "cinco vezes vinte".


a parte, de lado

Se o desafio fosse realmente produzir os números em dinamarquês, seria possível pegar o lang_DK.py na página do github e usar:

from num2words import*
[num2words(i,lang='dk')for i in range(1,101)]

para 68 bytes, produzindo:

['et', 'to', 'tre', 'fire', 'fem', 'seks', 'syv', 'otte', 'ni', 'ti', 'elleve', 'tolv', 'tretten', 'fjorten', 'femten', 'seksten', 'sytten', 'atten', 'nitten', 'tyve', 'enogtyve', 'toogtyve', 'treogtyve', 'fireogtyve', 'femogtyve', 'seksogtyve', 'syvogtyve', 'otteogtyve', 'niogtyve', 'tredive', 'enogtredive', 'toogtredive', 'treogtredive', 'fireogtredive', 'femogtredive', 'seksogtredive', 'syvogtredive', 'otteogtredive', 'niogtredive', 'fyrre', 'enogfyrre', 'toogfyrre', 'treogfyrre', 'fireogfyrre', 'femogfyrre', 'seksogfyrre', 'syvogfyrre', 'otteogfyrre', 'niogfyrre', 'halvtreds', 'enoghalvtreds', 'tooghalvtreds', 'treoghalvtreds', 'fireoghalvtreds', 'femoghalvtreds', 'seksoghalvtreds', 'syvoghalvtreds', 'otteoghalvtreds', 'nioghalvtreds', 'treds', 'enogtreds', 'toogtreds', 'treogtreds', 'fireogtreds', 'femogtreds', 'seksogtreds', 'syvogtreds', 'otteogtreds', 'niogtreds', 'halvfjerds', 'enoghalvfjerds', 'tooghalvfjerds', 'treoghalvfjerds', 'fireoghalvfjerds', 'femoghalvfjerds', 'seksoghalvfjerds', 'syvoghalvfjerds', 'otteoghalvfjerds', 'nioghalvfjerds', 'firs', 'enogfirs', 'toogfirs', 'treogfirs', 'fireogfirs', 'femogfirs', 'seksogfirs', 'syvogfirs', 'otteogfirs', 'niogfirs', 'halvfems', 'enoghalvfems', 'tooghalvfems', 'treoghalvfems', 'fireoghalvfems', 'femoghalvfems', 'seksoghalvfems', 'syvoghalvfems', 'otteoghalvfems', 'nioghalvfems', 'ethundrede']

3

Bash (usando reve sed),299 276 bytes

Eu estou usando chaves de expansão do bash. No entanto, as chaves são expandidas na ordem errada, por isso imprimo todas as palavras em ordem invertida e depois fixo a ordem das letras usando rev. Depois disso, ainda preciso de alguns ajustes usando sed:

printf '%s\n' orez {,{neet,yt{newt,riht,rof},ytnewt\ semit\ {drihtX,eerht,htruofX,ruof,htfifX}}Y}{,eno,owt,eerht,ruof,evif,xis,neves,thgie,enin} derdnuh\ eno |rev |sed -r 's,^Yte,t,;s,^Y,,;12s,.*,eleven,;13s,o.*,elve,;1,20{s,reeY,ir,;s,veY,f,;s,(t|)Y,,};s,Y, and ,;s,X,half ,'

Um pouco menos ilegível:

printf '%s\n' orez {,{neet,yt{newt,riht,rof},\
ytnewt\ semit\ {drihtX,eerht,htruofX,ruof,htfifX}}Y}\
{,eno,owt,eerht,ruof,evif,xis,neves,thgie,enin} \
    derdnuh\ eno \
    |rev \
    |sed -r 's,^Yte,t,;
            s,^Y,,;
            12s,.*,eleven,;
            13s,o.*,elve,;
            1,20{s,reeY,ir,;s,veY,f,;s,(t|)Y,,};
            s,Y, and ,;
            s,X,half ,'

2

JavaScript (ES6), 346 bytes

Apenas uma pequena idéia para a solução da ETHproductions: Substitua f(..)por a[..]para poder ligar frecursivamente para concaturar a saída.

f=x=>(a="1one1two1three1four1five1six1seven1eight1nine1ten1eleven1twelve1thir11fif111eigh".split(1),x<1?"zero":f(x-1)+(x<13?a[x]:x<20?(a[x]||a[x-10])+"teen":x>99?"one hundred":(x%10?a[x%10]+" and ":"")+(x<50?"twen1thir1for".split(1)[x/10-2|0]+"ty":(x%20>9?"half "+"third1forth1fifth".split(1)[x/20-2.5|0]:a[x/20|0])+" times twenty")))+"\n"
f(100)

Ainda longe do ideal ...


2

Java 8 7, 512 490 + 19 bytes (importação)

Precisa de uma importação import java.util.*;

<T>void y(List<T>l,T...a){for(T t:a)l.add(t);}List x(){String b="teen",c="twenty",d="half ",e=" times "+c;String[]a={"zero","one","two","three","four","five","six","seven","eight","nine"},f={c,"thirty","fourty",d+"third"+e,a[3]+e,d+"fourth"+e,a[4]+e,d+"fifth"+e};List<String>g=new ArrayList<>(Arrays.asList(a));y(g,"ten","eleven","twelve","thir"+b,a[4]+b,"fif"+b,a[6]+b,a[7]+b,"eigh"+b,a[9]+b);for(String h:f){y(g,h);for(int i=1;i<=9;i++)y(g,(a[i]+" and "+h));}y(g,"one hundred");return g;}

Ungolfed:

<T> void y(List<T> l, T... a) {
    for (T t : a) {
        l.add(t);
    }
}

List x() {
    String b = "teen", c = "twenty", d = "half ", e = " times " + c;
    String[] a = {"zero", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"},
        f = {c, "thirty", "fourty", d + "third" + e, a[3] + e, d + "fourth" + e, a[4] + e, d + "fifth" + e};
    List<String> g = new ArrayList<>(Arrays.asList(a));
    y(g, "ten", "eleven", "twelve", "thir" + b, a[4] + b, "fif" + b, a[6] + b, a[7] + b, "eigh" + b, a[9] + b);

    for (String h : f) {
        y(g, h);
        for (int i = 1; i <= 9; i++) {
            y(g, (a[i] + " and " + h));
        }
    }

    y(g, "one hundred");
    return g;
}

Para executar isso, basta ligar <instance>.x();. Isso agora retorna a lista que contém todos os números.

Experimente aqui!


2

PHP, 318 bytes

for($i=~0;$i++<100;)echo([0=>zero,10=>ten,eleven,twelve,thirteen,15=>fifteen,18=>eighteen,100=>"one hundred"][$i]??["",one,two,three,four,five,six,seven,eight,nine][$i%10].($i>20&&$i%10?" and ":"").["",teen,twenty,thirty,forty,"half third",three,"half fourth",four,"half fifth"][$i/10].($i>49?" times twenty":"")).",";

primeira escolha com o operador coalescente nulo? as exceções.

esta versão com 314 bytes não possui, no final

zero<?php for($i=0;$i++<100;)echo",".([10=>ten,eleven,twelve,thirteen,15=>fifteen,18=>eighteen][$i]??["",one,two,three,four,five,six,seven,eight,nine][$i%10].($i>20&&$i%10?" and ":"").["",teen,twenty,thirty,forty,"half third",three,"half fourth",four,"half fifth"][$i/10].($i>49?" times twenty":""));?>,one hundred

2

05AB1E , 127 123 120 115 bytes

“¡×€µ‚•„í†ìˆÈŒšï¿Ÿ¯¥Š—¿áÓÁωª†ìdßàŒšdï¿dŸ¯een¥Šd“¤'…§:#©`…«¹¿œÖƒ#“‰ª„í¦ƒ†ì³ä“#ε…ÿ„Æ«¹NÈi„Š£ ì]«vyTG®Nè'€ƒ‚yª]„€µ°¡»

Experimente online!

“¡× (...) Šd“         # dictionary string "zero one two ... sixd sevend eighteen nined"
¤                     # get the last letter ("d") without popping 
 '…§                  # dictionary string "teen"
    :                 # replace (changes all "d" to "teen" in the initial string)
     #                # split on spaces
      ©               # save this list to the register
       `              # dump all items on the stack
…«¹¿œÖƒ               # dictionary string "twenty thirty fourty"
       #              # split on spaces
“‰ª„í¦ƒ†ì³ä“          # dictionary string "third three fourth four fifth"
            #         # split on spaces
ε              ]      # for each:
 …ÿ„Æ«¹               #  append " times twenty"
       NÈi     ]      #  if the iteration count is even:
          „Š£ ì       #   prepend "half "
                «     # merge those two lists ([20, 30, 40] and [50, 60, 70, 80, 90])
v            ]        # for y in this list of names:
 y                    #  put y on the stack
  TG         ]        #  for N from 1 to 9:
    ®Nè               #   get the Nth element in the register
       '€ƒ‚           #   append "and"
           yª         #   append y
„€µ°¡                 # dictionary string "one hundred"
     »                # join the stack with newlines

1

tinta , 286 bytes

-(c){
-c>11 and c<21:
{eleven|twelve|thir|four|fif|six|seven|eigh|nine}{||teen}
-c%10==1:
~temp t="{zero|ten|twenty|thirty|forty|{&half {third|fourth|fifth}|{three|four|five}} times twenty}"
{t}
-1:
{&one|two|three|four|five|six|seven|eight|nine}{c>19: and {t}}
}
{c<100:->c}one hundred

Experimente online!

A tinta tem sequências - elas se parecem {a|b|c} e avaliam um valor diferente a cada vez, até que não exista um valor próximo no qual elas permaneçam com a última - é por isso que {||teen}continua emitindo teenapós a saída nada nas duas primeiras vezes que é encontrada. Ao combinar e aninhar esses, podemos avançar bastante com muito pouco em termos de condicionais reais.

Uma sequência que começa com {& não apenas, {é um ciclo - esses ciclos e é assim que contamos unidades e como alternamos entre "meia enésima vez vinte" e "n vezes vinte" para as dezenas.

Nós controlamos o nome das dezenas em uma variável tque somente atualizamos a cada décimo passo no loop. Nos passes em que atualizamos a variável, imprimimos apenas a variável, nos outros passes usamos ciclos para imprimir a unidade seguida por and {t}.
Com algumas exceções - abaixo de dez, pulamos a impressão das dezenas (não three and zero) e os adolescentes são irregulares o suficiente para obter uma sequência só para eles.

cé uma reunião rotulada. Reuniões sozinhas não fazem nada, mas podem ser desviadas como uma forma de fluxo de controle e registram quantas vezes foram visitadas - usamos esse número de leitura para casos especiais dos adolescentes, para saber quando precisamos atualizar a variável dezenas e saber quando parar o loop, embrulhe tudo e imprima cem.

Eu sei que poderia salvar um byte usando "adiante" em vez de "quarto", mas estou optando por não.

Ungolfed

- (c)
{
- c > 11 and c < 21:                                        // If c is strictly between 11 and 21 we're in the teens
  {eleven|twelve|thir|four|fif|six|seven|eigh|nine}{||teen} // They get a sequence of their own because they don't fit into the other numbers' pattern.
- c % 10 == 1:                                              // Otherwise, if we're meant to print a multiple of ten
  // Set the variable t to the multiple of ten we want. Note the cycle to alternate between "half nth" and "n"
  ~ temp t="{zero|ten|twenty|thirty|forty|{&half {third|fourth|fifth}|{three|four|five}} times twenty}"

  {t}                                                       // Print the contents of t
- else:                                                     // Otherwise, we go with the usual pattern
  {&one|two|three|four|five|six|seven|eight|nine}           // Print the unit - this is a cycle, so it loops when it's been run through nine times.
  {c > 10:<> and {t}}                                       // If we're past ten (and, since we didn't enter the "teens" section earlier, past twenty), also print the contents of the variable t.
}
{c < 100: -> c}                                             // If we've done all this fewer than a hundred times, we go back to the top.
one hundred                                                 // Print "one hundred"
// Out of content, end of program
Ao utilizar nosso site, você reconhece que leu e compreendeu nossa Política de Cookies e nossa Política de Privacidade.
Licensed under cc by-sa 3.0 with attribution required.