The scala code to solve problems on Codility