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 9af513a commit 9395dddCopy full SHA for 9395ddd
1 file changed
backtracking/minimax.py
@@ -57,6 +57,10 @@ def minimax(
57
if len(scores) == 0:
58
raise ValueError("Scores cannot be empty")
59
60
+ # Validate that scores length is a power of 2
61
+ if len(scores) & (len(scores) - 1) != 0:
62
+ raise ValueError("Number of scores must be a power of 2")
63
+
64
# Base case: If the current depth equals the height of the tree,
65
# return the score of the current node.
66
if depth == height:
@@ -92,4 +96,4 @@ def main() -> None:
92
96
import doctest
93
97
94
98
doctest.testmod()
95
- main()
99
+ main()
0 commit comments