Word Distance - Sum - MATLAB Cody - MATLAB Central

Problem 44815. Word Distance - Sum

Difficulty:Rate

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

23.9% Correct | 76.1% Incorrect
Last Solution submitted on May 06, 2025

Problem Comments

Solution Comments

Show comments
LLMs with MATLAB updated to support the latest OpenAI Models
Large Languge model with MATLAB, a free add-on that lets you access...
1
3

Problem Recent Solvers174

Suggested Problems

More from this Author139

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!
Go to top of page