From: Robert Klemme Date: 2003-12-04T02:32:04+09:00 Subject: Re: New to ruby--trouble with initializing arrays "Josef 'Jupp' SCHUGT" schrieb im Newsbeitrag news:20031203004859.GC893@jupp%gmx.de... > Hi! > > * Van Jacques; 2003-12-02, 23:31 UTC: > > "Robert Klemme" wrote in message news:... > [Object oriented life] > > This is much more sophiscated than my program (with help from > > another poster in a similar thread here in comp.lang.ruby), but I > > used the > > > > row % size > > > > method for dealing with the edges also. > > The solution is not as sophisticated as it seems. Simply imagine that > you number the fields like this (use fixed width font): > >
> : +--+--+--+--+--+--+
> : | 0| 1| 2| 3| 4| 5|
> : +--+--+--+--+--+--+
> : | 6| 7| 8| 9|10|11|
> : +--+--+--+--+--+--+
> : |12|13|14|15|16|17|
> : +--+--+--+--+--+--+
> : |18|19|20|21|22|23|
> : +--+--+--+--+--+--+
> : |24|25|26|27|28|29|
> : +--+--+--+--+--+--+
> : |30|31|32|33|34|35|
> : +--+--+--+--+--+--+
> 
> > If you now store them one after another going one to the right/left > when assuming 0 and 5 are neighbors and current position is n results > in (n +/- 1) modulo 6. For the row the same works - with the only > difference that the result of the operation must be multiplied by the > distance of the chunks representing a whole row (6 in this case). I don't fully understand what you mean by "not as sophisticated as it seems" since it does exactly what you describe. (Look into the pos() method) Now, did I or did you get something wrong? :-) Kind regards robert