This problem description is lifted from http://en.wikipedia.org/wiki/Levenshtein_distance.
The Levenshtein distance between two strings is defined as the minimum number of edits needed to transform one string into the other, with the allowable edit operations being insertion, deletion, or substitution of a single character.
For example, the Levenshtein distance between "kitten" and "sitting" is 3, since the following three edits change one into the other, and there is no way to do it with fewer than three edits:
kitten => sitten (substitution of 's' for 'k') sitten => sittin (substitution of 'e' for 'i') sittin => sitting (insert 'g' at the end).
So when
s1 = 'kitten'
and
s2 = 'sitting'
then the distance d is equal to 3.
Good question
Shameless code... now i'll do that in right way.
The simplest solution for beginner, now I'm trying to solve in a correct way
Apparently the test suite needs to be augmented!
Done. People never get tired of look-up tables.
Indeed: all of the current supposedly 'top ten' submissions here (by Cody-size) are hard-coded hacks! The Test Suite can be augmented by: (i) adding more arbitrary test cases; (ii) adding test cases in which the first [and last] characters/words are the same as in some other test case(s); (iii) banning mention of numbers that correspond to results and need not be mentioned in legitimate submissions (e.g. 18, 25, 27) [as implemented for Problem 44466]; and (iv) potentially banning other key words appearing in other 'generic' hacks (per Solutions 312146 and 1039520). —DIV
Find the "ordinary" or Euclidean distance between A and Z
119 Solvers
Get the elements of diagonal and antidiagonal for any m-by-n matrix
198 Solvers
264 Solvers
Find the index of the largest value in any vector X=[4,3,4,5,9,12,0,4.....5]
231 Solvers
Create a two dimensional zero matrix
275 Solvers