scala exercises (P11-P13)