Solution to CodeEval problems