Another exercise from Learn to Program