scala exercises (P49)