A Ruby solution for xkcd 287