# Forum: Ruby Help defining multi-dimensional array

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
on 2005-12-08 20:41
```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 2005-12-08 20:49
```On Dec 8, 2005, at 1:38 PM, Victor Reyes 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 Gray II```
on 2005-12-08 22:14
```#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 2005-12-09 04:49
```On Fri, 9 Dec 2005, Victor Reyes 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```
on 2005-12-11 05:55
`Thank you all for your help.`
This topic is locked and can not be replied to.