XKCD Calendar Facts

17

1

Inspiration. Posted with permission.

Print one of the possible XKCD calendar "facts":

XKCD Calendar Facts

You can get the raw text and structure from my APL reference implementation or from Explain XKCD's transcript (including the title text just under the illustration).

Rules

At every decision node, there must be an equal (pseudo-)random chance of each choice.

You may use all uppercase.

You must generate three sentences; a question, a reason, and a title text.

The three sentences should be ended by ?, ., and . respectively, and separated from each other by a single space.

The only extra white-space you may include is one trailing space and/or line break.

Examples

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.

Adám

Posted 2017-12-19T12:37:02.300

Reputation: 37 779

@Rod I never said anything about the chart. I said to get the text from my reference implementation (which includes it) or from Explain XKCD (with a note to include the title text). – Adám – 2017-12-19T13:14:30.810

Are leading spaces in the output allowed? – Erik the Outgolfer – 2017-12-19T14:30:45.750

@EriktheOutgolfer No. – Adám – 2017-12-19T14:31:22.463

Related – FryAmTheEggman – 2017-12-19T16:05:06.917

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. I... I mean... I... Okay. – Magic Octopus Urn – 2017-12-19T16:54:25.390

Is there a time constraint on how long the program can take to finish running? – Οurous – 2017-12-20T23:24:25.553

@Οurous Not really. Are you intending very long, like after the heat death of the universe? – Adám – 2017-12-21T00:44:13.497

@Adám No, just a few weeks worst-case. A few hours for most random seeds. – Οurous – 2017-12-21T01:00:57.400

My CTO made this neat representation.

– Adám – 2018-01-02T11:53:49.117

Answers

7

Befunge-93, 1959 1930 bytes

"#~$}%|&{'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>% "$&(

Try it online!

Explanation

In the first three lines, we start by building up a kind of state table on the stack, representing the graph of all possible sentences. These stack entries are grouped into pairs, so there is first a string item, and then a jump or branch. Where necessary, the graph is padded with empty strings and zero-length jumps in order to meet this requirement.

Our main loop then begins by popping a number, representing a string item, off the stack. This number is interpreted as an offset into the string table in the lower section of the source. The string table is essentially a kind of linked list, wrapped over multiple lines to fit into Befunge's constrained memory space.

After outputting a string, the next item on the stack is either a jump or branch. If the number is less than 32, it's a jump, which we interpret by dropping that many pairs of items from the stack. If the number is 32 or more, it's a branch, and we use the value (minus 32) to lookup the branch details from the table on the last line of the source.

The entries in the branch table each consist of a count, followed by a list of offsets. Once we know which branch to use, we simply generate a random number, modulo the branch count, to lookup the appropriate offset. This offset is then interpreted as a jump, dropping the required number of items from the stack.

We repeat this process, outputting a string, then performing a jump or branch, until we run out of stack entries. At that point, we simply output a "." to mark the end of the final sentence, and then exit.

James Holderness

Posted 2017-12-19T12:37:02.300

Reputation: 8 298

3What is the URL doing in there? – Adám – 2017-12-21T09:19:03.900

4@Adám I had a bit of space in the middle of the line and thought it would be a neat way to credit the original comic. The byte count also kind of references the comic, but that was entirely coincidental. – James Holderness – 2017-12-21T10:30:29.520

This is surprisingly fast... – Erik the Outgolfer – 2017-12-24T12:52:16.640

5

Javascript (ES6), 1698 1510 1506 1501 bytes

Thanks to 12Me21 for fixing a bug in the code, which added 2 bytes

f= and document.write(f()) are not part of the byte count

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())

Herman L

Posted 2017-12-19T12:37:02.300

Reputation: 3 611

4

Python 2, 1297 bytes

-419 bytes thanks to 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')

Try it online!

The actual code:

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')+'.'

That was tiring. I haven't even done basic golfing. Somebody please write a script to golf this.

totallyhuman

Posted 2017-12-19T12:37:02.300

Reputation: 15 378

I think this fails the spec of an equal pseudo-random chance at each decision node at the Gregorian/Mayan/Lunar/iPhone calendar node. You have a choice function for those four calendar types embedded within another choice. This means that "Gregorian calendar" will be a quarter as likely as "atomic clock in Colorado". – Sellyme – 2017-12-19T13:43:06.623

3I think those are separate decision nodes. "Drifts out of sync with" connects to "Sun" "Moon" "Zodiac" "_ Calendar" and "Atomic clock in Colorado", and the choice between "Gregorian" "Mayan" "Lunar" and "iPhone" is only done if the "Calendar" branch is chosen.

EDIT: Also, the reference implementation has the same behavior. – 12Me21 – 2017-12-19T13:48:49.187

Yes, each node splits even, no matter how many sub-nodes it has. – Adám – 2017-12-19T14:01:01.717

It looks like you've got 'libation' twice - one of them should be 'libration'. At least in the uncompressed code - not sure if the compressed version is the same. – James Holderness – 2017-12-20T01:08:01.203

3

Charcoal, 806 bytes

≔”}‽÷⌊&β¶&⁰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β≔⁺⁺§⪪θι⁰‽✂⪪θι¹±¹¦¹⊟⪪θιθθ

