]>
cvs.zerfleddert.de Git - micropolis/blob - src/tclx/tcllib/8queens.tcl
4 # by Karl Lehenbauer, 23 Nov 1990
6 #-----------------------------------------------------------------------------
7 # $Id: 8queens.tcl,v 2.0 1992/10/16 04:51:36 markd Rel $
8 #-----------------------------------------------------------------------------
10 proc none_attacking
{rank position
} {
13 set j
$queens([expr {$rank - $i}])
14 if {($j==$position-$i) ||
($j==$position) ||
($j==$position+$i)} {
23 echo
$queens(1) $queens(2) $queens(3) $queens(4) $queens(5) $queens(6) $queens(7) $queens(8)
26 proc x8queens
{rank
} {
30 if [none_attacking
$rank $i] {
33 x8queens
[expr $rank+1]
46 global interactiveSession
47 if !$interactiveSession 8queens