Solve hamming in scala