(HP-65) N-Queens
|
01-09-2022, 07:45 PM
Post: #1
|
|||
|
|||
(HP-65) N-Queens
For a long time, I wasn't sure N-Queens with up to an 8x8 board was possible on the HP 65, owing to the lack of indirect addressing. I was reading Mathematical Recreations for the Programmable Calculator (by Dean Hoffman and Lee Mohler, Hayden Book Company 1982) this morning, and found a chapter discussing the problem. They have flowcharts of a relatively simple algorithm that doesn't require a calculator with indirect addressing. I'm not clever enough to have come up with it on my own, but I'm clever enough to shoehorn it into the HP 65's 100 steps of program memory.
To use: load the program, press f REG, enter n into stack register X (so 8 for an 8x8 board), and press A to start searching. With an 8x8 board, the program will run for about 50 minutes and stop with the first solution in the display, in the format of 8 digits showing the column number of the queen in each row. You can press R/S to continue searching for the next solution. When all solutions have been found, the program will stop with 0 in the display. Note that this program abuses subroutines, treating them as one-step GTO instructions to save space. There are no RTNs, and the program pointers will be a little goofy after completion of the program, so you may need to press RTN or reload the program if you want to run it again with a different board size. Code: STO 5 33 05 Flowcharts from Mathematical Recreations for the Programmable Calculator, on which this program is based: Main Program Flowchart Attack Checking Procedure Flowchart |
|||
« Next Oldest | Next Newest »
|
Messages In This Thread |
(HP-65) N-Queens - Dave Britten - 01-09-2022 07:45 PM
RE: (HP-65) N-Queens - Nihotte(lma) - 01-13-2022, 05:50 PM
RE: (HP-65) N-Queens - Dave Britten - 01-13-2022, 10:49 PM
RE: (HP-65) N-Queens - Thomas Klemm - 03-02-2022, 01:21 AM
RE: (HP-65) N-Queens - Dave Britten - 06-25-2023, 01:43 PM
RE: (HP-65) N-Queens - Steve Simpkin - 06-25-2023, 05:54 PM
RE: (HP-65) N-Queens - Steve Simpkin - 06-26-2023, 05:47 AM
|
User(s) browsing this thread: 1 Guest(s)