Solved #7 in scala
Solved #8 in scala