This drove me nuts. I'm not very good at math in the beginning, and when I first started, trying to figure out if there was some special equation to figure it out wasn't ending well.
Then, I sat down here tonight, and figured it out in a matter of ten minutes. Go figure.
Very clever. I look forward to torturing my friends with it.