Although in this case, to be honest, the code is not that great. Lots of repetition/noise-- plenty of opportunity for factoring.
Good work on this, btw. I'd be super ashamed to release the one I wrote (I was in university at the time, though that's no excuse).