We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 1640999 commit 4154181Copy full SHA for 4154181
1 file changed
backtracking/all_permutations.py
@@ -93,7 +93,13 @@ def create_state_space_tree(
93
raw = input().split()
94
if len(raw) > MAX_SEQUENCE_LENGTH:
95
raise ValueError(f"Input sequence too long (max {MAX_SEQUENCE_LENGTH} elements).")
96
-sequence: list[int | str] = raw
+# Try to convert each token to int; keep as str if conversion is not possible
97
+sequence: list[int | str] = []
98
+for token in raw:
99
+ try:
100
+ sequence.append(int(token))
101
+ except ValueError:
102
+ sequence.append(token)
103
generate_all_permutations(sequence)
104
"""
105
0 commit comments