On 2004-08-26, Boris Glawe <boris / boris-glawe.de> wrote: > Fastest is C: 4.1 seconds > then C++: 4.5 seconds > > Now I tried ruby: 16 minutes !! I have 74ms on my P3-450MHz, that must be a mistake in my implementation but: could you give us the output of './springer.rb 7 4 4' you were expecting. I have: (4, 4) (6, 5) ... with 44 recursions. > def search_neighbours > fields.each do |line| > line.each do |current_field| > tmp_field = field(current_field.pos_x + 2, current_field.pos_y + 1) > current_field.neighbours.push(tmp_field) unless ! tmp_field > ... > end > end > end 'unless !' is called 'if' in Ruby ;) and I have a small optimisation: KNIGHT_MOVES = [ [2, 1], [-1, 2], [-2, -1], [-2, 1] ] def search_neighbours @fields.each do |line| line.each do |current_field| KNIGHT_MOVES.each do |move| tmp = field( current_field.x + move[0], current_field.y + move[1] ) current_field.neighbours << tmp if tmp tmp = field( current_field.x + move[1], current_field.y + move[0] ) current_field.neighbours << tmp if tmp end end end end -- Olivier D.