Saturday, September 03, 2011

When will the 1000th XKCD will come out? F# knows (as in using F# to figure it out...)

Robert Pickering's Strange Blog - Calculating when the 1000th XKCD will appear

"Like so many geeks I’m a massive XKCD fan. But I’m often troubled by questions like when will the 1000th XKCD appear, or the 1024th or even the 2000th? Even though the first two numbers are getting quite close now, it’s still more fingers and toes than I have so working it out by hand is out. Fortunately we have computers to this kind of heavy lifting for us, and the solution in F# is kinda cute.

We need 3 pieces of information to be able to work out when any given XKCD will appear: an epoch date and number as well as the days that XKCD is published on. I chose todays date, 2nd September 2011 when XKCD 946 was published. I would have been nice to start with issue 1, but in the early days of XKCD it wasn’t published regularly so starting at the beginning would considerable complexity the task, and besides, we already know when numbers in the past were published. XKCD is published on Mondays, Wednesdays and Fridays, so here’s how we encode this information in F#:

...

image..."

There's something that's just dev-geek awesome about this...

No comments: