Runs the nqueens benchmark found at https://www.hpmuseum.org/cgi-sys/cgiwrap/hpmuseum/articles.cgi?read=700
from time import * def nqueens(n=100): t0 = monotonic() for i in range(n): 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) t0=(monotonic()-t0)/n print("Time: {0:.3f} seconds".format(t0))