Created
April 18, 2012 02:31
-
-
Save mikeebert/2410700 to your computer and use it in GitHub Desktop.
n queens loop
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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