Solution to problem here: http://www.mrbrown.com/blog/2013/02/more-maths-madness.html