scala exercises (P18-P19)