Added answer to problem 5 by scala