@@ -21,7 +21,6 @@ def compute_transform_tables(
21
21
destination_seq = list (destination_string )
22
22
len_source_seq = len (source_seq )
23
23
len_destination_seq = len (destination_seq )
24
-
25
24
costs = [
26
25
[0 for _ in range (len_destination_seq + 1 )] for _ in range (len_source_seq + 1 )
27
26
]
@@ -31,28 +30,28 @@ def compute_transform_tables(
31
30
32
31
for i in range (1 , len_source_seq + 1 ):
33
32
costs [i ][0 ] = i * delete_cost
34
- ops [i ][0 ] = f"D{ source_seq [i - 1 ]:c } "
33
+ ops [i ][0 ] = f"D{ source_seq [i - 1 ]} "
35
34
36
35
for i in range (1 , len_destination_seq + 1 ):
37
36
costs [0 ][i ] = i * insert_cost
38
- ops [0 ][i ] = f"I{ destination_seq [i - 1 ]:c } "
37
+ ops [0 ][i ] = f"I{ destination_seq [i - 1 ]} "
39
38
40
39
for i in range (1 , len_source_seq + 1 ):
41
40
for j in range (1 , len_destination_seq + 1 ):
42
41
if source_seq [i - 1 ] == destination_seq [j - 1 ]:
43
42
costs [i ][j ] = costs [i - 1 ][j - 1 ] + copy_cost
44
- ops [i ][j ] = f"C{ source_seq [i - 1 ]:c } "
43
+ ops [i ][j ] = f"C{ source_seq [i - 1 ]} "
45
44
else :
46
45
costs [i ][j ] = costs [i - 1 ][j - 1 ] + replace_cost
47
- ops [i ][j ] = f"R{ source_seq [i - 1 ]:c } " + str (destination_seq [j - 1 ])
46
+ ops [i ][j ] = f"R{ source_seq [i - 1 ]} " + str (destination_seq [j - 1 ])
48
47
49
48
if costs [i - 1 ][j ] + delete_cost < costs [i ][j ]:
50
49
costs [i ][j ] = costs [i - 1 ][j ] + delete_cost
51
- ops [i ][j ] = f"D{ source_seq [i - 1 ]:c } "
50
+ ops [i ][j ] = f"D{ source_seq [i - 1 ]} "
52
51
53
52
if costs [i ][j - 1 ] + insert_cost < costs [i ][j ]:
54
53
costs [i ][j ] = costs [i ][j - 1 ] + insert_cost
55
- ops [i ][j ] = f"I{ destination_seq [j - 1 ]:c } "
54
+ ops [i ][j ] = f"I{ destination_seq [j - 1 ]} "
56
55
57
56
return costs , ops
58
57
0 commit comments