Solution for codeeval problems