scala exercises (3-1 is incomplete)