Skip to content

Commit 4154181

Browse files
Apply code changes: @orbisai0security can you address code review comm...
1 parent 1640999 commit 4154181

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

backtracking/all_permutations.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,13 @@ def create_state_space_tree(
9393
raw = input().split()
9494
if len(raw) > MAX_SEQUENCE_LENGTH:
9595
raise ValueError(f"Input sequence too long (max {MAX_SEQUENCE_LENGTH} elements).")
96-
sequence: list[int | str] = raw
96+
# 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)
97103
generate_all_permutations(sequence)
98104
"""
99105

0 commit comments

Comments
 (0)