Add static typing to backtracking algorithms (#2684)

* Added static typing to backtracking algorithms

* Ran psf/black to fix some minor issues.

* updating DIRECTORY.md

* updating DIRECTORY.md

Co-authored-by: github-actions <${GITHUB_ACTOR}@users.noreply.github.com>
Co-authored-by: John Law <johnlaw.po@gmail.com>
This commit is contained in:
Jenia Dysin
2020-11-29 18:19:50 +02:00
committed by GitHub
parent 5de90aafc7
commit e07766230d
6 changed files with 34 additions and 16 deletions

View File

@ -7,11 +7,13 @@
"""
def generate_all_permutations(sequence):
def generate_all_permutations(sequence: [int]) -> None:
create_state_space_tree(sequence, [], 0, [0 for i in range(len(sequence))])
def create_state_space_tree(sequence, current_sequence, index, index_used):
def create_state_space_tree(
sequence: [int], current_sequence: [int], index: int, index_used: int
) -> None:
"""
Creates a state space tree to iterate through each branch using DFS.
We know that each state has exactly len(sequence) - index children.