Problem 44815. Word Distance - Sum
Let's suppose that the distance of a word can be calculated by summing the differences between its letters, having assigned the letters of the alphabet to integers (a = 1, b = 2, ... z = 26). For example, if
word = 'hello'
then the total distance would be
abs(8–5) + abs(5–12) + abs(12–12) + abs(12–15) = 3 + 7 + 0 + 3 = 13.
Let's also make this case insensitive (i.e., 'A' = 'a'). Write a function to return the distance for any word or set of words. See the test suite for examples.
Solution Stats
Problem Comments
-
1 Comment
Brandon
on 3 Jul 2023
Why would you create a problem with multiple kinds of inputs? This is just stupid.
Solution Comments
Show commentsProblem Recent Solvers168
Suggested Problems
-
Remove all the words that end with "ain"
2297 Solvers
-
501 Solvers
-
Sum of odd numbers in a matrix
574 Solvers
-
ベクトル [1 2 3 4 5 6 7 8 9 10] の作成
549 Solvers
-
1117 Solvers
More from this Author139
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!