[pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci
This commit is contained in:
pre-commit-ci[bot] 2024-10-30 06:04:00 +00:00
parent 841ca3d660
commit 606f962196

View File

@ -1,5 +1,6 @@
from itertools import combinations from itertools import combinations
def permute_recursive(nums: list[int]) -> list[list[int]]: def permute_recursive(nums: list[int]) -> list[list[int]]:
""" """
Return all permutations. Return all permutations.
@ -19,6 +20,7 @@ def permute_recursive(nums: list[int]) -> list[list[int]]:
nums.append(n) nums.append(n)
return result return result
def permute_backtrack(nums: list[int]) -> list[list[int]]: def permute_backtrack(nums: list[int]) -> list[list[int]]:
""" """
Return all permutations of the given list. Return all permutations of the given list.
@ -26,6 +28,7 @@ def permute_backtrack(nums: list[int]) -> list[list[int]]:
>>> permute_backtrack([1, 2, 3]) >>> permute_backtrack([1, 2, 3])
[[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]] [[1, 2, 3], [1, 3, 2], [2, 1, 3], [2, 3, 1], [3, 2, 1], [3, 1, 2]]
""" """
def backtrack(start: int) -> None: def backtrack(start: int) -> None:
if start == len(nums) - 1: if start == len(nums) - 1:
output.append(nums[:]) output.append(nums[:])
@ -39,6 +42,7 @@ def permute_backtrack(nums: list[int]) -> list[list[int]]:
backtrack(0) backtrack(0)
return output return output
def get_combinations(nums: list[int], r: int) -> list[list[int]]: def get_combinations(nums: list[int], r: int) -> list[list[int]]:
""" """
Return all combinations of the given list of length r. Return all combinations of the given list of length r.