Codility Demo problem solved.