On May 24, 2005, at 4:33 PM, Pedro wrote: > Here's my solution, and without googling!. Nice job. > I'm new in Ruby, Welcome! > and I have a little doubt in my solution. The to_s method is too > slow in the way I implemented it, Is there any better approach?. [snip] > def to_s > cad = '' > @tiles.each_index { |i| > cad += @tiles[i] + ' ' > cad += "\n" if i%@w==@w-1 > } > return cad > end I haven't tested or timed it, but one way might be: def to_s @tiles.join(" ").sub!(/((?:[0-9X]+\s+){#{@w}})/, "\\1\n") + "\n" end Hope that helps. James Edward Gray II