Post Reply 
About calculator benchmark (8 queens) and fast devices. MS challenge #2
12-26-2018, 04:19 AM
Post: #22
RE: About calculator benchmark (8 queens) and fast devices. MS challenge #2
From Calculator Benchmark
0.130 FX-CG50 MicroPython / OS 3.20
Code:

MicroPython -------------

def nqueens(): for i in range(100): a = [0] * 9 r = 8 s = 0 x = 0 y = 0 t = 0 while True: x += 1 a[x] = r while True: s += 1 y = x while y>1: y -= 1 t = a[x]-a[y] if t==0 or x-y==abs(t): y=0 a[x] -= 1 while a[x]==0: x -= 1 a[x] -= 1 if y==1: break; if x==r: break; print(s)


This seems a remarkably fast result.
Does it really outperform the prime D ?

0.158 HP-Prime Formula / List / G2 / HW.D
Code:
EXPORT NQUEENS() BEGIN R:=8; L1:=MAKELIST(0,X,1,R,1); S:=0; X:=0; REPEAT X:=X+1; L1(X):=R; REPEAT S:=S+1; Y:=X; WHILE Y>1 DO Y:=Y-1; T:=L1(X)-L1(Y); IF T==0 OR X-Y==ABS(T) THEN Y:=0; L1(X):=L1(X)-1; WHILE L1(X)==0 DO X:=X-1; L1(X):=L1(X)-1; END; END; END; UNTIL Y==1 END; UNTIL X==R END; S; END;
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: About calculator benchmark (8 queens) and fast devices. MS challenge #2 - Stevetuc - 12-26-2018 04:19 AM



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