Swift💯
Functional approach (accepted answer)\n\nimport Algorithms\n\nclass Solution {\n    func scoreOfString(_ s: String) -> Int {\n        s.utf8CString          // 
**Functional approach (accepted answer)**\n```\nimport Algorithms\n\nclass Solution {\n    func scoreOfString(_ s: String) -> Int {\n        s.utf8CString          // convert `s` into `[CChar]` (`CChar` is typealias for `UInt8`)\n\t\t .dropLast()           // drop the zero-terminator that is added to the C string\n\t\t .compactMap(Int.init) // convert all elements from `UInt8` to `Int`\n\t\t .adjacentPairs()      // creates a sequence of tuples `[(s[0],s[1]), (s[1],s[2]),...]`\n\t\t .map{abs($0-$1)}      // convert tuples to difference `abs(s[x]-s[x+1])`\n\t\t .reduce(0,+)          // sum up array of differences\n    }\n}\n```
['Swift']