From d3a390a78d7e75417caa517e8b9cd7b64e76afc5 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 10:57:28 +0300 Subject: [PATCH 01/24] chore: Fix tests --- cellular_automata/game_of_life.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cellular_automata/game_of_life.py b/cellular_automata/game_of_life.py index 3382af7b5db6..da5884e51375 100644 --- a/cellular_automata/game_of_life.py +++ b/cellular_automata/game_of_life.py @@ -98,7 +98,7 @@ def __judge_point(pt: bool, neighbours: list[list[bool]]) -> bool: if pt: if alive < 2: state = False - elif alive == 2 or alive == 3: + elif alive in (2, 3): state = True elif alive > 3: state = False From d3c045ded4024e494f67857df4b41c7cef058699 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:26:37 +0300 Subject: [PATCH 02/24] chore: Fix failing ruff --- data_structures/trie/radix_tree.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data_structures/trie/radix_tree.py b/data_structures/trie/radix_tree.py index 66890346ec2b..cf2f25c29f13 100644 --- a/data_structures/trie/radix_tree.py +++ b/data_structures/trie/radix_tree.py @@ -156,7 +156,7 @@ def delete(self, word: str) -> bool: del self.nodes[word[0]] # We merge the current node with its only child if len(self.nodes) == 1 and not self.is_leaf: - merging_node = list(self.nodes.values())[0] + merging_node = next(iter(self.nodes.values())) self.is_leaf = merging_node.is_leaf self.prefix += merging_node.prefix self.nodes = merging_node.nodes @@ -165,7 +165,7 @@ def delete(self, word: str) -> bool: incoming_node.is_leaf = False # If there is 1 edge, we merge it with its child else: - merging_node = list(incoming_node.nodes.values())[0] + merging_node = next(iter(incoming_node.nodes.values())) incoming_node.is_leaf = merging_node.is_leaf incoming_node.prefix += merging_node.prefix incoming_node.nodes = merging_node.nodes From 50f3c968d0b28c0c26fa75ff60dfc09cbb2e7400 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:28:28 +0300 Subject: [PATCH 03/24] chore: Fix ruff errors --- divide_and_conquer/convex_hull.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/divide_and_conquer/convex_hull.py b/divide_and_conquer/convex_hull.py index 1ad933417da6..da92c20ec0f0 100644 --- a/divide_and_conquer/convex_hull.py +++ b/divide_and_conquer/convex_hull.py @@ -266,7 +266,7 @@ def convex_hull_bf(points: list[Point]) -> list[Point]: points_left_of_ij = points_right_of_ij = False ij_part_of_convex_hull = True for k in range(n): - if k != i and k != j: + if k not in (i, j): det_k = _det(points[i], points[j], points[k]) if det_k > 0: From 6a3e370d5a853b20a5be55093fd140e5404e2427 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:33:03 +0300 Subject: [PATCH 04/24] chore: Fix ruff errors --- ...directed_and_undirected_(weighted)_graph.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/graphs/directed_and_undirected_(weighted)_graph.py b/graphs/directed_and_undirected_(weighted)_graph.py index b29485031083..7b1d1a5e5699 100644 --- a/graphs/directed_and_undirected_(weighted)_graph.py +++ b/graphs/directed_and_undirected_(weighted)_graph.py @@ -39,7 +39,7 @@ def dfs(self, s=-2, d=-1): stack = [] visited = [] if s == -2: - s = list(self.graph)[0] + s = next(iter(self.graph)) stack.append(s) visited.append(s) ss = s @@ -87,7 +87,7 @@ def bfs(self, s=-2): d = deque() visited = [] if s == -2: - s = list(self.graph)[0] + s = next(iter(self.graph)) d.append(s) visited.append(s) while d: @@ -114,7 +114,7 @@ def topological_sort(self, s=-2): stack = [] visited = [] if s == -2: - s = list(self.graph)[0] + s = next(iter(self.graph)) stack.append(s) visited.append(s) ss = s @@ -146,7 +146,7 @@ def topological_sort(self, s=-2): def cycle_nodes(self): stack = [] visited = [] - s = list(self.graph)[0] + s = next(iter(self.graph)) stack.append(s) visited.append(s) parent = -2 @@ -199,7 +199,7 @@ def cycle_nodes(self): def has_cycle(self): stack = [] visited = [] - s = list(self.graph)[0] + s = next(iter(self.graph)) stack.append(s) visited.append(s) parent = -2 @@ -305,7 +305,7 @@ def dfs(self, s=-2, d=-1): stack = [] visited = [] if s == -2: - s = list(self.graph)[0] + s = next(iter(self.graph) stack.append(s) visited.append(s) ss = s @@ -353,7 +353,7 @@ def bfs(self, s=-2): d = deque() visited = [] if s == -2: - s = list(self.graph)[0] + s = next(iter(self.graph)) d.append(s) visited.append(s) while d: @@ -371,7 +371,7 @@ def degree(self, u): def cycle_nodes(self): stack = [] visited = [] - s = list(self.graph)[0] + s = next(iter(self.graph)) stack.append(s) visited.append(s) parent = -2 @@ -424,7 +424,7 @@ def cycle_nodes(self): def has_cycle(self): stack = [] visited = [] - s = list(self.graph)[0] + s = next(iter(self.graph)) stack.append(s) visited.append(s) parent = -2 From 1b0be4e60a7a2224664e1a715bca243c61b371cd Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:34:56 +0300 Subject: [PATCH 05/24] chore: Fix ruff errors --- graphs/edmonds_karp_multiple_source_and_sink.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphs/edmonds_karp_multiple_source_and_sink.py b/graphs/edmonds_karp_multiple_source_and_sink.py index d0610804109f..e58fdfeb37ac 100644 --- a/graphs/edmonds_karp_multiple_source_and_sink.py +++ b/graphs/edmonds_karp_multiple_source_and_sink.py @@ -113,7 +113,7 @@ def _algorithm(self): vertices_list = [ i for i in range(self.verticies_count) - if i != self.source_index and i != self.sink_index + if i not in (self.source_index, self.sink_index) ] # move through list From cef5c6fd2184a0dff3e366c1a1b83bab82d3a8f4 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:35:54 +0300 Subject: [PATCH 06/24] chore: Fix ruff errors --- maths/factorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/factorial.py b/maths/factorial.py index bbf0efc011d8..9c0e25973165 100644 --- a/maths/factorial.py +++ b/maths/factorial.py @@ -55,7 +55,7 @@ def factorial_recursive(n: int) -> int: raise ValueError("factorial() only accepts integral values") if n < 0: raise ValueError("factorial() not defined for negative values") - return 1 if n == 0 or n == 1 else n * factorial(n - 1) + return 1 if n in (0, 1) else n * factorial(n - 1) if __name__ == "__main__": From 8dd51199581a93cdd3fba0ab8738ce5a5dec27d7 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:37:05 +0300 Subject: [PATCH 07/24] chore: Fix ruff errors --- maths/primelib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/primelib.py b/maths/primelib.py index 81d5737063f0..d93635682f83 100644 --- a/maths/primelib.py +++ b/maths/primelib.py @@ -154,7 +154,7 @@ def prime_factorization(number): quotient = number - if number == 0 or number == 1: + if number in (0, 1): ans.append(number) # if 'number' not prime then builds the prime factorization of 'number' From dedd1735ae1e18da818b127b391d9f7d54dbb913 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:38:47 +0300 Subject: [PATCH 08/24] chore: Fix ruff errors --- other/davisb_putnamb_logemannb_loveland.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/other/davisb_putnamb_logemannb_loveland.py b/other/davisb_putnamb_logemannb_loveland.py index a1bea5b3992e..f5fb103ba528 100644 --- a/other/davisb_putnamb_logemannb_loveland.py +++ b/other/davisb_putnamb_logemannb_loveland.py @@ -253,7 +253,7 @@ def find_unit_clauses( unit_symbols = [] for clause in clauses: if len(clause) == 1: - unit_symbols.append(list(clause.literals.keys())[0]) + unit_symbols.append(next(iter(clause.literals.keys()))) else: f_count, n_count = 0, 0 for literal, value in clause.literals.items(): From ff63a0dbaa62b69e0c72ce0183bd0d9b41086a57 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:40:41 +0300 Subject: [PATCH 09/24] chore: Fix ruff errors --- project_euler/problem_009/sol3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project_euler/problem_009/sol3.py b/project_euler/problem_009/sol3.py index d299f821d4f6..d4fe2bb03d09 100644 --- a/project_euler/problem_009/sol3.py +++ b/project_euler/problem_009/sol3.py @@ -28,12 +28,12 @@ def solution() -> int: 31875000 """ - return [ + return next([ a * b * (1000 - a - b) for a in range(1, 999) for b in range(a, 999) if (a * a + b * b == (1000 - a - b) ** 2) - ][0] + ]) if __name__ == "__main__": From 4efe26f08d1169e40fefa8c4295a432174943478 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:41:44 +0300 Subject: [PATCH 10/24] chore: Fix ruff errors --- quantum/ripple_adder_classic.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/quantum/ripple_adder_classic.py b/quantum/ripple_adder_classic.py index b604395bc583..2284141ccac2 100644 --- a/quantum/ripple_adder_classic.py +++ b/quantum/ripple_adder_classic.py @@ -107,7 +107,7 @@ def ripple_adder( res = qiskit.execute(circuit, backend, shots=1).result() # The result is in binary. Convert it back to int - return int(list(res.get_counts())[0], 2) + return int(next(iter(res.get_counts())), 2) if __name__ == "__main__": From d73ae1765ac88a47c87620ddae21792fb9c12442 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:42:50 +0300 Subject: [PATCH 11/24] chore: Fix ruff errors --- strings/min_cost_string_conversion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/min_cost_string_conversion.py b/strings/min_cost_string_conversion.py index 089c2532f900..7bd2e4f90060 100644 --- a/strings/min_cost_string_conversion.py +++ b/strings/min_cost_string_conversion.py @@ -61,7 +61,7 @@ def assemble_transformation(ops: list[list[str]], i: int, j: int) -> list[str]: if i == 0 and j == 0: return [] else: - if ops[i][j][0] == "C" or ops[i][j][0] == "R": + if ops[i][j][0] in ("C", "R"): seq = assemble_transformation(ops, i - 1, j - 1) seq.append(ops[i][j]) return seq From 340248f4dba443e3a26deefd3a8e1c8ea0123453 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:44:47 +0300 Subject: [PATCH 12/24] chore: Fix ruff errors --- web_programming/convert_number_to_words.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/web_programming/convert_number_to_words.py b/web_programming/convert_number_to_words.py index 1e293df9660c..dac9e3e38e7c 100644 --- a/web_programming/convert_number_to_words.py +++ b/web_programming/convert_number_to_words.py @@ -90,9 +90,7 @@ def convert(number: int) -> str: else: addition = "" if counter in placevalue: - if current == 0 and ((temp_num % 100) // 10) == 0: - addition = "" - else: + if current != 0 and ((temp_num % 100) // 10) != 0: addition = placevalue[counter] if ((temp_num % 100) // 10) == 1: words = teens[current] + addition + words From e336a60ee3cefa82ea957f8cb797714bd8abe559 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:46:05 +0300 Subject: [PATCH 13/24] chore: Fix ruff errors --- data_structures/binary_tree/red_black_tree.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/data_structures/binary_tree/red_black_tree.py b/data_structures/binary_tree/red_black_tree.py index 3ebc8d63939b..4ebe0e927ca0 100644 --- a/data_structures/binary_tree/red_black_tree.py +++ b/data_structures/binary_tree/red_black_tree.py @@ -152,7 +152,7 @@ def _insert_repair(self) -> None: self.grandparent.color = 1 self.grandparent._insert_repair() - def remove(self, label: int) -> RedBlackTree: + def remove(self, label: int) -> RedBlackTree: # noqa: PLR0912 """Remove label from this tree.""" if self.label == label: if self.left and self.right: From cd15fa4096d08fc5af1d181226c8f7c6e679e3b3 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 22 Jul 2023 08:47:27 +0000 Subject: [PATCH 14/24] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- project_euler/problem_009/sol3.py | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/project_euler/problem_009/sol3.py b/project_euler/problem_009/sol3.py index d4fe2bb03d09..d44d5ca779fc 100644 --- a/project_euler/problem_009/sol3.py +++ b/project_euler/problem_009/sol3.py @@ -28,12 +28,14 @@ def solution() -> int: 31875000 """ - return next([ - a * b * (1000 - a - b) - for a in range(1, 999) - for b in range(a, 999) - if (a * a + b * b == (1000 - a - b) ** 2) - ]) + return next( + [ + a * b * (1000 - a - b) + for a in range(1, 999) + for b in range(a, 999) + if (a * a + b * b == (1000 - a - b) ** 2) + ] + ) if __name__ == "__main__": From 121eae1e087f007534bb22d004a776bd32b34415 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:51:00 +0300 Subject: [PATCH 15/24] chore: Fix ruff errors --- graphs/directed_and_undirected_(weighted)_graph.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphs/directed_and_undirected_(weighted)_graph.py b/graphs/directed_and_undirected_(weighted)_graph.py index 7b1d1a5e5699..8ca645fdace8 100644 --- a/graphs/directed_and_undirected_(weighted)_graph.py +++ b/graphs/directed_and_undirected_(weighted)_graph.py @@ -305,7 +305,7 @@ def dfs(self, s=-2, d=-1): stack = [] visited = [] if s == -2: - s = next(iter(self.graph) + s = next(iter(self.graph)) stack.append(s) visited.append(s) ss = s From 6b41a2510939d4d293087187322777963abbb43d Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 11:53:00 +0300 Subject: [PATCH 16/24] chore: Fix ruff errors --- project_euler/problem_009/sol3.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/project_euler/problem_009/sol3.py b/project_euler/problem_009/sol3.py index d44d5ca779fc..3516ffbecf81 100644 --- a/project_euler/problem_009/sol3.py +++ b/project_euler/problem_009/sol3.py @@ -28,14 +28,14 @@ def solution() -> int: 31875000 """ - return next( + return next(iter( [ a * b * (1000 - a - b) for a in range(1, 999) for b in range(a, 999) if (a * a + b * b == (1000 - a - b) ** 2) ] - ) + )) if __name__ == "__main__": From 8dd3c35d2dde8f358e62dd86cdff0a97a7c5793a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Sat, 22 Jul 2023 08:53:34 +0000 Subject: [PATCH 17/24] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- project_euler/problem_009/sol3.py | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/project_euler/problem_009/sol3.py b/project_euler/problem_009/sol3.py index 3516ffbecf81..37340d3063bb 100644 --- a/project_euler/problem_009/sol3.py +++ b/project_euler/problem_009/sol3.py @@ -28,14 +28,16 @@ def solution() -> int: 31875000 """ - return next(iter( - [ - a * b * (1000 - a - b) - for a in range(1, 999) - for b in range(a, 999) - if (a * a + b * b == (1000 - a - b) ** 2) - ] - )) + return next( + iter( + [ + a * b * (1000 - a - b) + for a in range(1, 999) + for b in range(a, 999) + if (a * a + b * b == (1000 - a - b) ** 2) + ] + ) + ) if __name__ == "__main__": From 95118455818f20bb2d0537f3dfaaf276af27f6ce Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 12:30:18 +0300 Subject: [PATCH 18/24] Update cellular_automata/game_of_life.py Co-authored-by: Christian Clauss --- cellular_automata/game_of_life.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cellular_automata/game_of_life.py b/cellular_automata/game_of_life.py index da5884e51375..b69afdce03eb 100644 --- a/cellular_automata/game_of_life.py +++ b/cellular_automata/game_of_life.py @@ -98,7 +98,7 @@ def __judge_point(pt: bool, neighbours: list[list[bool]]) -> bool: if pt: if alive < 2: state = False - elif alive in (2, 3): + elif alive in {2, 3}: state = True elif alive > 3: state = False From dc257569faa9d482d08d9d1b41d15efbbd5b05a6 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 12:35:06 +0300 Subject: [PATCH 19/24] chore: Update ruff version in pre-commit --- .pre-commit-config.yaml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 13b955dd374f..5adf12cc70c5 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,7 @@ repos: - id: auto-walrus - repo: https://github.com/astral-sh/ruff-pre-commit - rev: v0.0.278 + rev: v0.0.280 hooks: - id: ruff From ebc3c290b22220745526cc44e3e2ca2a43f2cf9d Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 12:35:55 +0300 Subject: [PATCH 20/24] chore: Fix ruff errors --- divide_and_conquer/convex_hull.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/divide_and_conquer/convex_hull.py b/divide_and_conquer/convex_hull.py index da92c20ec0f0..1d1bf301def5 100644 --- a/divide_and_conquer/convex_hull.py +++ b/divide_and_conquer/convex_hull.py @@ -266,7 +266,7 @@ def convex_hull_bf(points: list[Point]) -> list[Point]: points_left_of_ij = points_right_of_ij = False ij_part_of_convex_hull = True for k in range(n): - if k not in (i, j): + if k not in {i, j}: det_k = _det(points[i], points[j], points[k]) if det_k > 0: From 514d664deb566030d5abd4e026f4a5c6f2762202 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 12:37:10 +0300 Subject: [PATCH 21/24] Update edmonds_karp_multiple_source_and_sink.py --- graphs/edmonds_karp_multiple_source_and_sink.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/graphs/edmonds_karp_multiple_source_and_sink.py b/graphs/edmonds_karp_multiple_source_and_sink.py index e58fdfeb37ac..5c774f4b812b 100644 --- a/graphs/edmonds_karp_multiple_source_and_sink.py +++ b/graphs/edmonds_karp_multiple_source_and_sink.py @@ -113,7 +113,7 @@ def _algorithm(self): vertices_list = [ i for i in range(self.verticies_count) - if i not in (self.source_index, self.sink_index) + if i not in {self.source_index, self.sink_index} ] # move through list From a72f94d0be605122f4f098f857c15b8aeddb7e02 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 12:37:49 +0300 Subject: [PATCH 22/24] Update factorial.py --- maths/factorial.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/factorial.py b/maths/factorial.py index 9c0e25973165..18cacdef9b1f 100644 --- a/maths/factorial.py +++ b/maths/factorial.py @@ -55,7 +55,7 @@ def factorial_recursive(n: int) -> int: raise ValueError("factorial() only accepts integral values") if n < 0: raise ValueError("factorial() not defined for negative values") - return 1 if n in (0, 1) else n * factorial(n - 1) + return 1 if n in {0, 1} else n * factorial(n - 1) if __name__ == "__main__": From 2bd6c4940771c708c2cb28ab6321dc938223a077 Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 12:38:23 +0300 Subject: [PATCH 23/24] Update primelib.py --- maths/primelib.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/maths/primelib.py b/maths/primelib.py index d93635682f83..28b5aee9dcc8 100644 --- a/maths/primelib.py +++ b/maths/primelib.py @@ -154,7 +154,7 @@ def prime_factorization(number): quotient = number - if number in (0, 1): + if number in {0, 1}: ans.append(number) # if 'number' not prime then builds the prime factorization of 'number' From 41dd207208bce2bab5c2fa42552b002c152c232a Mon Sep 17 00:00:00 2001 From: Caeden Perelli-Harris Date: Sat, 22 Jul 2023 12:38:54 +0300 Subject: [PATCH 24/24] Update min_cost_string_conversion.py --- strings/min_cost_string_conversion.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/strings/min_cost_string_conversion.py b/strings/min_cost_string_conversion.py index 7bd2e4f90060..0fad0b88c370 100644 --- a/strings/min_cost_string_conversion.py +++ b/strings/min_cost_string_conversion.py @@ -61,7 +61,7 @@ def assemble_transformation(ops: list[list[str]], i: int, j: int) -> list[str]: if i == 0 and j == 0: return [] else: - if ops[i][j][0] in ("C", "R"): + if ops[i][j][0] in {"C", "R"}: seq = assemble_transformation(ops, i - 1, j - 1) seq.append(ops[i][j]) return seq