Try it online! Link is to verbose version of code. Explanation:

 ”....”                             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`

Neil

Posted 2017-12-19T12:37:02.300

Reputation: 95 035

3

R, 1903 1751 1743 bytes

A simple brute-force solution. Might be some way to golf it down some more.

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'),'.')

Try it online!

rturnbull

Posted 2017-12-19T12:37:02.300

Reputation: 3 689

2

Haskell, 1949 1938 bytes

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

Try it online! (Has an extra 2 bytes for f=)

Mostly wrote this just so I could create the data structure. This could definitely be improved but I'm tired and I have to leave soon anyway. I think capitalization is mostly right but I'll convert it all to caps if it's wrong. That won't change the byte count or anything since I haven't done anything weird with the string data.

Basic idea is a linked list of trees where each node is either empty (E), a punctuation mark (P) or a string label with children. All nodes except E nodes have a "follower" node that comes after them.

EDIT: just noticed a spelling mistake (I wrote "no one know why" instead of "no one knows why") so I had to add a byte to fix it but I also found some code that could be cut out

user1472751

Posted 2017-12-19T12:37:02.300

Reputation: 1 511

2

JavaScript (ES6), 1275 bytes

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')

where the ... represents the result of running atob() on this string and replacing \ with \\, ` with \`, 0x00 with \0, and 0x0D with \r:

DIDaYOUaKNOWaTHATgTHEgFALLhSPRINGiEQUINOXhTHEgWINTERhSUMMERigSOLSTICEhOLYMPICSihTHEgEARLIESThLATESTigSUNRISEhSUNSETihTHEgHARVESThSUPERhBLOODiMOONhDAYLIGHTgSAVINGhSAVINGSiTIMEhLEAPgDAYhYEARihEASTERhTOYOTAaTRUCKaMONTHhSHARKaWEEKigHAPPENSgEARLIERhLATERhATaTHEaWRONGaTIMEiEVERYaYEARhDRIFTSaOUTaOFaSYNCaWITHaTHEgSUNhMOONhZODIAChgGREGORIANhMAYANhLUNARhIPHONEiCALENDARhATOMICaCLOCKaINaCOLORADOihMIGHTgNOTaHAPPENhHAPPENaTWICEiTHISaYEARiBECAUSEaOFgTIMEaZONEaLEGISLATIONaINgINDIANAhARIZONAhRUSSIAihAaDECREEaBYaTHEaPOPEaINaTHEa1500ShgPRECESSIONhLIBRATIONhNUTATIONhLIBRATIONhECCENTRICITYhOBLIQUITYiOFaTHEgSUNhMOONhEARTHbSaAXIShEQUATORhPRIMEaMERIDIANhINTERNATIONALaDATEaLINEhMASONcDIXONaLINEihMAGNETICaFIELDaREVERSALhANaARBITRARYaDECISIONaBYgBENJAMINaFRANKLINhISSACaNEWTONhFDRiidaAPPARENTLYgITaCAUSESaAaPREDICTABLEaINCREASEaINaCARaACCIDENTShTHATbSaWHYaWEaHAVEaLEAPaSECONDShSCIENTISTSaAREaREALLYaWORRIEDhITaWASaEVENaMOREaEXTREMEaDURINGaTHEgBRONZEaAGEhICEaAGEhCRETACEOUSh1990SihTHEREbSaAaPROPOSALaTOaFIXaITeaBUTaITgWILLaNEVERaHAPPENhACTUALLYaMAKESaTHINGSaWORSEhISaSTALLEDaINaCONGRESShMIGHTaBEaUNCONSTITUTIONALihITbSaGETTINGaWORSEaANDaNOaONEaKNOWSaWHYifaWHILEaITaMAYaSEEMaLIKEaTRIVIAeaITgCAUSESaHUGEaHEADACHESaFORaSOFTWAREaDEVELOPERShISaTAKENaADVANTAGEaOFaBYaHIGHcSPEEDaTRADERShTRIGGEREDaTHEa2003aNORTHEASTaBLACKOUThHASaTOaBEaCORRECTEDaFORaBYaGPSaSATELLITEShISaNOWaRECOGNIZEDaASaAaMAJORaCAUSEaOFaWORLDaWARaIif

Try it here, minus the 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())

ETHproductions

Posted 2017-12-19T12:37:02.300

Reputation: 47 880

2

APL (Dyalog), 1302 bytes

'[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⌸.'

Try it online!

Adám helped with this one...then challenged me to finish it. :P

-11 thanks to Adám (using his new SBCS tool I can abuse the encoding without extra cost).

Erik the Outgolfer

Posted 2017-12-19T12:37:02.300

Reputation: 38 134

1289 using QuadR. – Adám – 2018-01-02T11:59:49.733

@Adám yeah I remember... – Erik the Outgolfer – 2018-01-02T12:02:51.750

0

APL (Dyalog Unicode), 1593 bytes

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')'.'

Try it online!

Defines two helper functions and then uses them in one giant expression:

C← C (for Choose) is
?∘≢ a random number up to the number of elements in the argument
 picks
 from the arguments

S← S (for Split and Select) is
C choose among
'|'∘≠ the where-not-pipe
partitioned
 argument

ϵnlist (flatten)
C chooses from a list of strings and S chooses from the substrings of a | delimited string, and these are just used in combination to construct a "fact".

Adám

Posted 2017-12-19T12:37:02.300

Reputation: 37 779