(16C) 15-Puzzle Solvability Checker
|
02-03-2020, 02:10 PM
Post: #1
|
|||
|
|||
(16C) 15-Puzzle Solvability Checker
Reference: https://www.geeksforgeeks.org/check-inst...-solvable/
In a nutshell, a configuration of the 15 puzzle is solvable if the number of inversions plus the row number of the blank space (starting at 1 and counting from the top) is an even number. This is based on the program Don Shepherd wrote for the 65, which uses bit flag techniques to track which tiles have been "seen". Since the 16C has functions for directly setting and counting bits, it seemed like an ideal platform to implement this solution. It's longer than the 65 version, but mostly because I wasted a bunch of steps displaying a crude message using hex mode when the program finishes. https://www.hpmuseum.org/forum/thread-7362.html The 16C version must be run with WSIZE 16 or greater. Complement mode shouldn't matter. Usage Enter the row number containing the blank space, with row 1 being the top row, and row 4 being the bottom, and press GSB A to initialize the program. Enter the tiles one by one, starting from the top row, and going left to right across each row. Press R/S after each tile entry. Skip over the blank space (i.e. only make 15 entries total). And if your 15 puzzle happens to be hexadecimal, you can switch to hex mode and use 1-F to make entries. The display will show the total number of inversions so far after each entry. After entering all 15 tiles, the program will briefly display either "GOOD" or "BAD" to indicate if the puzzle can be solved, and leave the final inversion count in the X register. Code: 001 LBL A 43,22,A |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)