in reply to Challenge: Box Blackout

The following generates the solution using brute force. It works for 3x3, but takes forever for 10x10. It hasn't finished running for 10x10 yet, so I don't know if it gives a sensible answer.
use strict; use warnings; use re 'eval'; my $size = 3; my $sizem1 = $size-1; my $sizem2 = $size-2; my $grid = 'X' x ($size*$size); my %solution; my @todo = $grid; while (@todo) { local $_ = pop(@todo); next if $solution{$_}++; # Row /^((?:.{$size})*X{0,$size})X(X{0,$sizem1}(?:.{$size})*)$ (?{ push(@todo, "$1_$2") })(?=\Z=)/x; # Col /^(.{0,$sizem1}(?:X.{$sizem1})*)X((?:.{$sizem1}X)*.{0,$sizem1})$ (?{ push(@todo, "$1_$2") })(?=\Z=)/x; # Diag \ /^((?:X.{$size})*)X((?:.{$size}X)*)$ (?{ push(@todo, "$1_$2") })(?=\Z=)/x; # Diag / /^(.{$sizem1}(?:X.{$sizem2})*)X((?:.{$sizem2}X)*.{$sizem1})$ (?{ push(@todo, "$1_$2") })(?=\Z=)/x; } my @solutions = map substr($_, 5), sort { $b cmp $a } map sprintf('%05d%s', 0+/_/g, $_), keys %solution; foreach my $solution (@solutions) { print map "$_\n\n", join "\n", map /(...)/g, $solution; }

A mirror image of a solution is counted as a solution.