Peaceful chess queen armies: Difference between revisions

m
(Added Perl 6 example)
Line 1,826:
state $solution = False;
 
# logic of 'attack' regex: queen ( ... paths between queens containing only empty squares ... ) queen of other color
once {
my %Q = 'WBBW'.comb; # return the queen of alternate color
Line 1,843:
}
 
# passreturn already-foundfirst result backfound up(omit thethis stackline to get last result found)
return $solution if $solution;
 
Line 1,856:
while $board ~~ m:nth(++$cnt)/<[◦•]>/;
 
return $solution;
# pass already-found result back up the stack
return $solution;
}
 
Line 1,864 ⟶ 1,863:
my $board = ($empty-square x $n**2).comb.rotor($n)>>.join[^$n].join: "\n";
 
my $solution = place( $board, $n, $m, $empty-square );
 
say $solution
2,392

edits