Add Python solution for problem 3. Modify Scala solution for problem 3.