Solved #92 in scala