Codility questions. The program used to solve this task was Python 3.