Problem 196. love is an n-letter word
Given a list of N words, return the N-letter word (choosing one letter from each word) with the property of having the least distance between each pair of two consecutive letters (if there are multiple optimal solutions return any one of them).
Example: s1 = {'abcd','bcde','cdef','defg'}; should return s2 = 'dddd'; (with total letter-distance = 0)
Example: s1={'aldfejk','czoa','vwy','abcde'}; should return s2='love'; (with total letter-distance = 27: 'l'-'o'=3 + 'o'-'v'=7 + 'v'-'e'=17 ; compare for example to the possible word 'aave' which has a total letter-distance of 38)
Solution Stats
Problem Comments
-
4 Comments
apparently it tries to call an overloaded diff ( probably from the symbolic toolbox ) for which it doesn’t have a license
@Martijn: I am not sure why that is happening but in the meantime using "diff(double('test'))" should work fine
fixed look-up table hack
Solution Comments
Show commentsProblem Recent Solvers42
Suggested Problems
-
235 Solvers
-
Sum of first n terms of a harmonic progression
431 Solvers
-
String substitution, sub problem to cryptoMath
231 Solvers
-
Change the sign of even index entries of the reversed vector
566 Solvers
-
91 Solvers
More from this Author38
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!