Here's another trick I used on the weekend, before rolling everything together. You know with a puzzle like this, that breaking the solution up into seperate UDF's can be VERY expensive in terms of chars. Well, here's an example of how we can "embed" functions within UDF themselves, example:

break on

?"func=" addone(1)

exit 1

function addone($n)

 gosub "add"

 $addone = $n

 return

 :add
  $n = $n + 1
 return

endfunction


This function just adds one to the number specified, but notice the gosub embedded inside the UDF itself. Heres the interesting thing, $n is local to the UDF, but the subroutine still has access to it. Even more interesting is that the GOSUB routine itself is LOCAL to the UDF, ie, you can't access it from outside the UDF ... its like a LOCAL UDF ...

-Shawn