Kardinal dan ordo, 1 hingga 100


28

Inilah yang sederhana untuk meregangkan otot kompresi Anda. Kode Anda (program lengkap) harus menampilkan representasi bahasa Inggris yang dieja dari semua nomor kardinal dari 1 hingga 100, dan kemudian semua nomor urut dari 1 hingga 100. Angka-angka dalam setiap daftar harus dibatasi oleh koma dan spasi serta dengan benar ditulis dgn tanda penghubung. Setiap daftar harus dimulai dengan huruf kapital tunggal dan diakhiri dengan tanda titik. Kedua daftar harus dipisahkan oleh baris baru.

Demi kejelasan, Anda harus menghasilkan aliran byte yang tepat ini:

One, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twenty-one, twenty-two, twenty-three, twenty-four, twenty-five, twenty-six, twenty-seven, twenty-eight, twenty-nine, thirty, thirty-one, thirty-two, thirty-three, thirty-four, thirty-five, thirty-six, thirty-seven, thirty-eight, thirty-nine, forty, forty-one, forty-two, forty-three, forty-four, forty-five, forty-six, forty-seven, forty-eight, forty-nine, fifty, fifty-one, fifty-two, fifty-three, fifty-four, fifty-five, fifty-six, fifty-seven, fifty-eight, fifty-nine, sixty, sixty-one, sixty-two, sixty-three, sixty-four, sixty-five, sixty-six, sixty-seven, sixty-eight, sixty-nine, seventy, seventy-one, seventy-two, seventy-three, seventy-four, seventy-five, seventy-six, seventy-seven, seventy-eight, seventy-nine, eighty, eighty-one, eighty-two, eighty-three, eighty-four, eighty-five, eighty-six, eighty-seven, eighty-eight, eighty-nine, ninety, ninety-one, ninety-two, ninety-three, ninety-four, ninety-five, ninety-six, ninety-seven, ninety-eight, ninety-nine, one hundred.
First, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth, seventeenth, eighteenth, nineteenth, twentieth, twenty-first, twenty-second, twenty-third, twenty-fourth, twenty-fifth, twenty-sixth, twenty-seventh, twenty-eighth, twenty-ninth, thirtieth, thirty-first, thirty-second, thirty-third, thirty-fourth, thirty-fifth, thirty-sixth, thirty-seventh, thirty-eighth, thirty-ninth, fortieth, forty-first, forty-second, forty-third, forty-fourth, forty-fifth, forty-sixth, forty-seventh, forty-eighth, forty-ninth, fiftieth, fifty-first, fifty-second, fifty-third, fifty-fourth, fifty-fifth, fifty-sixth, fifty-seventh, fifty-eighth, fifty-ninth, sixtieth, sixty-first, sixty-second, sixty-third, sixty-fourth, sixty-fifth, sixty-sixth, sixty-seventh, sixty-eighth, sixty-ninth, seventieth, seventy-first, seventy-second, seventy-third, seventy-fourth, seventy-fifth, seventy-sixth, seventy-seventh, seventy-eighth, seventy-ninth, eightieth, eighty-first, eighty-second, eighty-third, eighty-fourth, eighty-fifth, eighty-sixth, eighty-seventh, eighty-eighth, eighty-ninth, ninetieth, ninety-first, ninety-second, ninety-third, ninety-fourth, ninety-fifth, ninety-sixth, ninety-seventh, ninety-eighth, ninety-ninth, one hundredth.

Ini adalah kode golf, jawaban terpendek dalam byte menang.

Jawaban:


28

Gangguan umum, 88 82 80 byte

(format t"~@(~{~R~^, ~}~).
~:*~@(~{~:R~^, ~}~)."(loop as i to 99 collect(1+ i)))

(Ini adalah bagian dari bahasa, saya harap Anda tidak keberatan)

Keluaran

One, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twenty-one, twenty-two, twenty-three, twenty-four, twenty-five, twenty-six, twenty-seven, twenty-eight, twenty-nine, thirty, thirty-one, thirty-two, thirty-three, thirty-four, thirty-five, thirty-six, thirty-seven, thirty-eight, thirty-nine, forty, forty-one, forty-two, forty-three, forty-four, forty-five, forty-six, forty-seven, forty-eight, forty-nine, fifty, fifty-one, fifty-two, fifty-three, fifty-four, fifty-five, fifty-six, fifty-seven, fifty-eight, fifty-nine, sixty, sixty-one, sixty-two, sixty-three, sixty-four, sixty-five, sixty-six, sixty-seven, sixty-eight, sixty-nine, seventy, seventy-one, seventy-two, seventy-three, seventy-four, seventy-five, seventy-six, seventy-seven, seventy-eight, seventy-nine, eighty, eighty-one, eighty-two, eighty-three, eighty-four, eighty-five, eighty-six, eighty-seven, eighty-eight, eighty-nine, ninety, ninety-one, ninety-two, ninety-three, ninety-four, ninety-five, ninety-six, ninety-seven, ninety-eight, ninety-nine, one hundred.
First, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth, seventeenth, eighteenth, nineteenth, twentieth, twenty-first, twenty-second, twenty-third, twenty-fourth, twenty-fifth, twenty-sixth, twenty-seventh, twenty-eighth, twenty-ninth, thirtieth, thirty-first, thirty-second, thirty-third, thirty-fourth, thirty-fifth, thirty-sixth, thirty-seventh, thirty-eighth, thirty-ninth, fortieth, forty-first, forty-second, forty-third, forty-fourth, forty-fifth, forty-sixth, forty-seventh, forty-eighth, forty-ninth, fiftieth, fifty-first, fifty-second, fifty-third, fifty-fourth, fifty-fifth, fifty-sixth, fifty-seventh, fifty-eighth, fifty-ninth, sixtieth, sixty-first, sixty-second, sixty-third, sixty-fourth, sixty-fifth, sixty-sixth, sixty-seventh, sixty-eighth, sixty-ninth, seventieth, seventy-first, seventy-second, seventy-third, seventy-fourth, seventy-fifth, seventy-sixth, seventy-seventh, seventy-eighth, seventy-ninth, eightieth, eighty-first, eighty-second, eighty-third, eighty-fourth, eighty-fifth, eighty-sixth, eighty-seventh, eighty-eighth, eighty-ninth, ninetieth, ninety-first, ninety-second, ninety-third, ninety-fourth, ninety-fifth, ninety-sixth, ninety-seventh, ninety-eighth, ninety-ninth, one hundredth.

Penjelasan

Lihat Output Terformat ke Streaming Karakter .

  • (format t "<control string>" <arguments>)memformat string kontrol sesuai dengan argumen (variadik) dan mencetak ke output standar (karena t)

  • (loop ...) membangun daftar bilangan bulat dari 1 hingga 100

  • ~@( ... ~) mengkapitalisasi string yang dikembalikan oleh string kontrol dalam
  • ~{ ... ~} mengulangi argumen saat ini dan menerapkan pemformatan dalam untuk setiap elemen
  • Di dalam iterasi, segala sesuatu yang berikut ~^ini tidak dicetak pada iterasi terakhir: ini digunakan untuk menambahkan pemisah koma-ruang antara unsur-unsur.
  • ~R menampilkan argumen saat ini sebagai kardinal
  • ~:R menampilkan argumen saat ini sebagai ordinal
  • ~% menampilkan baris baru
  • ~:*atur ulang argumen saat ini untuk diproses seperti yang sebelumnya, yang digunakan di sini untuk menggunakan kembali daftar bilangan bulat untuk kedua kalinya.

Disimpan 2 byte berkat PrzemysławP.


1
Dan saya pikir jawaban saya 340 byte sangat mengesankan ...
kirbyfan64sos

3
Perwakilan Anda saat ini cukup 1337! : D Jadi, sayangnya, saya tidak bisa
memutakhirkan

2
@Numeri Anda dapat memilih sekarang. ;)
DLosc

1
Solusi disingkat kompleksitas kolomogorov dari input selalu sangat mengesankan! Sudah selesai dilakukan dengan baik.
isaacg

1
@Dlikosc Itu hanya baik bagi saya untuk istirahat ...: D
Numeri mengatakan Reinstate Monica

9

Pyth, 366 342 340 bytes

Lcbdj=Y", "++rhJy"one two three four five six seven eight nine"3+tJ+y"ten eleven twelve"+=Nm+d"teen"=by"thir four fif six seven eigh nine"sm+dm++d\-kJKy"twenty thirty forty fifty sixty seventy eighty ninety"+=H"one hundred"\.jY+rh=J++y"first second third"m+d=T"th"tPby"ninth"3+++tJy"tenth eleventh twelfth"+m+dTNsm++Pd"ieth"m++d\-kJK+H"th."

