RosettaCodeData/Task/N-queens-problem/Quackery/n-queens-problem.quackery
2023-07-01 13:44:08 -04:00

26 lines
520 B
Text

[ false 0 rot
witheach
[ i + bit
2dup & iff
[ drop dip not
conclude ]
done
| ]
drop ] is l-bishop ( [ --> b )
[ reverse l-bishop ] is r-bishop ( [ --> b )
[ [] swap perms
witheach
[ dup l-bishop iff
drop done
dup r-bishop iff
drop done
nested join ] ] is queens ( n --> [ )
8 queens
dup size echo say " solutions."
cr cr
witheach
[ echo
i^ 1+ 4 mod iff sp else cr ]