Join Mark Niemann-Ross for an in-depth discussion in this video A classic computer science problem, part of Code Clinic: R (2015).
- Hello and welcome to Code Clinic. My name is Mark Niemann-Ross and I'm the content manager for the developer segment at lynda.com. Code Clinic is the course where I introduce a problem to a collection of lynda.com authors, and in turn, those authors use their computer programming language of choice to produce a unique solution. You can learn several things from Code Clinic: different approaches to solving a problem, the pros and cons of different languages, and some tips and tricks to incorporate into your own coding practices.
This month we're going to explore a classic problem called The Eight Queens. The problem is simple. Start with a chessboard and eight queens, then set up the board so that no two queens can attack each other. There is more than one solution, find them all. This famous problem is often used during interviews for computer programming jobs or to demonstrate the utility of a computer language. It requires an understanding of recursion and algorithm design and can be quite useful as an exercise in learning to program for complex solutions.
If you've never played chess, you'll need to understand that a queen can attack by moving an unlimited number of spaces in three directions: horizontally, vertically and diagonally. This means that no two queens can share a row or a column nor can they be located diagonally from each other. This problem was proposed by Max Bezzel in 1848 and solved by Franz Nauck in 1850. We already know there are 92 possible solutions, and we already have examples of the solutions in several computer languages.
In the following video you'll be presented with a solution to the Eight Queens Problem and why that solution is my favorite. I'd encourage you to also look at the solutions from other authors in the lynda.com library. You'll be able to compare different author styles and different languages. I've also asked our authors to create a visual display of the solution so you can see how each language draws video representations. You may want to pause this course and try to solve it on your own. You'll have a better understanding of the problem and a better understanding of the solution I've created.
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.