Solution to the Double Squares challenge from CodeEval and FB Hacker Cup 2011