Implementation of xkcd 1286.