Solution to some codility tasks