word. Walk through it from left to right and, for every pair of neighbouring letters, take the absolute difference of their ASCII codes. Return the sum of these values.
For example, the codes in "bad" are 98, 97 and 100, so the answer is |98 − 97| + |97 − 100| = 1 + 3 = 4.word="code" → 24
Codes: c = 99, o = 111, d = 100, e = 101. The sum |99 − 111| + |111 − 100| + |100 − 101| = 12 + 11 + 1 = 24.
word="aza" → 50
From a to z is 25, and back again another 25, so 50.
word="mm" → 0
word consists of lowercase English lettersword="code"
24
Run checks the first 3 tests in your browser. Submit checks all 88 tests on the server, hidden ones included.