for my $row (1 .. $row_size) {
for my $column (1 .. $column_size) {
...
}
}
####
use List::Util qw{ shuffle };
# ...
for my $row (shuffle(1 .. $row_size)) {
for my $column (shuffle(1 .. $column_size)) {
...
}
}
##
##
#!/usr/bin/perl
use warnings;
use strict;
use feature qw{ say };
local $SIG{ALRM} = sub { system killall => '1a1.pl'; die };
for my $r (2 .. 20) {
SIZE:
for my $c (2 .. 20) {
open my $OUT, '>', 'x1' or die $!;
say {$OUT} 1;
say {$OUT} "$r $c";
close $OUT;
for my $rand (1 .. 100) {
print "$r $c $rand\n";
eval {
alarm 1;
0 == system '1a1.pl', $rand, 'x1';
} and do {
print "$r $c $rand\n";
next SIZE
};
}
say "NOT FOUND";
}
}
##
##
my %srand = ('3 16' => 2,
'4 10' => 2,
'4 17' => 3,
'4 19' => 3,
'5 15' => 5,
# ...
);
##
##
srand ($srand{"$rows $columns"} || 1);
$grid = solve($rows, $columns);