From the course: Code Clinic: Swift

Unlock the full course today

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

Display solutions

Display solutions - Swift Tutorial

From the course: Code Clinic: Swift

Start my 1-month free trial

Display solutions

- [Narrator] Now let's look at placing the queens in the appropriate position and cycling through all of the various solutions. So scroll down to the placeQueens method. And in here we're going to reference our current solution. So let solution = solutions and the index is going to be the value of our index property. And then we're going to get the height and width of our queen. So the reason that we need to do this is we're going to take that position of our first queen. So right here at the top left, and we're going to find the positions on the other ones based on multiplying by this object's height and width. So we talked about that earlier in the chapter, but if we take this position and we add on in the amount of its width, then we get this position. And then the width times two, this position, et cetera. And the same thing for height, so we're basing all of that based on the size of the width and the height of this queen. So let's go back to the Controller.swift and we'll let w…

Contents