mmm perl
Posted 09-08-2009 at 08:49 AM by estabroo
Code:
$e = "0";
$v = "5";
@odd = (
[\$w, \$x, \$v, \$y, \$z],
[\$w, \$x, \$v, \$z, \$y],
[\$w, \$y, \$v, \$x, \$z],
[\$w, \$y, \$v, \$z, \$x],
[\$w, \$z, \$v, \$x, \$y],
[\$w, \$z, \$v, \$y, \$x],
);
@even = (
[\$a, \$b, \$c, \$d, \$e],
[\$a, \$b, \$d, \$c, \$e],
[\$a, \$c, \$b, \$d, \$e],
[\$a, \$c, \$d, \$b, \$e],
[\$a, \$d, \$b, \$c, \$e],
[\$a, \$d, \$c, \$b, \$e],
);
@on = ("1", "3", "7", "9");
@en = ("2", "4", "6", "8");
$count = 0;
for ($i=0; $i < 4; $i++) {
$w = $on[(0+$i)%4];
$x = $on[(1+$i)%4];
$y = $on[(2+$i)%4];
$z = $on[(3+$i)%4];
for ($j=0; $j < 6; $j++) {
for ($k=0; $k < 4; $k++) {
$a = $en[(0+$k)%4];
$b = $en[(1+$k)%4];
$c = $en[(2+$k)%4];
$d = $en[(3+$k)%4];
for ($l=0; $l < 6; $l++) {
$num = "";
$fail = 0;
for ($m=0; $m < 5; $m++) {
$num .= ${$odd[$j][$m]};
if ((int(($num+0)/($m*2+1))*($m*2+1)) != ($num+0)) {
# print "odd: $num -- $m\n";
$fail = 1;
}
$num .= ${$even[$l][$m]};
if ((int(($num+0)/($m*2+2))*($m*2+2)) != ($num+0)) {
# print "even: $num -- $m\n";
$fail = 1;
}
}
if ($fail == 0) {
print "num: $num\n";
$count++;
}
}
}
}
}
print "total numbers matching: $count\n";









