Nice! I got about half way through (without the cheat sheet) but then got stumped. I looked at the values on successive iterations, realized that only 0-2 mattered, and got sort of a feel for how the transformation was being applied. (i.e. the twos near the front were being peeled off one at a time, etc.) However, when I got to that formula I was totally thrown for a loop. I spent a little time poking around at it, but never figured out what it was doing (or how it was doing it) at all.
Again, nicely done.
-Blake