This video shows a demonstration of a basic working solution using permutations.
- [Instructor] In this video,…we'll write our first implementation…using the permutation solution.…First, I'm in the permutation dot clj file…and I'm gonna define our name space.…Call it queens dot permutation.…Now, for our require expression,…I'll pull in clojure dot math dot combinatorics…and I'll alias this as combo.…We will be able to leverage this…to create combinations and permutations.…Now, I'll start at the very top level.…
I'm gonna create a function called generate…and make this function take in as in,…in queens so this will be the size…of the board that we're working with.…First, I'll use combo slash permutations…and posit range of n,…this will generate all the permutations of n things.…This is enough to solve the n rooks problem as we discussed…but I need to check for diagonal attacks.…So now, I'll use remove and posit a predicate function…which will define called has diagonal attack.…
Now delete this parentheses…that I can wrap our permutations in it.…In this way, once we write has diagonal attack…and return true when two pieces…
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.