File: queens

package info (click to toggle)
scheme9 2025.08.12-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 4,080 kB
  • sloc: lisp: 16,752; ansic: 11,869; sh: 806; makefile: 237; sed: 6
file content (15 lines) | stat: -rw-r--r-- 384 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
S9 LIB  (queens n)  ==>  list

Solve the N-Queens puzzle using AMK. All solutions for the
given board size will be returned, where the offset in each
list is an X position on the board and the value at that
offset is the corresponding Y position. E.g., the board
(2 0 3 1) would look like this:

. . & . 3
& . . . 2
. . . & 1
. & . . 0
0 1 2 3

(queens 4)  ==>  ((2 0 3 1) (1 3 0 2))