Codility challenge solutions