scala exercises (P24)