diff --git a/backtracking/all_permutations.py b/backtracking/all_permutations.py index f376e6fa0945..9c722b43c296 100644 --- a/backtracking/all_permutations.py +++ b/backtracking/all_permutations.py @@ -74,15 +74,15 @@ def create_state_space_tree( index_used[i] = False -""" -remove the comment to take an input from the user - -print("Enter the elements") -sequence = list(map(int, input().split())) -""" - -sequence: list[int | str] = [3, 1, 2, 4] -generate_all_permutations(sequence) - -sequence_2: list[int | str] = ["A", "B", "C"] -generate_all_permutations(sequence_2) +if __name__ == "__main__": + # --- Example 1: Integers --- + print("--- Permutations for [3, 1, 2, 4] ---") + sequence: list[int | str] = [3, 1, 2, 4] + generate_all_permutations(sequence) + + print("\n" + "=" * 30 + "\n") + + # --- Example 2: Characters --- + print("--- Permutations for ['A', 'B', 'C'] ---") + sequence_2: list[int | str] = ["A", "B", "C"] + generate_all_permutations(sequence_2)