Implemented task for Algorithms course Week 2