Fakta Kalender XKCD


17

Inspirasi . Diposting dengan izin .

Cetak salah satu "fakta" kalender XKCD yang mungkin:

Fakta Kalender XKCD

Anda bisa mendapatkan teks dan struktur mentah dari implementasi referensi APL saya atau dari Jelaskan transkrip XKCD (termasuk teks judul tepat di bawah ilustrasi).

Aturan

Pada setiap simpul keputusan, harus ada kesempatan acak yang sama (pseudo-) dari setiap pilihan.

Anda dapat menggunakan semua huruf besar.

Anda harus menghasilkan tiga kalimat; pertanyaan, alasan, dan teks judul.

Tiga kalimat harus diakhiri dengan ?, ., dan .masing-masing, dan terpisah satu sama lain oleh satu ruang.

Satu-satunya ruang putih tambahan yang dapat Anda sertakan adalah satu spasi tambahan dan / atau pemisah baris.

Contohnya

Did you know that the Latest Sunset drifts out of sync with the Zodiac because of time zone legislation in Indiana? Apparently it's getting worse and no one knows why. While it may seem like trivia, it has to be corrected for by GPS satellites.

Did you know that Leap Year happens later every year because of precession of the equator? Apparently scientists are really worried. While it may seem like trivia, it is taken advantage of by high-speed traders.

Did you know that Easter drifts out of sync with the atomic clock in Colorado because of a decree by the pope in the 1500s? Apparently scientists are really worried. While it may seem like trivia, it causes huge headaches for software developers.


@Rod aku tidak pernah mengatakan apa pun tentang bagan. Saya mengatakan untuk mendapatkan teks dari implementasi referensi saya (yang memasukkannya) atau dari Jelaskan XKCD (dengan catatan untuk memasukkan teks judul).
Adám

Apakah memimpin spasi dalam output diperbolehkan?
Erik the Outgolfer

@EriktheOutgolfer No.
Adám


Did you know that shark week happens at the wrong time every year because of an arbitrary decision by Benjamin Franklin? Apparently it causes a predictable increase in car accidents.Aku ... maksudku ... aku ... Oke.
Magic Gurita Guci

Jawaban:


7

Befunge-93, 1959 1930 byte

"#~$}%|&{'zwy#x$-#w$v%u&tTs*-#r$q%p&oTn0m1l2kpj#-#i$h%gFf(e)-#d#c$bC-'a(`)_*E+"v
v"#*_?F@%A$B#C3DYE,F+G*-TH&I%J$K#L$M#-'NCO$P#Q#RjSFT%U$V#-<W;-cX(Y'Z&[%\$]#^cF"<
>">$=%<#;$:%9F$*8+-#7$6C5/4#3$-C23-#1$0C*#/$.C$:-#,$+C*#)$(C$A'#&$%C$J#"75*-0\:v
$::"P"vv-*84:-*57$$_1-\1+::"P"%\v>+>\1-:v>-#1:#$>#\_:$#<$:#v_".",@v/"P"\%"P"::\_
>\#%4#<3g/7+g"!"-:!^!:\,g+7/"P"<<^1?<*2\_$\%1++64*g48*-^<<<>75*-0v>7+g84*-+\1-:^
#<<<*2\>#$$:0\`#$_\$55++:64*g48*-90^https://xkcd.com/1930/^<<<<<<>#\\:#< >#<>#<^

3Did you know that %the %fall'spring) equinox'winter'summer" )solstice)Olympics!
)earliest'latest(sunrise'sunset0daylight saving"s& time&leap $day%year'Easter(ha
rvest&super&blood& moon3Toyota Truck Month+Shark Week)happens (earlier&later2at
the wrong time, every year=drifts out of sync with the $sun%moon'zodiac*Gregoria
n&Mayan&lunar'iPhone* calendar9atomic clock in Colorado'might +not happen-happen
 twice+ this year- because of :time zone legislation in (Indiana(Arizona'RussiaB
a decree by the Pope in the 1500s+precession*libration)nutation)libation-eccentr
icity*obliquity) of the -earth's axis(equator/Prime Meridian3International Date,
Mason-Dixon& Line8magnetic field reversal:an arbitrary decision by 2Benjamin Fra
nklin-Isaac Newton$FDR.? Apparently Rit causes a predictable increase in car acc
idents@that's why we have leap seconds>scientists are really worriedEit was even
 more extreme during the +Bronze Age(Ice Age+Cretacious&1990sFthere's a proposal
 to fix it, but it 2will never happen;actually make things worse7is stalled in C
ongress:might be unconstitutionalHit's getting worse and no one knows whyE. Whil
e it may seem like trivia, it Ncauses huge headaches for software developersLis
taken advantage of by high-speed tradersFtriggered the 2003 Northeast BlackoutJh
as to be corrected for by GPS satellitesRis now recognized as a major cause of W
orld War I" "# "$) (6DLTV`b$ "$&% "$&2# *B& "$&(*% *,PR& "$&2>% "$&(

Cobalah online!

Penjelasan

Dalam tiga baris pertama, kita mulai dengan membangun semacam tabel negara pada tumpukan, yang mewakili grafik dari semua kalimat yang mungkin. Entri tumpukan ini dikelompokkan menjadi pasangan, jadi pertama-tama ada item string, dan kemudian lompatan atau cabang. Bila perlu, grafik diisi dengan string kosong dan lompatan panjang nol untuk memenuhi persyaratan ini.

Loop utama kami kemudian dimulai dengan memunculkan angka, mewakili item string, dari tumpukan. Angka ini ditafsirkan sebagai offset ke tabel string di bagian bawah sumber. Tabel string pada dasarnya adalah sejenis daftar tertaut, yang dibungkus beberapa baris agar sesuai dengan ruang memori Befunge yang terbatas.

Setelah mengeluarkan string, item berikutnya pada stack adalah lompatan atau cabang. Jika jumlahnya kurang dari 32, itu adalah lompatan, yang kami interpretasikan dengan menjatuhkan banyak pasangan item dari tumpukan. Jika angkanya 32 atau lebih, itu adalah cabang, dan kami menggunakan nilai (minus 32) untuk mencari detail cabang dari tabel di baris terakhir sumber.

Entri dalam tabel cabang masing-masing terdiri dari hitungan, diikuti oleh daftar offset. Setelah kita tahu cabang mana yang akan digunakan, kita cukup menghasilkan angka acak, memodulasi jumlah cabang, untuk mencari offset yang sesuai. Offset ini kemudian diartikan sebagai lompatan, menjatuhkan jumlah item yang diperlukan dari tumpukan.

Kami ulangi proses ini, mengeluarkan string, lalu melakukan lompatan atau cabang, hingga kami kehabisan entri tumpukan. Pada titik itu, kita cukup mengeluarkan "." untuk menandai akhir kalimat terakhir, dan kemudian keluar.


2
Apa yang dilakukan URL di sana?
Adám

3
@ Adám Saya punya sedikit ruang di tengah baris dan berpikir itu akan menjadi cara yang rapi untuk memuji komik aslinya. Hitungan byte juga jenis referensi komik, tapi itu sepenuhnya kebetulan.
James Holderness

Ini sangat cepat ...
Erik the Outgolfer

5

Javascript (ES6), 1698 1510 1506 1501 byte

Terima kasih kepada 12Me21 untuk memperbaiki bug dalam kode, yang menambahkan 2 byte

f=dan document.write(f())bukan bagian dari jumlah byte

f=_=>eval(`"Did you know that {the {Fall;Spring} Equinox;the {Wint;Summ}er {Solstice;Olympics};the {Earli;Lat}est Sun{rise;set};Daylight Saving{;s} Time;Leap {Day;Year};Easter;the {Harvest;Super;Blood} Moon;Toyota Truck Month;Shark Week} {happens {earlier;later;at the wrong time} every year;drifts out of sync with the {Sun;Moon;Zodiac;{Gregorian;Mayan;Lunar;iPhone} Calendar;atomic clock in Colorado};might {not happen;happen twice} this year} because of {time zone legislation in {Indian;Arizon;Russi}a;a decree by the pope in the 1500s;{{precession;eccentricity;obliquity};{lib;liber;nut}ation} of the {Moon;Sun;Earth's axis;equator;prime meridian;{international date;mason-dixon} line};magnetic field reversal;an arbitrary decision by {Benjamin Franklin;Isaac Newton;FDR}}? Apparently {it causes a predictable increase in car accidents;that's why we have leap seconds;scientists are really worried;it was even more extreme during the {{Bronz;Ic}e Age;{Cretaceou;1990}s};there's a proposal to fix it, but it {will never happen;actually makes things worse;is stalled in congress;might be unconstitutional};it's getting worse and no one knows why}. While it may seem like trivia, it {causes huge headaches for software developers;is taken advantage of by high-speed traders;triggered the 2003 Northeast Blackout;has to be corrected for by GPS satellites;is now recognized as a major cause of World War I}."`.split`{`.join`"+(a=>a[Math.random()*a.length|0])(["`.split`}`.join`"])+"`.split`;`.join`","`)
document.write(f())


4

Python 2 , 1297 byte

-419 byte berkat ovs.

exec'eJxNVcGO3DYMvecriLk4m2yCSYseUqAomgYpcgkW7WHPtMSxmZElR5Jnxvv1fZQns3sybZHi4+MjfchposzR46HTnHJ988r9EXjqPb/h392Y1Mlrvns1Z421+6ye1rTQMaYz1ZErdW/d666OshkHDqG774p5D93d247kx6IxXfDx5nTGTZLNbZkmGObWDkoKpSIfjlJYp1ld6e5eBArnoFIqzgNXM55Dl5i1SLs0FqkW53kNOoyVCp8MjvmZQ4uqOpl3EJ63G+CN9xU5LFa4bBhvyUfOpy13WeZ21IeUfLtsSimab1pTZap5cUd8i3U0bwQe6SxyfEY78jxLLC+rytei7AlaLe05pzhsQBuTJ8krNYCoLeuhFkpLpXSgskZHZ60j3eCCBrhdgT0lr+y6e3wfsgwpK7dTXtszLLFdqg9jilsyx0Gi5w1NmtSRCwlVaSSXQsrsk9E0NX5bwpgqbXUhZjOonq2bje5Ry4bd3npxvBQx6Jt+UCM9ITcFGbSAB03RcrVTjUAf2aBkhZdZeSlF2SAweXFZhPq1Vf+QZrFQsz/8tt+XVvacxQlCGh1B+5YBZlzqT/PFV3FOYs3qtJooUh8UMoZt4AH6xvKV30b2DtWh44X4omWHS34soM4YxDSgPkhdfSO+1YRWx5aPA3k0vvWjpPjO6wWXWqag1g37PkTBYNBBJXjKpoTCNmgciXOvNTOkAR7UKjQmGrpPEr/zBC6+YMKPuA0RXwuzo29yrg35l8//dnfI9Sf9Nc+cUXW4Bmul1iTUQ2DPq6vcB6MWbHNpHDvOxM6pRxx43tlGAAHncYXgoYaTNRQDVsSl6I2U4hS+WqBdZEMpWBhwTjmreJNgpTMX03rEBMFDLjUL2POLrZRn5nsMx5MQD0YcVHa1gK2y07QATvfh48e9bRDgkizdVkmaE7ijmsDmhbTeU48hQt7dtptCoGgEP4uZXV0azImPYkqOQzHIbd1A1qXiVLwR8jcmNkNn3c/R6IWWiOKx1+qyddsAqdE0SK1WU7uKsIMpJrIhsO3aWNyhM+/pcVTjvSL/CiplgjAMSNaT8r0dNEau3RqXAdQLe3YjXg8pU0mHeja6PQoLmI9cNuQVBUFB/sSxgj+TNrQzAvm7MgtKgrD85o1swwAWfWvBL/v9r/QNf4vRFiV9CuyO2EVt8otxi7odmiquIsIw4N5/Hv7DKq4SgmJ5bwjsPwKvNER9gidbjyb+joDbhnhMGaJ/hNS+2lS87/4H4KM8AA=='.decode('base64').decode('zip')

Cobalah online!

Kode aktual:

from random import*
c=lambda*a:choice(a)
print'Did you know that '+c('the '+c('fall','spring')+' equinox','the '+c('winter','summer')+' '+c('solstice','olympics'),'the '+c('earliest','latest')+' '+c('sunrise','sunset'),'daylight saving'+c('','s')+' time','leap '+c('day','year'),'easter','the '+c('harvest','super','blood')+' moon','toyota truck month','shark week')+' '+c('happens '+c('earlier','later','at the wrong time')+' every year','drifts out of sync with the '+c('sun','moon','zodiac',c('gregorian','mayan','lunar','iPhone')+' calendar','atomic clock in colorado'),'might '+c('not happen','happen twice')+' this year')+' because of '+c('time zone legislation in '+c('indiana','arizona','russia'),'a decree by the Pope in the 1500s',c('precession','libation','nutation','libation','eccentricity','obliquity')+' of the '+c('moon','sun',"earth's axis",'equator','prime meridian',c('international date','mason-dixon')+' line'),'magnetic field reversal','an arbitrary decision by '+c('Benjamin Franklin','Isaac Newton','FDR'))+'? Apparently '+c('it causes a predictable increase in car accidents',"that's why we have leap seconds",'scientists are really worried','it was even more extreme during the '+c('bronze age','ice age','cretacious','1990s'),"there's a proposal to fix it, but it "+c('will never happen','actually make things worse','is stalled in Congress','might be unconstitutional'),"it's getting worse and no one knows why")+'. While it may seem like trivia, it '+c('causes huge headaches for software developers','is taken advantage of by high-speed traders','triggered the 2003 Northeast Blackout','has to be corrected for by GPS satellites','is now recognized as a major cause of World War I')+'.'

Itu melelahkan. Saya bahkan belum melakukan golf dasar. Seseorang tolong tuliskan skrip untuk golf ini.


Saya pikir ini gagal spesifikasi dari kesempatan pseudo-acak yang sama di setiap simpul keputusan di simpul kalender Gregorian / Maya / Lunar / iPhone. Anda memiliki fungsi pilihan untuk keempat jenis kalender yang tertanam dalam pilihan lain. Ini berarti bahwa "kalender Gregorian" akan seperempat dari "jam atom di Colorado".
Sellyme

3
Saya pikir itu adalah simpul keputusan yang terpisah. "Hanyut tidak sinkron dengan" terhubung ke "Sun" "Moon" "Zodiac" "_ Kalender" dan "Jam atom di Colorado", dan pilihan antara "Gregorian" "Maya" "Lunar" dan "iPhone" hanya dilakukan jika cabang "Kalender" dipilih. EDIT: Juga, implementasi referensi memiliki perilaku yang sama.
12Me21

Ya, setiap node terbagi rata, tidak peduli berapa banyak sub-node yang dimilikinya.
Adám

Sepertinya Anda mendapat 'libation' dua kali - salah satunya harus 'libration'. Setidaknya dalam kode yang tidak terkompresi - tidak yakin apakah versi yang dikompres adalah sama.
James Holderness

3

Arang , 806 byte

≔”}‽÷⌊&β¶&⁰5EYB∕¤ⅉ‖≧I2[y·↔m⁷b∕¶⎆w‹ta≔Þ…¤eN⌕⟦1H}⁷φb$≧xζ→j5⮌↗2Σ↶C$JiψT↧⊘ν;{Fκⅉ⊘V⁵)}LZ)←‴F9cCIj+FJ➙N¶℅Pφ⦄≧πΦjt/;⊗…→⎇↓y⁻OD¤HRw2◧eE≦⊗▶⁴Uμ4⁶⊟P}⁼Ruf→u≧″℅9ξ→W⊗7≧↨↥ω⎚,_-,*U∕$⊖τJb4%L'⪪*⎇⊕>Þ↨IQ.&XVSv⧴×↑N:εγC~f≔hI¶⊖⎇N6ydy"⁸?⁷∕Oυ⁻~Þ⁶πv″ZOgΦ✂⊘qV↓Y5U,fν¶⁼⟲Y⁺⪪“↓‹5Hψ.>⊕LS⁸◨›±3¤�[<⊟D´YυΣOR↓↓g⟧⎈″:;9≧¿×➙ρlZσ31‴8↖HXυ3@⁺�@δIΣ≔⁺@ⅉCX⎇",H²⁻↥uνu⎚⌊ÀW⊘∕U ψu]q➙⟲BoF⧴Qψ8)Zk⌕⊗ü;≡N±$⊞QU≕⁹↘NYFY?⊗↖\≦∧₂!Fd⌈B"η№⁻⎈O2jηQμfÞωσdJ↧Àκ«ⅈ∕+¤êE�№F´⟲τ₂Gξr1⦃:>Oa²O[)¬X⎚∧V⊖«⪫J⁼0✂⦄Blν≦&C₂?⁹κIWÞ⁶≕>u/EKπd4ζ¤h]≕D@;VWR$▷ω≔BU″″◧⁸|%↔φ;Φ?@R:↙!,⧴¹3H%⁸⧴↨⁵&⁼E¶N V⬤⌊←}⁸⁺aw⌈Vς2A§A⟦W3«;{aZKl⊞Lξd⌊2≦2?⎈OM↔ü?⎚_Q▶δMp>{✂Mx§+↔⎆}Cκ·W∧Sd⎇⁹_ςCüI.G↓x≕χ«]n⦄&➙{‽ι⦃⁺^⦃Jk⎈O+oκs◧¿#W↙QR[Lα±´@⁰¶◧⊗βυ⊕⁴…«✳τi"TWι&=l¦⦄Þ⪪Þ▷‴υγ±A↥2⭆⁴≕↖≔…L¦ê⊘↥Bwψ¦⊘⊕*YkxAyg-'≦sΦd4◨υÀ?⁶[)…WS×∧ηt\e↗⊕Xκ≕№q₂‽Az←ERT◨⟦◨<1↧Φ…⊗E›c*«R↥M6-±⌀↑F⟲#π'F5/±κ;↗~&ζTUI⁺U⦃⸿?^↙i⧴t”θFβ≔⁺⁺§⪪θι⁰‽✂⪪θι¹±¹¦¹⊟⪪θιθθ

