Learn how to implement an inductive solution.
- [Instructor] Now, let's implement our inductive solution.…Define our name space as queens.inductive,…and in a require expression,…I'm gonna pull in clojure.set,…and I'll alias it to set,…and this is a built-in library for doing operations on sets.…I'll begin by defining a function…that within the recursive process is given a board,…and returns the set of valid boards…with one more column placed.…We'll call this next-valid-boards.…So I'll need to take n for our target size,…and board for the current board that it's building off of.…
This function will look much like the generate function…in our permutation solution.…So I'll use remove has-diagonal-attack,…but instead of calling permutations,…I'll implement a function called next-boards.…And I'll need to pass to next-boards…n and the current board.…Now I'll implement that next board's function.…This also takes the n and board parameters.…So our task here is that given a board,…this function will return a series of boards…with an extra column.…
The placement in this column…
Skill Level Intermediate
1. Problem 1: Exploring Lake Pend Oreille
2. Problem 2: Image Analysis
3. Problem 3: Eight Queens
4. Problem 4: Accessing Peripherals
5. Problem 5: Recursion and Directories
6. Problem 6: Building the Web
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.