Scala: fold by indices
Code\n\nobject Solution {\n  def scoreOfString(s: String): Int = \n    (1 until s.length).foldLeft(0)((sum, i) => sum + (s(i - 1) - s(i)).abs)\n}\n
# Code\n```\nobject Solution {\n  def scoreOfString(s: String): Int = \n    (1 until s.length).foldLeft(0)((sum, i) => sum + (s(i - 1) - s(i)).abs)\n}\n```
['Scala']