------ art_134154_3545505.1161089681356 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Content-Disposition: inline On 10/17/06, Peter Szinek <peter / rubyrailways.com> wrote: > > Robert Dober wrote: > > On 10/17/06, Peter Szinek <peter / rubyrailways.com> wrote: > > > You are simply brilliant ;) > > I am certainly very far from that... I was just happy that (still being > a noob) I have solved something on my own for the first time. What's > wrong with that? Did you see the smiley Peter? I meant that somebody coming up with the same thingy than me will be brilliant because we all think that we are brilliant, but only in the joke. So there is definitely nothing wrong at all and it is quite impressive for someone new to ruby. However it is quite a headache to maintain, I did not add any more readable forms, using e.g. #inject because I thaught that this will be perfectly at your fingertips. Simon has added a version I think is most readable, it is probably a very good thing to use. Here is an alternative using #inject - I do not like inject - but I am a pro, I will not let getting feelings in my way ;) <---N.B. Smiley n.inject([]){ |a,k| a << [*k*n+1..(k+1)*n] } Furthermore that leaves a little challange for yourself, unless you dislike the magic dot notation. Cheers Robert > Peter > http://www.rubyrailways.com > > > -- The reasonable man adapts himself to the world; the unreasonable one persists in trying to adapt the world to himself. Therefore all progress depends on the unreasonable man. - George Bernhard Shaw ------ art_134154_3545505.1161089681356--