Created
March 21, 2014 08:02
-
-
Save mailpraveens/9681672 to your computer and use it in GitHub Desktop.
Recursive program to find the levenshtein distance between two strings
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def calculateLevenSteninDistance(a,b): | |
if not a: return len(b) | |
if not b: return len(a) | |
return min(calculateLevenSteninDistance(a[1:], b[1:])+(a[0] != b[0]), calculateLevenSteninDistance(a[1:], b)+1, calculateLevenSteninDistance(a, b[1:])+1) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment