Actually, it's not obfuscated. Just the "design" of the source is fun...
You might give it an input as a file like this:
_6_174_5_ 1_83_56__ 2_______1 8__4_7__6 __6___3__ 7__9_1__4 5_______2 __72_69__ _4_5_8_7_
or just give it no input, as there is a default one. Here it is:
#!/usr/bin/perl -w my @mag= @{&neg}; my$t=["_", 1,2,3,4,5,6, 7,8,9];@mag=([ [9],[6],[@$t],[1 ],[7],[4],[@$t],[5 ],[@$t]],[[1],[@$t], [8],[3],[@$t],[5],[6], [@$t],[@$t]],[[2],[@$t], [@$t],[@$t],[@$t],[@$t],[@ $t],[@$t],[1]],[[8],[@$t],[@ $t],[4],[@$t],[7],[@$t],[@$t], [6]],[[@$t],[@$t],[6],[@$t],[@$t ],[@$t],[3],[@$t],[@$t]],[[7],[@$t ],[@$t],[9 ],[@$t],[1],[@$t],[@$t],[ 4]],[[5],[@$t],[@$t],[@$t],[@$t],[@$t] ,[@$t],[@$t],[2]],[[@$t],[@$t],[7],[2],[ @$t],[6],[9],[@$t],[@$t]],[[@$t],[4],[@$t] ,[5],[@$t],[8],[@$t],[7],[@$t]]);;if(@ARGV){ my ($f ); $f =$ARGV[0];open F, "<",$f;my$j=0;my$ i=0;while(<F>){$i =0;my@li=(m/./g); foreach my $plop( @li){if($plop=~m/ \d/x){$mag[$j][$i ]=[$plop];}else{$ mag[$j][$i]=[@$t];}$i++;}$j++;}}sub neg{my@g; for my$j (0.. 8){ for my$i (0.. 8){ $g[$ j][$ i]=[ "_", 1,2, 3,4, 5,6,7 ,8,9] }}return\@g;}sub printg{ my@grille=@_;foreach my$j(0..8){for my$i( 0..8){if(@{$grille[$ j][$i]}==1){print" ",$grille [$j][$i][0]," "}else{print" _ "}}print"\n" ;}}sub combien{my@grille=@_;my $res;foreach my$j( 0..8){for my$i(0..8){$res++if(@{$grille[$j][$i]}==1) }}return $res;}sub getLine{my($line,$from,$to,@grille) =@_;my@res;for my$i($from..$to){push@res,$grille[$line][ $i][0]if@{$grille[$line][$i]}==1}return\@res;}sub getCol {my($col,$from,$to,@grille)=@_;my@res;foreach my$j($from ..$to){push@res,$grille[$j][$col][0]if@{$grille[$j][$col ]}==1}return\@res;}sub elim1{my@grille=@_;for my$j(0..8) {for my$i(0..8){unless(@{$grille[$j][$i]}==1){my@ajarter =@{getLine($j,0,8,@grille)};push@ajarter,@{getCol($i,0,8 ,@grille)};push@ajarter,["_"];my%hash;@hash{@{$grille[$j ][$i]}} = (1) x @{$grille[$j][$i]}; delete @hash{@ ajarter};if((keys %hash)==2 ){@{++ $grille [$j][$i]}=grep{ /\d/ } keys %hash} else{@{ $grille[$j][$i]}=keys %hash; }}}};; return \@grille}sub getCube{my( $j_,$ i_,@ grille)=@_;my(@res,@I, @J); if ($j_<9) { @J=(6,7,8)}; if ($j_<6) {@J=(3,4,5)};if($j_<3) {@J=(0 ,1,2)}; if($i_<9){@I=(6,7,8)}; if($i_ < 6 ) { @I=(3,4,5)};if ($i_<3) { @I = ( 0 , 1 , 2)};for my$j(@J){for my $i ( @I ) {push @res , $grille[$j] [$i][0 ]if@{$grille[$j][ $i]}==1;}} return\@res;} sub elim2{ my@grille =@_;for my $j(0..8){ foreach my $i(0..8){ unless(@{$ grille[$j ][$i]}==1) {my@ajartr ;@ajartr=@ {getCube($ j, $i , @ grille)} ; push@ajartr ,["_"];my% hash;my@g= @grille;@ hash{@{$g[ $j][$i]}}= (1)x@{$g[$ j][ $i]}; delete@hash {@ajartr}; if((keys% hash)==2){ @{$g[$j][$ i]}=grep{/ \d/x}keys% hash}else{ @{$g[$j][$ i]}=keys % hash;} } } } return\@ grille}printg(@mag) ;print"\n";while (combien(@mag)!=combien (@{elim2(@{elim1(@mag) })}) ){@mag =@{+elim2 ( @{ elim1 (@mag) } ) }; printg(@mag); print"\n";}

by the way, it's a simple stupid suudoku solver...


P!

Are the monkeys gone yet?

Replies are listed 'Best First'.