Cobalah online! Tautan adalah untuk mengucapkan versi kode. Penjelasan:

 ”....”                             Compressed string
≔      θ                            Assign to `q`
         β                          Lowercase letters
        F                           Loop over each letter
              ⪪θι   ⪪θι      ⪪θι    Split `q` at that letter
             §   ⁰                  First string in split (i.e. prefix)
                   ✂   ¹±¹¦¹        Slice split excluding prefix and suffix
                  ‽                 Select random element
                            ⊟       Pop last string (i.e. suffix)
           ⁺⁺                       Concatenate
          ≔                     θ   Assign to `q`
                                 θ  Print `q`

3

R , 1903 1751 1743 byte

Solusi brute force sederhana. Mungkin ada cara untuk menurunkannya lagi.

p=paste
P=paste0
s=function(...)sample(c(...),1)
C='calendar'
T='the'
P(p('Did you know that',s(p(T,s('Fall','Spring'),'Equinox'),p(T,s('Winter','Summer'),s('Solstice','Olympics')),p(T,s('Earliest','Latest'),s('Sunrise','Sunset')),P('Daylight Saving',s('s',''),' Time'),p('Leap',s('Day','Year')),'Easter',p(T,s('Harvest','Super','Blood'),'Moon'),'Toyota Truck Month','Shark Week'),s(p('happens',s('earlier','later','at the wrong time'),'every year'),p('drifts out of sync with the',s('Sun','Moon','Zodiac',p('Gregorian',C),p('Mayan',C),p('Lunar',C),p('iPhone'),'atomic clock in Colorado')),p('might',s('not happen','happen twice'),'this year')),'because of',s(p('time zone legislation in',s('Indiana','Arizona','Russia')),'a decree by the pope in the 1500s',p(s('precession','libration','nutation','libation','eccentricity','obliquity'),'of the',s('Moon','Sun',"Earth's axis",'equator','prime meridian','international date line','mason-dixon line')),'magnetic field reversal',p('an arbitrary decision by',s('Benjamin Franklin','Isaac Newton','FDR')))),'? Apparently ',s('it causes a predictable increase in car accidents',"that's why we have leap seconds",'scientists are really worried',p('it was even more extreme during the',s('Bronze Age','Ice Age','Cretaceous','1990s')),p("there's a proposal to fix it, but it",s('will never happen','actually makes things worse','is stalled in congress','might be unconstitutional')),"it's getting worse and no one knows why"),'. While it may seem like trivia, it ',s('causes huge headaches for software developers','is taken advantage of by high-speed traders','triggered the 2003 Northeast Blackout','has to be corrected for by GPS satellites','is now recognized as a major cause of World War I'),'.')

Cobalah online!


2

JavaScript (ES6), 1275 byte

f=(s=btoa`...`)=>/h/.test(s)?f(s.replace(/g([^gi]+)i/,(_,x)=>` ${(x=x.split`h`)[Math.random()*x.length|0]} `)):s.replace(/[a-f]/g,x=>" '-?,."['0x'+x-10]).replace(/ +(\W)/g,'$1')

di mana ...merupakan hasil dari menjalankan atob()string ini dan mengganti \dengan \\, `dengan \`, 0x00 dengan \0, dan 0x0D dengan \r:

DIDaYOUaKNOWaTHATgTHEgFALLhSPRINGiEQUINOXhTHEgWINTERhSUMMERigSOLSTICEhOLYMPICSihTHEgEARLIESThLATESTigSUNRISEhSUNSETihTHEgHARVESThSUPERhBLOODiMOONhDAYLIGHTgSAVINGhSAVINGSiTIMEhLEAPgDAYhYEARihEASTERhTOYOTAaTRUCKaMONTHhSHARKaWEEKigHAPPENSgEARLIERhLATERhATaTHEaWRONGaTIMEiEVERYaYEARhDRIFTSaOUTaOFaSYNCaWITHaTHEgSUNhMOONhZODIAChgGREGORIANhMAYANhLUNARhIPHONEiCALENDARhATOMICaCLOCKaINaCOLORADOihMIGHTgNOTaHAPPENhHAPPENaTWICEiTHISaYEARiBECAUSEaOFgTIMEaZONEaLEGISLATIONaINgINDIANAhARIZONAhRUSSIAihAaDECREEaBYaTHEaPOPEaINaTHEa1500ShgPRECESSIONhLIBRATIONhNUTATIONhLIBRATIONhECCENTRICITYhOBLIQUITYiOFaTHEgSUNhMOONhEARTHbSaAXIShEQUATORhPRIMEaMERIDIANhINTERNATIONALaDATEaLINEhMASONcDIXONaLINEihMAGNETICaFIELDaREVERSALhANaARBITRARYaDECISIONaBYgBENJAMINaFRANKLINhISSACaNEWTONhFDRiidaAPPARENTLYgITaCAUSESaAaPREDICTABLEaINCREASEaINaCARaACCIDENTShTHATbSaWHYaWEaHAVEaLEAPaSECONDShSCIENTISTSaAREaREALLYaWORRIEDhITaWASaEVENaMOREaEXTREMEaDURINGaTHEgBRONZEaAGEhICEaAGEhCRETACEOUSh1990SihTHEREbSaAaPROPOSALaTOaFIXaITeaBUTaITgWILLaNEVERaHAPPENhACTUALLYaMAKESaTHINGSaWORSEhISaSTALLEDaINaCONGRESShMIGHTaBEaUNCONSTITUTIONALihITbSaGETTINGaWORSEaANDaNOaONEaKNOWSaWHYifaWHILEaITaMAYaSEEMaLIKEaTRIVIAeaITgCAUSESaHUGEaHEADACHESaFORaSOFTWAREaDEVELOPERShISaTAKENaADVANTAGEaOFaBYaHIGHcSPEEDaTRADERShTRIGGEREDaTHEa2003aNORTHEASTaBLACKOUThHASaTOaBEaCORRECTEDaFORaBYaGPSaSATELLITEShISaNOWaRECOGNIZEDaASaAaMAJORaCAUSEaOFaWORLDaWARaIif

Coba di sini, minus btoa:

f=(s="DIDaYOUaKNOWaTHATgTHEgFALLhSPRINGiEQUINOXhTHEgWINTERhSUMMERigSOLSTICEhOLYMPICSihTHEgEARLIESThLATESTigSUNRISEhSUNSETihTHEgHARVESThSUPERhBLOODiMOONhDAYLIGHTgSAVINGhSAVINGSiTIMEhLEAPgDAYhYEARihEASTERhTOYOTAaTRUCKaMONTHhSHARKaWEEKigHAPPENSgEARLIERhLATERhATaTHEaWRONGaTIMEiEVERYaYEARhDRIFTSaOUTaOFaSYNCaWITHaTHEgSUNhMOONhZODIAChgGREGORIANhMAYANhLUNARhIPHONEiCALENDARhATOMICaCLOCKaINaCOLORADOihMIGHTgNOTaHAPPENhHAPPENaTWICEiTHISaYEARiBECAUSEaOFgTIMEaZONEaLEGISLATIONaINgINDIANAhARIZONAhRUSSIAihAaDECREEaBYaTHEaPOPEaINaTHEa1500ShgPRECESSIONhLIBRATIONhNUTATIONhLIBRATIONhECCENTRICITYhOBLIQUITYiOFaTHEgSUNhMOONhEARTHbSaAXIShEQUATORhPRIMEaMERIDIANhINTERNATIONALaDATEaLINEhMASONcDIXONaLINEihMAGNETICaFIELDaREVERSALhANaARBITRARYaDECISIONaBYgBENJAMINaFRANKLINhISSACaNEWTONhFDRiidaAPPARENTLYgITaCAUSESaAaPREDICTABLEaINCREASEaINaCARaACCIDENTShTHATbSaWHYaWEaHAVEaLEAPaSECONDShSCIENTISTSaAREaREALLYaWORRIEDhITaWASaEVENaMOREaEXTREMEaDURINGaTHEgBRONZEaAGEhICEaAGEhCRETACEOUSh1990SihTHEREbSaAaPROPOSALaTOaFIXaITeaBUTaITgWILLaNEVERaHAPPENhACTUALLYaMAKESaTHINGSaWORSEhISaSTALLEDaINaCONGRESShMIGHTaBEaUNCONSTITUTIONALihITbSaGETTINGaWORSEaANDaNOaONEaKNOWSaWHYifaWHILEaITaMAYaSEEMaLIKEaTRIVIAeaITgCAUSESaHUGEaHEADACHESaFORaSOFTWAREaDEVELOPERShISaTAKENaADVANTAGEaOFaBYaHIGHcSPEEDaTRADERShTRIGGEREDaTHEa2003aNORTHEASTaBLACKOUThHASaTOaBEaCORRECTEDaFORaBYaGPSaSATELLITEShISaNOWaRECOGNIZEDaASaAaMAJORaCAUSEaOFaWORLDaWARaIif")=>/h/.test(s)?f(s.replace(/g([^gi]+)i/,(_,x)=>` ${(x=x.split`h`)[Math.random()*x.length|0]} `)):s.replace(/[a-f]/g,x=>" '-?,."['0x'+x-10]).replace(/ +(\W)/g,'$1')
document.write(f())


2

APL (Dyalog) , 1302 byte

'[a-z]'R' \u&''⍠[^⍠⌸]*⌸'R{(?∘≢⊃⊢)⍵.Match(∊⊆⊣)⎕AV}⍣≡'DIDyOUkNOWtHAT⍠tHE⍠fALL⌺sPRING⌸eQUINOX⌺tHE⍠wINTE⌺sUMME⌸R⍠sOLSTICE⌺oLYMPICS⌸⌺tHE⍠eARLI⌺lAT⌸ESTsUN⍠RISE⌺SET⌸⌺dAYLIGHTsAVING⍠ ⌺S ⌸TIME⌺lEAP⍠dAY⌺yEAR⌸⌺eASTER⌺tHE⍠hARVEST⌺sUPER⌺bLOOD⌸mOON⌺tOYOTAtRUCKmONTH⌺sHARKwEEK⌸⍠hAPPENS⍠eARLIER⌺lATER⌺aTtHEwRONGtIME⌸eVERYyEAR⌺dRIFTSoUToFsYNCwITHtHE⍠sUN⌺mOON⌺zODIAC⌺⍠gREGORIAN⌺mAYAN⌺lUNAR⌺iPHONE⌸cALENDAR⌺aTOMICcLOCKiNcOLORADO⌸⌺mIGHT⍠nOThAPPEN⌺hAPPENtWICE⌸tHISyEAR⌸bECAUSEoF⍠tIMEzONElEGISLATIONiN⍠iNDIAN⌺aRIZON⌺rUSSI⌸A⌺adECREEbYtHEpOPEiNtHE 1500S⌺⍠pRECESSION⌺lIBRATION⌺nUTATION⌺lIBATION⌺eCCENTRICITY⌺oBLIQUITY⌸oFtHE⍠mOON⌺sUN⌺eARTH''SaXIS⌺eQUATOR⌺pRIMEmERIDIAN⌺⍠iNTERNATIONALdATE⌺mASON-DIXON⌸lINE⌸⌺mAGNETICfIELDrEVERSAL⌺aNaRBITRARYdECISIONbY⍠bENJAMINfRANKLIN⌺iSAACnEWTON⌺fDR⌸⌸?aPPARENTLY⍠iTcAUSESapREDICTABLEiNCREASEiNcARaCCIDENTS⌺tHAT''SwHYwEhAVElEAPsECONDS⌺sCIENTISTSaRErEALLYwORRIED⌺iTwASmOREeXTREMEdURINGtHE ⍠BRONZEaGE⌺ICEaGE⌺CRETACEOUS⌺1990S⌸⌺tHERE''SapROPOSALtOfIXiT,bUTiT⍠wILLnEVERhAPPEN⌺aCTUALLYmAKEStHINGSwORSE⌺iSsTALLEDiNcONGRESS⌺mIGHTbEuNCONSTITUTIONAL⌸⌺iT''SgETTINGwORSEaNDnOoNEkNOWSwHY⌸.wHILEiTmAYsEEMlIKEtRIVIA,iT⍠cAUSEShUGEhEADACHESfORsOFTWAREdEVELOPERS⌺iStAKENaDVANTAGEoFbYhIGH-SPEEDtRADERS⌺tRIGGEREDtHE 2003nORTHEASTbLACKOUT⌺hAStObEcORRECTEDfORbYgPSsATELLITES⌺iSnOWrECOGNIZEDaSamAJORcAUSEoFwORLDwARi⌸.'

Cobalah online!

Adám membantu dengan yang satu ini ... kemudian menantang saya untuk menyelesaikannya. : P

-11 terima kasih kepada Adám (menggunakan alat SBCS barunya, saya dapat menyalahgunakan penyandian tanpa biaya tambahan).



@ Adam ya saya ingat ...
Erik the Outgolfer

2

Haskell , 1949 1938 byte

import System.Random
data T a=N a[T a](T a)|P Char(T a)|E
l s=N s[]E
t=N"the"
w=map l.words
k=map l.lines
d=N""
g!a|(i,h)<-randomR(0,length a-1)g=(a!!i,h)
g#E=("",g)
g#(P c n)|(e,v)<-g#n=(c:e,v)
g#(N s[]n)|(e,v)<-g#n=([' '|s>""]++s++e,v)
g#(N s c n)|(p,q)<-g!c,(m,h)<-q#p,(e,v)<-h#n=([' '|s>""]++s++m++e,v)
tail.fst.(#N"Did you know that"[t(w"fall spring")$l"equinox",t(w"winter summer")$d(w"solstice olympics")E,t(w"earliest latest")$d(w"sunrise sunset")E,N"daylight"(w"saving savings")$l"time",N"leap"(w"day year")E,l"easter",t(w"harvest super blood")$l"moon",l"Toyota truck month",l"shark week"](d[N"happens"(k"earlier\nlater\nat the wrong time")$l"every year",N"drifts out of sync with the"[l"sun",l"moon",l"zodiac",d(w"gregorian mayan lunar iPhone")$l"calendar",l"atomic clock in Colorado"]E,N"might"(k"not happen\nhappen twice")$l"this year"]$N"because of"[N"time zone legislation in"(w"Indiana Arizona Russia")E,l"a decree by the Pope in the 1500s",d(w"precession libration nutation libation eccentricity obliquity")$N"of the"(k"moon\nsun\nEarth's axis\nequator\nprime meridian\ninternational date line\nMason-Dixon line")E,l"magnetic field reversal",N"an arbitrary decision by"(k"Benjamin Franklin\nIsaac Newton\nFDR")E]$P '?'$N"Apparently"[l"it causes a predictable increase in car accidents",l"that's why we have leap seconds",l"scientists are really worried",N"it was even more extreme during the"[l"bronze age",l"ice age",l"cretaceous",l"1990's"]E,N"there's a proposal to fix it, but it"(k"will never happen\nactually makes things worse\nis stalled in congress\nmight be unconstitutional")E,l"it's getting worse and no one knows why"]$P '.'$N"While it may seem like trivia, it"(k"causes huge headaches for software developers\nis taken advantage of by high-speed traders\ntriggered the 2003 Northeast Blackout\nhas to be corrected for by GPS satellites\nis now recognized as a major cause of World War I")$P '.'E))<$>newStdGen

Cobalah online!(Memiliki 2 byte tambahan untuk f=)

Kebanyakan menulis ini supaya saya bisa membuat struktur data. Ini pasti bisa diperbaiki tetapi saya lelah dan saya harus segera pergi. Saya pikir kapitalisasi sebagian besar benar, tetapi saya akan mengkonversikannya menjadi huruf besar jika salah. Itu tidak akan mengubah jumlah byte atau apa pun karena saya belum melakukan sesuatu yang aneh dengan data string.

Ide dasarnya adalah daftar pohon yang ditautkan di mana setiap simpul kosong ( E), tanda baca ( P) atau label string dengan anak-anak. Semua node kecuali Enode memiliki simpul "pengikut" yang datang setelah mereka.

EDIT: baru saja melihat kesalahan ejaan (saya menulis "tidak ada yang tahu mengapa" alih-alih "tidak ada yang tahu mengapa") jadi saya harus menambahkan byte untuk memperbaikinya tetapi saya juga menemukan beberapa kode yang dapat dihapus


0

APL (Dyalog Unicode) , 1593 byte

C←?∘≢⊃⊢
S←C'|'∘≠⊆⊢
∊'Did you know that '(C('the '(S'Fall|Spring')' Equinox ')('the '(S'Winter |Summer ')(S'Solstice |Olympics '))('the '(S'Earliest |Latest ')(S'Sunrise |Sunset '))('Leap ',S'Day |Year ')'Easter '('the '(S'Harvest|Super|Blood')' Moon ')'Toyota Truck Month '('Daylight Savings Time '~C's∘')'Shark Week ')(C('happens '(S'earlier|later|at the wrong time')' every year ')('drifts out of sync with the '(S'Sun |Moon |Zodiac |atomic clock in Colorado|',' Calendar ',⍨S'Gregorian|Mayan|Lunar|iPhone'))('might '(S'not happen|happen twice')' this year '))'because of '(C('time zone legislation in ',S'Indiana|Arizona|Russia')'a decree by the pope in the 1500s'((S'precession|libration|nutation|libation|eccentricity|obliquity')' of the '(S'Moon|Sun|Earth''s axis|equator|prime meridian|',' line',⍨S'international date|mason-dixon'))'magnetic field reversal'('an arbitrary decision by ',S'Benjamin Franklin|Isaac Newton|FDR'))'? Apparently '(C'it causes a predictable increase in car accidents'('it was even more extreme during the ',S'Bronze Age|Ice Age|Cretaceous|1990s')'that''s why we have leap seconds'('there''s a proposal to fix it, but it ',S'will never happen|actually makes things worse|is stalled in congress|might be unconstitutional')'scientists are really worried' 'it''s getting worse and no one knows why')'. While it may seem like trivia, it '(S'causes huge headaches for software developers|is taken advantage of by high-speed traders|triggered the 2003 Northeast Blackout|has to be corrected for by GPS satellites|is now recognized as a major cause of World War I')'.'

Cobalah online!

Menentukan dua fungsi pembantu dan kemudian menggunakannya dalam satu ekspresi raksasa:

C← C (untuk C hoose) adalah
?∘≢ angka acak hingga jumlah elemen dalam argumen yang
 diambil
 dari argumen

S← S (untuk S plit dan S terpilih) adalah
C memilih di antara  argumen
'|'∘≠ dimana-tidak-pipa
dipartisi

ϵ nlist (flatten)
Cmemilih dari daftar string dan Smemilih dari substring dari |string yang dibatasi, dan ini hanya digunakan dalam kombinasi untuk membangun "fakta".

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.