Based on the method of this problem, write a function to calculate the letter distance for a set of words and then return the sorted set of words based on their distances, in ascending order. However, their distances will now be normalized by the number of characters in each word. For example, if
str_arr = {'jazz','cab','tree'}then
d = [(9+25+0)/4, (2+1)/3, (2+13+0)/4] = [34/4, 3/3, 15/4] = [8.5, 1, 3.75]
which would result in the following sorted order:
str_arr_sort = {'cab','tree','jazz'}Remember that the method is case insensitive. See the test suite for examples.
Solution Stats
Problem Comments
Solution Comments
Show comments
Loading...
Problem Recent Solvers16
Suggested Problems
-
Back to basics 13 - Input variables
391 Solvers
-
Split a string into chunks of specified length
2134 Solvers
-
275 Solvers
-
610 Solvers
-
Find and replaces spaces from a input string with *
172 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!