LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Blogs > estabroo
User Name
Password

Notices


Rate this Entry

mmm perl

Posted 09-08-2009 at 07: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";
Posted in Uncategorized
Views 838 Comments 0
« Prev     Main     Next »

  



All times are GMT -5. The time now is 10:07 AM.

Main Menu
Advertisement
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration