* Fix mypy in #2684

* fix pre-commit
This commit is contained in:
John Law
2020-11-30 01:30:31 +08:00
committed by GitHub
parent 0febbd397e
commit 25164bb638
5 changed files with 34 additions and 22 deletions

View File

@ -5,14 +5,18 @@
Time complexity: O(n! * n),
where n denotes the length of the given sequence.
"""
from typing import List, Union
def generate_all_permutations(sequence: [int]) -> None:
def generate_all_permutations(sequence: List[Union[int, str]]) -> None:
create_state_space_tree(sequence, [], 0, [0 for i in range(len(sequence))])
def create_state_space_tree(
sequence: [int], current_sequence: [int], index: int, index_used: int
sequence: List[Union[int, str]],
current_sequence: List[Union[int, str]],
index: int,
index_used: List[int],
) -> None:
"""
Creates a state space tree to iterate through each branch using DFS.
@ -40,8 +44,8 @@ print("Enter the elements")
sequence = list(map(int, input().split()))
"""
sequence = [3, 1, 2, 4]
sequence: List[Union[int, str]] = [3, 1, 2, 4]
generate_all_permutations(sequence)
sequence = ["A", "B", "C"]
generate_all_permutations(sequence)
sequence_2: List[Union[int, str]] = ["A", "B", "C"]
generate_all_permutations(sequence_2)