- or download this
sub getPos{
($x,$y,$s)=@_;($d=$x+$y)*($d++)/2
+($d%2?$y:$x)-($d>$s)*($d-$s)**2
}
- or download this
for(my $x = 0; $x < $size; $x++){
for(my $y = 0; $y < $size; $y++){
...
}
print "\n";
}
- or download this
0 1 5 6 14 15 27 28 44 45
2 4 7 13 16 26 29 43 46 63
...
35 37 52 57 69 74 82 87 91 96
36 53 56 70 73 83 86 92 95 97
54 55 71 72 84 85 93 94 98 99
- or download this
sub getPos{
my ($x,$y,$size)=@_;
...
$index -= ($m+1)**2;
}
}
- or download this
$==pop;print map{$y=$_;map(($d=$y+$_)*$d++/2-($d>$=)*($d-$=)**2+($d&1?
+$_:$y).$",@m),$/}@m=0..$=-1