first and second. All letters in first are distinct, and second contains exactly the same letters, possibly in a different order.
For each letter, find how many positions its index moved between first and second (the absolute difference of the indices). Return the sum of these moves over all letters.first="dog", second="god" → 4
d moves from 0 to 2, o stays at 1, g moves from 2 to 0: 2 + 0 + 2 = 4.
first="plan", second="lpan" → 2
Only p and l swapped places, each moving by 1, for a total of 2.
first="x", second="x" → 0
first="dog", second="god"
4
Run checks the first 3 tests in your browser. Submit checks all 70 tests on the server, hidden ones included.