-
-
Notifications
You must be signed in to change notification settings - Fork 545
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
Correct Queen Attack test values #1504
Conversation
I disagree. A solution that uses the difference of the positions would be testing against "third diagonal" Not to say that such solutions are quite optimal, but they are completely valid, if implemented correctly. Keeping both cases ensures that solutions like this handle both edge cases. |
My apologies; I misread your initial statement (not enough coffee yet). However, I do stand by my assertion that there needs to be a case where the second queen is closer to the bottom-left corner of the board than the first. What about switching the new suggested values (i.e. |
Makes sense; updated. |
Co-Authored-By: TeaDrivenDev <[email protected]>
🚀 lgtm and with 3 approvals I think this is good to go. |
There is a flaw in the Queen Attack test suite that causes the most naive implementation that makes the tests green to actually be incomplete.
The tests for "third diagonal" (2, 2 and 1, 1) and "fourth diagonal" (2, 2 and 5, 5) actually test for the same diagonal (A1 to H8) and are fulfilled by the condition
row1 = column1 && row2 = column2
. This does not cover the parallels of that diagonal, however, so if there was an additional test for (0, 6) and (1, 7) that would still be red.This is fixed by replacing the redundant "fourth diagonal" test values with said (0, 6) and (1, 7), which will require the condition to be changed to
row1 - column1 = row2 - column2
, thus covering all diagonals from "top left" to "bottom right".That said, the tests for "first diagonal" and "second diagonal" are actually also covering the same diagonal (the one from "bottom left" to "top right" that includes 2, 2), but this PR is not addressing that.