From: Tom Sawyer Date: 2002-08-01T02:26:05+09:00 Subject: Re: matrix challange funny you should ask. i just had to do that myself. aT = [] a.length.times do |y| a[y].length.times do |x| aT[x] = [] unless aT[x] aT[x][y] = a[y][x] end end the only thing somewhat annoying about this is having to specify aT[x] = []. wish ruby could just pick up on that when i try to use it as such. ~transami On Wed, 2002-07-31 at 10:23, Daniel Bretoi wrote: > > Hi all, > > I'd like to see the various solutions for coming up with code to > transpose a matrix. ie. make > > a = [[1,2],[1,3],[2,4]] > > look like > > aT = [[1,1,2],[2,3,4]] > > I haven't had time to do a solution myself, but I think it would be > interesting to see how some of you guys would tackle it while I > derive something. > > > -- > "Then we typed the G, and the system crashed"... > -- ~transami