Hmm... Why not just work in binary?  You could save on the number of variables and the number of calls to functions, speeding up the exercise.