Codility tasks solutions