mirror of
https://github.com/TheAlgorithms/Python.git
synced 2025-07-05 09:21:13 +08:00
Pyupgrade to Python 3.9 (#4718)
* Pyupgrade to Python 3.9 * updating DIRECTORY.md Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
This commit is contained in:
@ -5,18 +5,18 @@
|
||||
Time complexity: O(n! * n),
|
||||
where n denotes the length of the given sequence.
|
||||
"""
|
||||
from typing import List, Union
|
||||
from __future__ import annotations
|
||||
|
||||
|
||||
def generate_all_permutations(sequence: List[Union[int, str]]) -> None:
|
||||
def generate_all_permutations(sequence: list[int | str]) -> None:
|
||||
create_state_space_tree(sequence, [], 0, [0 for i in range(len(sequence))])
|
||||
|
||||
|
||||
def create_state_space_tree(
|
||||
sequence: List[Union[int, str]],
|
||||
current_sequence: List[Union[int, str]],
|
||||
sequence: list[int | str],
|
||||
current_sequence: list[int | str],
|
||||
index: int,
|
||||
index_used: List[int],
|
||||
index_used: list[int],
|
||||
) -> None:
|
||||
"""
|
||||
Creates a state space tree to iterate through each branch using DFS.
|
||||
@ -44,8 +44,8 @@ print("Enter the elements")
|
||||
sequence = list(map(int, input().split()))
|
||||
"""
|
||||
|
||||
sequence: List[Union[int, str]] = [3, 1, 2, 4]
|
||||
sequence: list[int | str] = [3, 1, 2, 4]
|
||||
generate_all_permutations(sequence)
|
||||
|
||||
sequence_2: List[Union[int, str]] = ["A", "B", "C"]
|
||||
sequence_2: list[int | str] = ["A", "B", "C"]
|
||||
generate_all_permutations(sequence_2)
|
||||
|
Reference in New Issue
Block a user