tasks a-s
This commit is contained in:
parent
47bf37c096
commit
b83f433714
12433 changed files with 156208 additions and 123 deletions
30
Task/N-queens-problem/BCPL/n-queens-problem-1.bcpl
Normal file
30
Task/N-queens-problem/BCPL/n-queens-problem-1.bcpl
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
// 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
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue