Post Reply 
N-Queens results on Casio calculators
08-23-2024, 08:59 AM (This post was last modified: 08-23-2024 09:23 AM by Hlib.)
Post: #15
RE: N-Queens results on Casio calculators
I offer you a faster CASIO-BASIC(structured) program. It does not look as neat as MicroPython code, but it allows you to get an increase in speed in the range of 17 ... 28% for some CASIO models.
This code is not suitable for CBASIC, as well as for calculators from the old generation (e.g. FX-7450G+/9700GE/9750G+).

Code:

8➝R : {R,1}->Dim Mat A
0->S : 0->X : 1->Z
While Z=0 Or X<>R
  If Z
    Then Isz X : R->L
      Else Dsz X : Mat A[X,1]-1->L
        If X=0
          Then Break
        IfEnd
  IfEnd
  For L->Y To 1 Step -1
    For 1->Z To X-1
    Y-Mat A[Z,1]->T
      If T=0 Or X-Z=Abs T
        Then 0->Z : Break
      IfEnd
    Next : Isz S
      If Z
        Then Y->Mat A[X,1] : Break
      IfEnd
  Next
WhileEnd
S

t=22.5_sec vs 29_sec, FX-9750GII (SH3, OS 2.0), +22% increase in speed.
t=42_sec vs 58.7_sec, FX-9860GII-2 (SH4, OS 2.09), +28%, without USB.
t=103_sec (1:43) vs 125_sec (2:05), AFX-2.0+, GRAPH-100+, +17%.

I don`t use lists in the above models because with the list-type variables the results are not stable. The more lists are defined in these calculators, the lower the speed of operations with list items.
A standard algorithm was used.
S=876, result is Mat A=[[8][4][1][3][6][2][7][5]]
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: N-Queens results on Casio calculators - Hlib - 08-23-2024 08:59 AM



User(s) browsing this thread: 1 Guest(s)