31 lines
759 B
Plaintext
31 lines
759 B
Plaintext
// This can be run using Cintcode BCPL freely available from www.cl.cam.ac.uk/users/mr10.
|
|
|
|
GET "libhdr.h"
|
|
|
|
GLOBAL { count:ug; all }
|
|
|
|
LET try(ld, row, rd) BE TEST row=all
|
|
|
|
THEN count := count + 1
|
|
|
|
ELSE { LET poss = all & ~(ld | row | rd)
|
|
WHILE poss DO
|
|
{ LET p = poss & -poss
|
|
poss := poss - p
|
|
try(ld+p << 1, row+p, rd+p >> 1)
|
|
}
|
|
}
|
|
|
|
LET start() = VALOF
|
|
{ all := 1
|
|
|
|
FOR i = 1 TO 16 DO
|
|
{ count := 0
|
|
try(0, 0, 0)
|
|
writef("Number of solutions to %i2-queens is %i7*n", i, count)
|
|
all := 2*all + 1
|
|
}
|
|
|
|
RESULTIS 0
|
|
}
|