From the course: Code Clinic: JavaScript

Unlock the full course today

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

Finishing calculations

Finishing calculations - JavaScript Tutorial

From the course: Code Clinic: JavaScript

Start my 1-month free trial

Finishing calculations

- [Instructor] It's said to start pushing these solutions into a solutions array and then also use recursion to go through all of the available options. So what we're doing is asking the computer to place a queen somewhere and then go through some checks. Make sure that no queens can be placed in the same horizontal position but what we need to do is once we're done with a row, we're going to be doing some calculations with the new row but this new row needs to know about the previous row and that's where recursion is going to come in handy. Once we sort of figure out what's happening in this row, that's not gonna work, this is not gonna work. Potentially this one here will work and we're sort of done because we can't place any more queens here so we need to move to the new row but this new row needs to know about these other two. So it's going to try to put something here and that's not going to work. Diagonally, that one doesn't work here. This won't work either. That one won't…

Contents