m$(,v)(;(|.&.>@{.,:{:)&.|:_2]\</.v)},v=.i.m=.4 4
0  1  5  6
2  4  7 12
3  8 11 13
9 10 14 15

--- bill lam <[EMAIL PROTECTED]> wrote:

> I found a problem that is said to an assignment for introductory C course but 
> it
> turned to be not so trivial. It can be rephrased in J as: for a positive 
> integer
> m find the array v or equivalently (m,m)$v so that result is a matrix with 
> atoms
> of i.*:m filling in zig-zag order. (restricted to square matrix for time 
> being)
> 
> example
>    4 4$0 1 5 6 2 4 7 12 3 8 11 13 9 10 14 15
> 0  1  5  6
> 2  4  7 12
> 3  8 11 13
> 9 10 14 15
> 
> I tackled the problem by noticing the sum of cell index pair for each layer is
> constant but run into trouble when need to eliminate extra pairs after passing
> the middle layer.
> 
> All suggestions welcome.
> 
> PS. zig-zag order is used in jpeg encoding http://en.wikipedia.org/wiki/JPEG
> -- 
> regards,
> bill
> ----------------------------------------------------------------------
> For information about J forums see http://www.jsoftware.com/forums.htm
> 



 
____________________________________________________________________________________
Want to start your own business?
Learn how on Yahoo! Small Business.
http://smallbusiness.yahoo.com/r-index
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm

Reply via email to