Menu

[r246]: / XQUEENS.MPL  Maximize  Restore  History

Download this file

19 lines (12 with data), 360 Bytes

// QUEENS - CONVERTED FROM BCPL

##LIBHDR

COUNT=0 ALL=0

TRY(LD,ROW,RD;POSS,P) [
  ROW==ALL ? ++COUNT : [ POSS=ALL&(-1^(LD|ROW|RD));
    POSS @ [ POSS-=(P=POSS&-POSS); TRY(<<(LD+P),ROW+P,>>(RD+P)) ]
]]

.(;I) [
  ALL=1; I=0; ++I<=12 @ [ COUNT=0; TRY(0,0,0);
    WRITEF("%I2-QUEENS PROBLEM HAS %I5 SOLUTIONS*N",I,COUNT);
    ALL=2*ALL+1
]]

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.