Demo langsung.

Versi 342 byte:

Lcbdj", "++rhJy"one two three four five six seven eight nine"3+tJ+y"ten eleven twelve"+=Nm+d"teen"=by"thir four fif six seven eigh nine"sm+dm++d\-kJKy"twenty thirty forty fifty sixty seventy eighty ninety"+=H"one hundred"\.j", "+rh=J++y"first second third"m+d"th"tPby"ninth"3+++tJy"tenth eleventh twelfth"+m+d"th"Nsm++Pd"ieth"m++d\-kJK+H"th."

Versi 366-byte:

Lcbd
j", "++"One"+tJy"one two three four five six seven eight nine"+y"ten eleven twelve"+=Nm+d"teen"y"thir four fif six seven eigh nine"sm+dm++d\-kJKy"twenty thirty forty fifty sixty seventy eighty ninety"+=H"one hundred"\.
j", "+"First"+++t=Jy"first second third fourth fifth sixth seventh eighth ninth"y"tenth eleventh twelfth"+m+d"th"Nsm++Pd"ieth"m++d\-kJK+H"th."

6

PHP - 491 byte

Cheat kecil di sini untuk para kardinal (Saya menggunakan kelas NumberFormatter yang menjadi default dengan PHP):

echo'One, ';$x=new NumberFormatter(0,5);for($i=1;$i++<100;)echo$x->format($i).($i>99?
'.':', ');echo"
";$y=[First,second,third,fourth,fifth,sixth,seventh,eighth,ninth,tenth,
eleventh,twelfth,thirteenth,fourteenth,fifteenth,sixteenth,seventeenth,eighteenth,nineteenth,
twentieth];for($z=[thirtieth,fortieth,fiftieth,sixtieth,seventieth,eightieth,ninetieth];
$j++<99;$q=floor($j/10),$w=$z[$q-2])echo$j<21?$y[$j-1]:($j%10?$x->format($q*10).'-'.
strtolower($y[$j%10-1]):$w),', ';echo'one hundredth.';

(menambahkan beberapa baris baru untuk dibaca)


2
Peringatan biasanya diizinkan, hapus semua @(-4 byte). Gunakan baris baru alih-alih menulis \n(-1 byte). Masukkan definisi $zke inisialisasi forloop kedua (-1 byte).
Blackhole

Simpan 6 byte dengan menggunakan metode prosedural alih-alih konstruktor berorientasi objek
rink.attendant.6

6

PHP 5.3+, 195 byte

Itu termasuk karakter baris baru.

Itu bagian dari NumberFormatterkelas, sama seperti jawaban razvan . Kecuali saya menjabarkan kardinal dan ordinal menurut ICU.

$f=numfmt_create(en,5);$g=clone$f;$g->setTextAttribute(6,'%spellout-ordinal');for($x=$y='',$i=1;$i++<100;){$x.=$f->format($i).($z=$i<=99?', ':'');$y.=$g->format($i).$z;}echo"One, $x.
First, $y.";

Terkait: https://stackoverflow.com/a/19411974/404623


Bagus! Saya tidak tahu format% ejaan-ordinal.
Razvan

4

Oracle SQL 231 byte

SqlFiddleLiveDemo

 SELECT 'O'||SUBSTR(LISTAGG(TO_CHAR(TO_DATE(level,'j'),'jsp'),', ')WITHIN GROUP(ORDER BY level),2)||'.','F'||SUBSTR(LISTAGG(TO_CHAR(TO_DATE(level,'j'),'jTHSP'),', ')WITHIN GROUP(ORDER BY level),2)||'.' FROM DUAL CONNECT BY level<101

3

JavaScript ES6, 562 464 byte

Bahkan belum bermain golf!

n=>(f=(a,b)=>Array(89).fill(a=btoa(a+`·§·,í*íË7躻rÍø·,ìrÎǯz{rÍè Ü³)Þ·,ó`).split`z`).map((l,i)=>i<1?b:i<20?a[i]:a[18+(i-i%10)/10]+'-'+a[i%10]).join`, `+', one hundred')(`¢w³·
3¶Þ{7躼ß÷³²,s±ëÞ7¢s)ÞÎקÍé^½éó·¥½ìí*íyéó~«µç§Íøµç§Îȱµç§Îǯz{^z|Þmyéó)Þµç§ÎÜܳ¶«·,ߢêíË7â~ܳ²,mË;½éíË7¢rÎx§µì³`,'One')+`
`+f(`~*ì·;rÝÎØb­Üߢêí7â~Øs²,m;½éí7¢Øs)Þ¶íz{aÍé^½éí;pz[Þ¶í*íyéí7躻^z{aÍøµç§¶ì^z{aÎǯz{^z{aÍè ×Øs)޵秶ó`,'First')+'th'

Jika ini tidak berhasil, saya mungkin perlu menambahkan hexdump karena semua karakter khusus. Tolong beri tahu saya jika ini masalahnya dan saya akan menghubungi Anda besok.

Jika ada kesalahan ketik, beri tahu saya.

Kode dalam pastebin (Diuji di Safari Nightly)

Penjelasan

Ini mungkin terlihat seperti sekelompok karakter yang kacau, tetapi sebenarnya cukup sederhana.

Kami mulai dengan menghasilkan kardinal. Array ini dikompres menggunakan btoafungsi.

['one', ..., 'eighteen', 'nineteen', 'twenty', 'thirty', ...,'ninety']

Untuk mengulang "rentang" kami menggunakan yang berikut:

Sekarang kita menghasilkan Array dengan panjang 89 yang digunakan. Inilah ...yang membuka kompresi array

Array(89).fill(...)

Kemudian memetakannya, saya adalah indeks:

.map((l,i)=>

Sekarang untuk kondisinya, i < 1atau jika itu adalah item pertama, kami akan menggunakan versi kapital dari satu / pertama

i<1?b

Kalau tidak ... jika kurang dari 20, kami output sebelas ... sembilan belas

i<20?a[i]:

Kalau tidak ... menggunakan (i-i%10)/10kita mendapatkan digit terakhir dari nomor tersebut. Kami menambahkan 18 untuk mengkompensasi 1..19. Kami menambahkan -dan kemudian menambahkan digit terakhir, atau i% 10

Akhirnya, kami menambahkan 'seratus' sampai akhir karena kami tidak.

Kami mengulangi ini untuk kedua jenis angka dan berpisah dengan baris baru


Mencoba dengan FireFox: kode yang diposting cacat. Kode dalam pastebin ok, tetapi melewatkan periode setelah yang pertama hundred. Keseluruhan: pekerjaan bagus | +1
edc65

Ada apa dengan karakter khusus?
Luminous

3

C ++ 704 642 620 602

Tidak ada penggunaan perpustakaan selain ostream operator<<()untuk char*s.

#include<iostream>
char*q,a[]="|one|two|three|four|five|six|seven|eight|ni&u$Il%*twel&bthirte$Q(P#tif#j)/#k'L#|)y#r*4#s'9rst&>cond*5d)zh)gh)U#V)Ch)2h(}#V09$m0M$I0]'g0k)B0|*I#}1A+4$01f+y1u$$|+/nty+(y*`#X*3y)p#V)Ly))y(dyC5~hundred)Oie1o#|1c#}*E#s*a#t*}$&+9#|+T#|+uth",b[448],*s=a,*t=b;int i,j,k;auto p(int k){for(s=b;k--;)while(*s++);return s;}int main(){for(;k=*s++;)if(k>98)*t++=k<'|'?k:" "[k<'~'];else for(i=(k-35)*95+*s++-32,q=t-i/9,k=3+i%9;k--;)*t++=*q++;for(j=0;j<2;++j)for(i=1;b[1+126*j]^=32*(i<3),k=i<20?i:i%10,i<101;++i)std::cout<<p(40+!k*j*11+i/10)<<"-"[!k|i<20]<<p(j*20+k)<<", \0.\n"+i/100*3;}

Versi langsung .

Dengan spasi putih dan beberapa komentar:

#include <iostream>

// Encoded as literal characters or offset/length pairs for previous runs of characters, LZ like
char *q, a[] =
             "|one|two|three|four|five|six|seven|eight|ni&u$Il%*twel&bthirte$Q(P#tif#j)/"
             "#k'L#|)y#r*4#s'9rst&>cond*5d)zh)gh)U#V)Ch)2h(}#V09$m0M$I0]'g0k)B0|*I#}1A+4$01f+y1u$$|"
             "+/nty+(y*`#X*3y)p#V)Ly))y(dyC5~hundred)Oie1o#|1c#}*E#s*a#t*}$&+9#|+T#|+uth",
         b[448], *s = a, *t = b;

int i, j, k;

// Find the kth null separated string in array b
auto p(int k) {
    for (s = b; k--;)
        while (*s++)
            ;
    return s;
}

int main() {
    // Decode the compressed 'primitives' we use to build up the output.
    for (; k = *s++;)
        if (k > 98)
            *t++ = k < '|' ? k : " "[k < '~'];
        else
            for (i = (k - 35) * 95 + *s++ - 32, q = t - i / 9, k = 3 + i % 9; k--;) *t++ = *q++;

    // Loop twice over numbers 1-100, building up output from the 'primitives' in our array
    for (j = 0; j < 2; ++j)
        for (i = 1; b[1 + 126 * j] ^= 32 * (i < 3), k = i < 20 ? i : i % 10, i < 101; ++i)
            std::cout << p(40 + !k * j * 11 + i / 10) << "-"[!k | i < 20] << p(j * 20 + k)
                      << ", \0.\n" + i / 100 * 3;
}

String yang dikompresi diterjemahkan dari amenjadi b:

|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|thirteen|fourteen|fifteen|
sixteen|seventeen|eighteen|nineteen||first|second|third|fourth|fifth|sixth|seventh|eighth|
ninth|tenth|eleventh|twelfth|thirteenth|fourteenth|fifteenth|sixteenth|seventeenth|
eighteenth|nineteenth|||twenty|thirty|forty|fifty|sixty|seventy|eighty|ninety|one~
hundred|||twentieth|thirtieth|fourtieth|fiftieth|sixtieth|seventieth|eightieth|
ninetieth|one~hundredth;

Tanpa baris baru. Selama dekompresi, |s diganti dengan '\0'dan ~s diganti dengan ' '(kekhasan cara karakter dikodekan ke dalam ASCII yang dapat dicetak). String 'primitif' ini kemudian dilihat oleh indeks dalam barray menggunakan pfungsi dan digunakan untuk merakit output.

Kompresi adalah skema mirip LZ sederhana di mana karakter dikodekan sebagai literal atau sebagai offset negatif ke buffer dan panjang run (dikodekan menjadi dua karakter) jika ditemukan kecocokan panjang> = 3. String dapat dikompresi lebih lanjut menggunakan karakter yang tidak dapat dicetak tetapi saya suka kode saya untuk disalin dan ditempelkan dengan aman :)


1

Javascript (ES6), 713

Mirip dengan pengajuan PHP kedua saya pada pertanyaan ini . (2444 - 713) / 2444 = 70,8% kompresi.

a=`Onez]cu^dP~Ntenz\`zHlvezmwgwjwkw{wqwpwHnQxZx]xcxux^xdxPx~xNmQXZX]XcXuX^XdXPX~XNforQbZb]bcbub^bdbPb~bNjQWZW]WcWuW^WdWPW~WNkQVZV]VcVuV^VdVPV~VN{QUZU]UcUuU^UdUPU~UNqQTZT]TcTuT^TdTPT~TNpQSZS]ScSuS^SdSPS~SNy.
FirstzaRMLKJI[ten}\`}Hlf}mGgGjGkG{GqGpGHnYx_xaxRxMxLxKxJxIx[mYX_XaXRXMXLXKXJXIX[forYb_babRbMbLbKbJbIb[jYW_WaWRWMWLWKWJWIW[kYV_VaVRVMVLVKVJVIV[{YU_UaURUMULUKUJUIU[qYT_TaTRTMTLTKTJTIT[pYS_SaSRSMSLSKSJSIS[yth.`,'eleven|`}|`z|twe|q}|{}|k}|j}|g}|pz|{z|kz|gz|one hundred|tyz|mdz|qtz|p~|q~|{~|k~|j~|m~|tie}|onez|nin}|twoz|fivez|firstz|teen|threez|secondz|for~|four|fif|twen~|six|thir|nine|eigh|, |seven|th, |ty-'.split('|').map((e,i)=>a=a.split('`GwHIJKLMNPduyQR~STUVWXYZ[]^_`cabgjxkmpqz{}~'[i]).join(e)),alert(a)

Biola


Mengapa ini diturunkan?
DankMemes

1

Mathematica 415 391 407

Para kardinal diberikan oleh IntegerName[n]. Ordo ordinal berasal dari para kardinal.

s = StringRiffle; y = IntegerName; t = StringReplace;
k@n_ := If[(z = (TextWords["first second third a fifth a a a ninth,a, a twelfth a a a a a eighteenth a, twentieth"])[[n]]) == "a", y@n <> "th", z]
g@n_ := Module[{i = IntegerDigits[n], z}, z := y[Quotient[n, 10]*10];Which[n == 100, "one hundredth", n < 20, k[n], i[[-1]] == 0, t[z, "y" -> "ieth"], 3 > 2, z <> "-" <> k[i[[-1]]]]]
t[(s[y@Range@100 /. "one" -> "One", ", "] <> ".") <> s[g /@ Range@100 /. "first" -> "\nFirst", ", "] <> ".", "tt" -> "t"]

Keluaran:

One, two, three, four, five, six, seven, eight, nine, ten, eleven, twelve, thirteen, fourteen, fifteen, sixteen, seventeen, eighteen, nineteen, twenty, twenty-one, twenty-two, twenty-three, twenty-four, twenty-five, twenty-six, twenty-seven, twenty-eight, twenty-nine, thirty, thirty-one, thirty-two, thirty-three, thirty-four, thirty-five, thirty-six, thirty-seven, thirty-eight, thirty-nine, forty, forty-one, forty-two, forty-three, forty-four, forty-five, forty-six, forty-seven, forty-eight, forty-nine, fifty, fifty-one, fifty-two, fifty-three, fifty-four, fifty-five, fifty-six, fifty-seven, fifty-eight, fifty-nine, sixty, sixty-one, sixty-two, sixty-three, sixty-four, sixty-five, sixty-six, sixty-seven, sixty-eight, sixty-nine, seventy, seventy-one, seventy-two, seventy-three, seventy-four, seventy-five, seventy-six, seventy-seven, seventy-eight, seventy-nine, eighty, eighty-one, eighty-two, eighty-three, eighty-four, eighty-five, eighty-six, eighty-seven, eighty-eight, eighty-nine, ninety, ninety-one, ninety-two, ninety-three, ninety-four, ninety-five, ninety-six, ninety-seven, ninety-eight, ninety-nine, one hundred.
First, second, third, fourth, fifth, sixth, seventh, eighth, ninth, tenth, eleventh, twelfth, thirteenth, fourteenth, fifteenth, sixteenth, seventeenth, eighteenth, nineteenth, twentieth, twenty-first, twenty-second, twenty-third, twenty-fourth, twenty-fifth, twenty-sixth, twenty-seventh, twenty-eighth, twenty-ninth, thirtieth, thirty-first, thirty-second, thirty-third, thirty-fourth, thirty-fifth, thirty-sixth, thirty-seventh, thirty-eighth, thirty-ninth, fortieth, forty-first, forty-second, forty-third, forty-fourth, forty-fifth, forty-sixth, forty-seventh, forty-eighth, forty-ninth, fiftieth, fifty-first, fifty-second, fifty-third, fifty-fourth, fifty-fifth, fifty-sixth, fifty-seventh, fifty-eighth, fifty-ninth, sixtieth, sixty-first, sixty-second, sixty-third, sixty-fourth, sixty-fifth, sixty-sixth, sixty-seventh, sixty-eighth, sixty-ninth, seventieth, seventy-first, seventy-second, seventy-third, seventy-fourth, seventy-fifth, seventy-sixth, seventy-seventh, seventy-eighth, seventy-ninth, eightieth, eighty-first, eighty-second, eighty-third, eighty-fourth, eighty-fifth, eighty-sixth, eighty-seventh, eighty-eighth, eighty-ninth, ninetieth, ninety-first, ninety-second, ninety-third, ninety-fourth, ninety-fifth, ninety-sixth, ninety-seventh, ninety-eighth, ninety-ninth, one hundredth.

1
Beberapa tidak benareightth
Mario Trucco

Kamu benar! Saya sekarang mengoreksi mereka.
DavidC

Anda dapat mengubah "first" -> "\nFirst"ke "fir" -> "\nFir"untuk menyimpan 4 byte.
LegionMammal978

@ LegionMamal978, Saran yang bagus tetapi tidak akan berfungsi karena kami mengganti elemen (kata) dalam daftar: "pertama" adalah elemen dalam daftar, tetapi "fir" tidak. Jika kami mencoba menerapkan saran Anda setelah daftar elemen StringJoindisunting, maka "dua puluh satu ... tiga puluh satu ..." akan menjadi "dua puluh satu ... tiga puluh pertama ...".
DavidC

1

JavaScript (ES6), 480

/*TEST: redirect console output to snippet body */ console.log=x=>O.innerHTML=x

// Not a function, as a complete program is requested
b=x=>btoa(x).split`/`;
Z=i=>z[i]||z[i-8]||z[i-18];
y=b("ýø«²ßìyÊ'wûa·ýøÿÿÞ)ÿÿûpzWÿÿÿÿÿÿÿ");
z=b("þÞþÜ(þØkyïߢêÿ~+ÞþȱþǯzÞmþx§{û^÷¥z÷§þÜ÷¿¶«ÿ÷âÿÿz(!ÿûpzÿ~ÿÿÿÿ");
o=(z.map((v,i)=>i<20?i<13?v:(v||z[i-10])+'teen':z[S='slice'](0,10).map(d=>Z(i)+(d?'ty-'+d:'ty')))+`,${h='one hundred'}.\nF`).split`,`;
q=y.map((v,i)=>i<4?v:`${v||o[i]}th`);
q=z.map((v,i)=>i<20?' '+q[i]:q[S](0,10).map(d=>' '+Z(i)+(d?'ty-'+d:'tieth')));
console.log('O'+o.join`, `[S](3)+`${q}, ${h}th.`[S](4))

// INFO: z uncompressed is [,one,two,three,four,five,six,seven,eight,nine,ten,eleven,twelve,thir,,fif,,,eigh,,twen,,for,,,,,]
// INCO: y uncompressed is [,first,second,third,,fif,,,eigh,nin,,,twelf,,,,,,,,,]
#O { white-space: pre-wrap }
<pre id=O></pre>


0

PHP - 842 byte

Menghilangkan tag awal dan akhir PHP biasa, kompresi adalah 1 - 842/2445 = 65,6%

Pada dasarnya mendapatkan output base64_encode(gzdeflate($input, 9));dan membalikkan operasi. Jelas, jika saya memilih untuk menghasilkan murni 8-bit vs basis-64, itu akan menjadi 25% lebih kecil, tetapi dengan risiko berlari ke melarikan diri atau karakter yang tidak dapat dicetak.

echo gzinflate(base64_decode('VZRdcuIwEITfcwoOQHKMfd1DBGnlKspUEYfEt1+rf2bGL6gbkLplS9/ftV0v28/j+BjPduj++H4en8vr0F/L7/HRXm29Xtryb2zXy7pgAr6585ftp93nv7exPLc2v5lrSC2d4lhKYk6ixJJQc1WqY7F12z2+P1gPmi2lWVaOnW1QXQY7sI6602k/ctrW3MHuUeHUekTUCqdTuMzyyl8YLq1wOofTMbw/kI2B0ZRIlvQrylxpxFIjVZKhNMqkUeTxdnYNioRkJKUiYXw2ekZCM5JSkTCOhGHkPAe7BkZSIlKSkTSMlPahdKQkI2kUSaNInLg9hGJlGGyjaFmF2zFeLu9GqSDrErKsgS93jywhjQ7WrCDHBjYoIIN863JFI12O4bhgu0eGSyPcmuFyDLdBuAzCrRkuVzAR4UfaZXyvt2e7fbz9WZ5feDafj/XGK3ATMQaPyuDrG36AQ3sZWHYOm769+/eJIEw0g7CWKOR1JUWiXL+VDGnzSGuv29JCzkeBLQRWtBOTCRsqZDrN7MVplxVPxXvPSajYoNoYOWxjzuRzLW0SVaeZvTi3KbwqPtoEsviIXcYcQhfTh1XMLr3oWsSzehrVKABL6xLBML9adRCY2EE4UgfBjB0CZnVWT+MOSbS00cFQ85liB5OKh1x8YgfTDR2SbnVWT+MrkIhL6w5BuTzMahHI0mV7nY5q4o5dCu7Os3u1p0tZO1XqjRP24l6xVnAMrQJeLBX8Q6fCv9PMXpwKVQgW7zrJwbjZbBNgQ5ugGdsEENGmAPE0sxenNpWKxReCtWxTyLiNj7f/'));
Dengan menggunakan situs kami, Anda mengakui telah membaca dan memahami Kebijakan Cookie dan Kebijakan Privasi kami.
Licensed under cc by-sa 3.0 with attribution required.