Help defining multi-dimensional array

Ruby Team,
I would like to define a 3x3 array of integers.
Can anyone tell me how this is done?
I would like to start playing with Ruby and I want to start by solving
Magic
Squares.

Thank you

Victor

On Dec 8, 2005, at 1:38 PM, Victor R. wrote:

Ruby Team,
I would like to define a 3x3 array of integers.
Can anyone tell me how this is done?

Here’s one way:

Array.new(3) { Array.new(3) { 0 } }
=> [[0, 0, 0], [0, 0, 0], [0, 0, 0]]

Hope that helps.

James Edward G. II

#Third Order Magic Cube
b={}
b[“0,0,0”]=1
b[“0,0,1”]=15
b[“0,0,2”]=26
b[“0,1,0”]=17
b[“0,1,1”]=19
b[“0,1,2”]=6
b[“0,2,0”]=24
b[“0,2,1”]=8
b[“0,2,2”]=10
b[“1,0,0”]=23
b[“1,0,1”]=7
b[“1,0,2”]=12
b[“1,1,0”]=3
b[“1,1,1”]=14
b[“1,1,2”]=25
b[“1,2,0”]=16
b[“1,2,1”]=21
b[“1,2,2”]=5
b[“2,0,0”]=18
b[“2,0,1”]=20
b[“2,0,2”]=4
b[“2,1,0”]=22
b[“2,1,1”]=9
b[“2,1,2”]=11
b[“2,2,0”]=2
b[“2,2,1”]=13
b[“2,2,2”]=27

On Fri, 9 Dec 2005, Victor R. wrote:

Ruby Team,
I would like to define a 3x3 array of integers.
Can anyone tell me how this is done?
I would like to start playing with Ruby and I want to start by solving Magic
Squares.

Thank you

Victor

check out narray - i think the functionality of it will help greatly.

-a

Thank you all for your help.