Tiny, but you can use zipWithIndex instead of manually writing the range. It gives you exactly the same tuple. You should use scores.view here instead of scores