My solution to codeeval