Summary of What Needs to be Done
The is_solvable function in games/Number-Sliding-Puzzle/Number-Sliding-Puzzle.py computes blank_row_from_bottom incorrectly. It uses 3 - blank_row_from_top which gives wrong values for the bottom row. The formula for a 3x3 sliding puzzle is: solvable if (inversions + blank_row_from_bottom) is odd, where blank_row_from_bottom should be 1 for bottom, 2 for middle, 3 for top.
Changes that Need to be Made
- Change
blank_row_from_bottom = 3 - blank_row_from_top to blank_row_from_bottom = 3 - (blank_idx // 3) or equivalently blank_row_from_bottom = blank_row_from_top + 1
Impact that it would Provide
- Fixes incorrect solvability checks for certain 8-puzzle configurations
- Prevents valid puzzles from being incorrectly rejected as unsolvable
Note: Please assign this issue to the tmdeveloper007 account.
Summary of What Needs to be Done
The
is_solvablefunction ingames/Number-Sliding-Puzzle/Number-Sliding-Puzzle.pycomputesblank_row_from_bottomincorrectly. It uses3 - blank_row_from_topwhich gives wrong values for the bottom row. The formula for a 3x3 sliding puzzle is: solvable if (inversions + blank_row_from_bottom) is odd, where blank_row_from_bottom should be 1 for bottom, 2 for middle, 3 for top.Changes that Need to be Made
blank_row_from_bottom = 3 - blank_row_from_toptoblank_row_from_bottom = 3 - (blank_idx // 3)or equivalentlyblank_row_from_bottom = blank_row_from_top + 1Impact that it would Provide
Note: Please assign this issue to the
tmdeveloper007account.