scala exercises (P20-P21)