Skip to content

Commit 69af177

Browse files
committed
resolved line length issues based on ruff requirements
1 parent 05f5983 commit 69af177

File tree

1 file changed

+22
-9
lines changed

1 file changed

+22
-9
lines changed

strings/min_cost_string_conversion.py

+22-9
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,18 @@ def compute_transform_tables(
1818
insert_cost: int,
1919
) -> tuple[list[list[int]], list[list[str]]]:
2020
"""
21-
Finds the most cost efficient sequence for converting one string into another.
22-
23-
>>> compute_transform_tables("cat", "cut", 1, 2, 3, 3)
24-
([[0, 3, 6, 9], [3, 1, 4, 7], [6, 4, 3, 6], [9, 7, 6, 4]], [['0', 'Ic', 'Iu', 'It'], ['Dc', 'Cc', 'Iu', 'It'], ['Da', 'Da', 'Rau', 'Rat'], ['Dt', 'Dt', 'Rtu', 'Ct']])
21+
Finds the most cost efficient sequence
22+
for converting one string into another.
23+
24+
>>> costs, operations = compute_transform_tables("cat", "cut", 1, 2, 3, 3)
25+
>>> costs[0][:4]
26+
[0, 3, 6, 9]
27+
>>> costs[2][:4]
28+
[6, 4, 3, 6]
29+
>>> operations[0][:4]
30+
['0', 'Ic', 'Iu', 'It']
31+
>>> operations[3][:4]
32+
['Dt', 'Dt', 'Rtu', 'Ct']
2533
2634
>>> compute_transform_tables("", "", 1, 2, 3, 3)
2735
([[0]], [['0']])
@@ -38,7 +46,9 @@ def compute_transform_tables(
3846
["0" for _ in range(len_destination_seq + 1)] for _ in range(len_source_seq + 1)
3947
]
4048

41-
# Removed ':c' specifier as it is generally used for integers to convert to a Unicode character not strings.
49+
# Removed ':c' specifier as it is generally
50+
# used for integers to convert to a Unicode
51+
# character not strings.
4252
for i in range(1, len_source_seq + 1):
4353
costs[i][0] = i * delete_cost
4454
ops[i][0] = f"D{source_seq[i - 1]}"
@@ -69,9 +79,12 @@ def compute_transform_tables(
6979

7080
def assemble_transformation(ops: list[list[str]], i: int, j: int) -> list[str]:
7181
"""
72-
Assembles the transformations based on the information in the ops table.
73-
74-
>>> ops = [['0', 'Ic', 'Iu', 'It'], ['Dc', 'Cc', 'Iu', 'It'], ['Da', 'Da', 'Rau', 'Rat'], ['Dt', 'Dt', 'Rtu', 'Ct']]
82+
Assembles the transformations based on the ops table.
83+
84+
>>> ops = [['0', 'Ic', 'Iu', 'It'],
85+
... ['Dc', 'Cc', 'Iu', 'It'],
86+
... ['Da', 'Da', 'Rau', 'Rat'],
87+
... ['Dt', 'Dt', 'Rtu', 'Ct']]
7588
>>> x = len(ops) - 1
7689
>>> y = len(ops[0]) - 1
7790
>>> assemble_transformation(ops, x, y)
@@ -150,4 +163,4 @@ def assemble_transformation(ops: list[list[str]], i: int, j: int) -> list[str]:
150163
print("".join(string))
151164
print("Cost: ", cost)
152165

153-
file.write("\r\nMinimum cost: " + str(cost))
166+
file.write("\r\nMinimum cost: " + str(cost))

0 commit comments

Comments
 (0)