Jesús Gabriel y Galán
1/8/2009 9:09:00 AM
On Thu, Jan 8, 2009 at 9:49 AM, andrea <kerny404@gmail.com> wrote:
> There are still a few things that I don't like though.
> For example here
> def reset_board(len = 3)
# board = []
# (0...(len)).each { board << [nil] * len }
board = Array.new(len) {[nil]*len}
free = []
# setting all the free cells
# for i in (0...(len))
# for j in (0...(len))
# free << [i, j]
# end
# end
# Not in a single loop but I'd do:
0.upto(len-1) {|i| 0.upto(len-1) {|j| free << [i,j]}}
> [board, free]
> end
Jesus.