From the course: Code Clinic: Clojure

Unlock the full course today

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

Concept overview

Concept overview - Clojure Tutorial

From the course: Code Clinic: Clojure

Start my 1-month free trial

Concept overview

- [Voiceover] Let's look briefly at some commonalities between the solutions. For both solutions, we'll represent queen placements with a vector of numbers, whose length is the size of the board. So we'll have eight numbers for an eight by eight board. Position of each element within the vector represents the associated column that a queen is placed in. Each value in the vector represents the row that that queen was placed in. So the value zero, is on the zeroth row, and four is on four, using zero indexing. Given this flat representation, queens can not be in the same column, so are unable to attack vertically. All the numbers in the list are distinct, then each queen is on its own row, and unable to attack horizontally. This helps us solve part of the problem on its own. To complete the solution, we also need to ensure that queens can't attack each other diagonally. We'll keep these observations in mind as we discuss both approaches, since they both build on this foundation. The…

Contents