Add Scala and Python solutions for problem 6. Modify Java solution for problem 6.