Hi,

Calculate the square root of the lenght of the original array and then 
use Enumerable#each_slice to create an array of "rows".

For example:

one_d_array = (1..9).to_a
dim = Math.sqrt(one_d_array.length).to_i
two_d_array = one_d_array.each_slice(dim).to_a
p two_d_array

However, if you actually want to do matrix calculations, you should use 
the Matrix class instead of an array:
http://ruby-doc.org/stdlib-1.9.3/libdoc/matrix/rdoc/Matrix.html

-- 
Posted via http://www.ruby-forum.com/.