in reply to ASCII Pattern - Golf

I wanted to go on a completely different tack using s///, but couldn't get anywhere near as brief a method.
$_=('x'x9 .$/)x9; substr($_,10*(9-$ARGV[1])+$ARGV[0]-1,1)=0; for$a(0..8){for$b(0,8,9,10){s/(?<=$a.{$b})x|x(?=.{$b}$a)/$a+1/esg}} print;
Useless but interesting digression: ...
This is similar to a routine used for pathfinding on game grids. I start at 0. At move 1, here's where I could be, at move 6, here's where I could be, and so on. My routine would be able to avoid barriers in the gameboard and continue to walk around the sides of such barriers. An example barrier of five dashes is added:
$_=('x'x9 .$/)x9; substr($_,10*(9-$ARGV[1])+$ARGV[0]-1,1)=0; substr($_,10*3+3,5)='-----'; # extra barrier for$a(0..8){for$b(0,8,9,10){s/(?<=$a.{$b})x|x(?=.{$b}$a)/$a+1/esg}} print;
This produces (with starting 0 at 2,3):
666666789 555556789 444456788 333-----7 222234567 111234567 101234567 111234567 222234567

--
[ e d @ h a l l e y . c c ]