From the course: Code Clinic: Ruby

Unlock the full course today

Join today to access over 22,400 courses taught by industry experts or purchase this course individually.

Further exercises

Further exercises

From the course: Code Clinic: Ruby

Start my 1-month free trial

Further exercises

- At its heart the eight queens problem is actually an exercise in efficient algorithm design. If you enjoyed this problem, you can take it even further. Here are some suggestions for further exercises you can attempt on your own. The most common extension of this chalenge is to use a different size chessboard, for example a nine queens challenge would use a nine by nine board with nine queens. Because the number of queens varies and always matches the size of the board these are often referred to as n-queens problems, the number of queens can vary. Some solutions to the eight queens challenge are only effective for an eight by eight board. The solution I've just demonstrated to you will work for any size board, let me show you. Inside our Code Clinic project I've added a new file called n_queens.rb and I've only made one change to this file, which is that instead of just having board.new, like we had in recursion_all or dot new, instead now we're passing in a size. And if you…

Contents