INPUT: Any string consisting exclusively of lowercase letters via function argument, command line argument, STDIN, or similar.
OUTPUT: Print or return a number that will represent the sum of the distances of the letters according to the following metric:
You take the first and second letter and count the distance between them. The distance is defined by the QWERTY keyboard layout, where every adjacent letter in the same row has distance 1 and every adjacent letter in the same column has distance 2. To measure the distance between letters that aren't adjacent, you take the shortest path between the two.
q->w is 1 distance apart q->e is 2 distance q->a is 2 distance q->s is 3 distance (q->a->s or q->w->s) q->m is 10 distance
Then you take the second and third letter, then the third and fourth, etc., until you reach the end of the input. The output is the sum of all those distances.
Example input and output:
INPUT: qwer OUTPUT: 3 INPUT: qsx OUTPUT: 5 INPUT: qmq OUTPUT: 20 INPUT: tttt OUTPUT: 0
Here is an image showing which letters are in the same column:
This is code golf, so the shortest code in bytes wins!