Change the dir structure slightly

This commit is contained in:
Marina von Steinkirch 2018-06-14 15:50:29 -07:00
parent 6b6fe21db3
commit 2f4a9638c0
184 changed files with 0 additions and 21 deletions

View file

@ -1,43 +0,0 @@
#!/usr/bin/env python
__author__ = "bt3"
''' computes the edit distance between two strings '''
def find_edit_distance(str1, str2):
'''
>>> s = 'sunday'
>>> t = 'saturday'
>>> find_edit_distance(s, t)
3
'''
m = len(str1)
n = len(str2)
diff = lambda c1, c2: 0 if c1 == c2 else 1
E = [[0] * (n + 1) for i in range(m + 1)]
for i in range(m + 1):
E[i][0] = i
for j in range(1, n + 1):
E[0][j] = j
for i in range(1, m + 1):
for j in range(1, n + 1):
E[i][j] = min(E[i-1][j] + 1, E[i][j-1] + 1, E[i-1][j-1] + diff(str1[i-1], str2[j-1]))
return E[m][n]
if __name__ == '__main__':
import doctest
doctest.testmod()