-
Notifications
You must be signed in to change notification settings - Fork 20.3k
Fix MiniMaxAlgorithm setScores bug and add comprehensive tests #6566
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
yashsaha555
wants to merge
6
commits into
TheAlgorithms:master
Choose a base branch
from
yashsaha555:fix-minimax-algorithm
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Fix MiniMaxAlgorithm setScores bug and add comprehensive tests #6566
yashsaha555
wants to merge
6
commits into
TheAlgorithms:master
from
yashsaha555:fix-minimax-algorithm
+197
−4
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
- Fix bug in setScores method where scores.length % 1 == 0 always returned true - Add isPowerOfTwo helper method to properly validate array length - Add comprehensive unit tests covering edge cases and algorithm correctness - Tests include validation for power of 2 check, minimax logic, and error handling Fixes issue with incorrect validation logic in MiniMaxAlgorithm.setScores()
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## master #6566 +/- ##
============================================
+ Coverage 75.19% 75.36% +0.16%
- Complexity 5614 5634 +20
============================================
Files 690 690
Lines 19407 19409 +2
Branches 3755 3755
============================================
+ Hits 14593 14627 +34
+ Misses 4247 4212 -35
- Partials 567 570 +3 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
- Replace star imports with explicit imports in test file - Remove trailing whitespaces from all lines - Add proper file ending newline - Improve setScores method to handle edge cases properly - Use direct bit manipulation for power-of-2 check as suggested - Ensure error message is printed and scores remain unchanged for invalid input All Checkstyle violations resolved and tests pass successfully.
- Fix Checkstyle violation: NewlineAtEndOfFile - Ensure file ends with proper newline character - All tests continue to pass successfully
- Replace inline bit manipulation with isPowerOfTwo method call - Resolves PMD UnusedPrivateMethod violation - Maintains same validation logic and error handling - All tests continue to pass successfully
DenizAltunkapan
approved these changes
Oct 1, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Thanks
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Issue
Fixes #6563
Fixes issue with incorrect validation logic in MiniMaxAlgorithm.setScores()
clang-format -i --style=file path/to/your/file.java