Finished programming exercise of sheet 6.