Join Mark Niemann-Ross for an in-depth discussion in this video Brute force: Dealing with diagonals, part of Code Clinic: R (2015).
- So, finally we need to deal with diagonal solutions.…This requires three nested FOR loops.…And I'm looking at eightQueensBruteForce.R,…starting at line 21.…You'll recall that clean columns and rows…contains a matrix of solutions…that have no conflicts on the columns…and no conflicts on the rows,…but there are obvious conflicts…in some of the diagonals.…I'm simply copying this over into…a variable called clean.diag just to keep…things clean around here.…
Then, line 23 starts the three nested FOR loops.…And in fact what you'll see is line 23…is a FOR loop, 24 is nested inside of 23,…and 25 is nested inside of 24.…Each one of those is FOR loops.…And what I've told it to do is,…in line 23 I'm setting up a FOR loop…that asks is a queen in this row?…Then in line 24, I say let's look in one of these columns.…And then in line 25 is where I'm looking…at the diagonals, or one through seven.…
Line 26 and line 30 are the two lines…that actually do the work of checking…to see if there are any queens…diagonally positioned from the particular…
Mark introduces challenges and then provides an overview of his solutions in R. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Skill Level Intermediate
Q: R Studio tells me that it can't find files I expect to be available. Where can I find them?
A: Use the setwd() command to set the working directory to match the folder you're working in.
Q: I am unable to access the Lake Pend Oreille data from outside the U.S.
A: A static copy of this data is provided here for lynda.com members outside of the U.S.
1. Problem One: Statistical Analysis
2. Problem Two: Image Analysis
3. Problem Three: Eight Queens
4. Accessing Peripherals
5. Recursion and Directories
Walking the directory sort code10m 56s
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.