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
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
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 Dec 8, 2005, at 1:38 PM, Victor Reyes wrote:
check out narray - i think the functionality of it will help greatly.
-a
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
ara [dot] t [dot] howard [at] noaa [dot] gov
all happiness comes from the desire for others to be happy. all misery
comes from the desire for oneself to be happy.
-- bodhicaryavatara
===============================================================================
This was quick.
Thank you
On 12/8/05, James Edward Gray II <james@grayproductions.net> wrote:
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
#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
---------------------------------
Yahoo! Shopping
Find Great Deals on Holiday Gifts at Yahoo! Shopping
Thank you all for your help.
On 12/8/05, ara.t.howard@noaa.gov <ara.t.howard@noaa.gov> wrote:
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
>
> Victorcheck out narray - i think the functionality of it will help greatly.
-a
--===============================================================================
> ara [dot] t [dot] howard [at] noaa [dot] gov
> all happiness comes from the desire for others to be happy. all misery
> comes from the desire for oneself to be happy.
> -- bodhicaryavatara===============================================================================