added solution 6 prob. 6, in Scala and Python