sub oddmagic{
my $order=shift;
if( $order%2 != 1 ){ return warn "$order not odd\n" }
my @ordinary=@{(shift)};
my @break=@{(shift)};
my @x=(0,($order-1)/2);
my @square;
for( 1..$order*$order ){
if( $square[$x[0]%$order][$x[1
$x[0] += $break[0]-$ordinary[0];
$x[1] += $break[1]-$ordinary[1];
}
$square[$x[0]%$order][$x[1
$x[0] += $ordinary[0]; $x[1] += $ordinary[1];
}
return @square;
}
my @s = oddmagic(7,[-1,1],[1,0]);
for( @s ){
printf"%3d"x@$_,@$_;
print"\n";
}
Main Topics
Browse All Topics





by: ozoPosted on 2005-06-28 at 23:00:11ID: 14325614
http://rec-puzzles.org/new /sol.pl/ar ithmetic/m agic.squar es