I have the base cases but I don't know how to access them and compute to choose the better operation and save a tuple in the cells
from enum import Enum
class Operation(Enum):
"""Operations"""
DELETED = 1
INSERTED = 2
SUBSTITUTED = 3
def __str__(self):
return str(self.name.lower())
def distances(a, b):
"""Calculate edit distance from a to b"""
# generating 2d list
matrix = []
for i in range(len(a)+1): #string a and rows
matrix.append([])
for j in range(len(b)+1): #string b and columns
matrix[i].append([])
# base cases
c = 1
for i in range(len(a)):
matrix[i+1][0] = [c, Operation.DELETED]
c += 1
c = 1
for j in range(len(b)):
matrix[0][j+1] = [c, Operation.INSERTED]
c += 1
#filling in
for i in range(len(a)+1):
for j in range(len(b)+1):
#converting to tuple
for i in range(len(a)+1):
for j in range(len(b)+1):
matrix[i][j] = tuple(matrix[i][j])
print(matrix)
distances('cat','ate')