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:
Christian Clauss
2021-09-07 13:37:03 +02:00
committed by GitHub
parent 5d5831bdd0
commit cecf43d648
142 changed files with 523 additions and 530 deletions

View File

@ -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)