Skip to content

Instantly share code, notes, and snippets.

@mikeebert
Created April 18, 2012 02:31
Show Gist options
  • Save mikeebert/2410700 to your computer and use it in GitHub Desktop.
Save mikeebert/2410700 to your computer and use it in GitHub Desktop.
n queens loop
def coordinates_for_next_move
while attackable(@row,@column)
@column += 1 if @column < @size
while @column >= @size
@row = @positions.last[0]
@column = @positions.last[1] + 1
@positions.delete_at(@positions.count - 1)
end
end
place_next_queen
end
# place_next_queen shovels the row and column to the positions array and then calls coordinates_for_next_move
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment