My code is quit long, but the part, that is executed is not very long. The only thing, that runs for 16 minutes is Board#find_trip The rest of the lengthy code is for initialization purposes. The constructor of the Board creates a square with dimension*dimension fields (instances of Field on a two dimensional array). Then the constructor finds the neighbours for each field and saves this list of neighbours within the field which is done by the private method Board#search_neighbours Most of this code isn't used anymore in Board#find_trip greets Boris