scala exercises (P61A)