(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 |
|||
01-13-2022, 05:50 PM
Post: #2
|
|||
|
|||
RE: (HP-65) N-Queens
(01-09-2022 07:45 PM)Dave Britten Wrote: 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'm clever enough to shoehorn it into the HP 65's 100 steps of program memory. Thanks to you Dave Britten ! I like this sort of challenge ! Have a happy new year and keep you safe ! Laurent |
|||
01-13-2022, 10:49 PM
Post: #3
|
|||
|
|||
RE: (HP-65) N-Queens
(01-13-2022 05:50 PM)Nihotte(lma) Wrote:(01-09-2022 07:45 PM)Dave Britten Wrote: 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'm clever enough to shoehorn it into the HP 65's 100 steps of program memory. Thanks Laurent, you as well! I've been thinking over whether I can cram this onto the HP 25, but it's not coming to me so far. If anybody can manage that, I'll be really impressed... |
|||
03-02-2022, 01:21 AM
Post: #4
|
|||
|
|||
RE: (HP-65) N-Queens
(01-13-2022 10:49 PM)Dave Britten Wrote: I've been thinking over whether I can cram this onto the HP 25, but it's not coming to me so far. If anybody can manage that, I'll be really impressed... Cf. (25) N-Queens Cheers Thomas |
|||
« Next Oldest | Next Newest »
|
User(s) browsing this thread: 1 Guest(s)