We've now improved our loops by using while…and are able to backtrack in our columns,…but in the process of doing that we discovered…that we also need more control…over looping through the rows as well.…Once again I've added a new file…to our code clinic project.…This one is called loop3.rb.…You can see that most of the code looks exactly the same.…The changes are all inside this function here,…solve queens problem.…Notice that I had column equals zero before…and I was looping through columns by using…while columns is less than the total columns.…
Now I'm going to add a new line,…row equals zero, and while row is…less than the total number of rows,…we're going to keep performing the loop…and we're going to make sure that we also…increment the row down here.…If we're not at the ending row yet,…then row plus equals one.…This is the substantive changes…except for this section right here.…So this will work.…This will allow us to loop through.…When we get to a column that doesn't work…and we need to backtrack, it's going to loop back up here…
Author
Updated
12/16/2014Released
7/15/2014Kevin introduces challenges and provides an overview of his solutions in Ruby. Challenges include topics such as statistical analysis, searching directories for images, and accessing peripheral devices.
Visit other courses in the series to see how to solve the exact same challenges in languages like C#, C++, Java, PHP, and Python.
Skill Level Intermediate
Duration
Views
Q: I'm running Windows and can't get some of the code shown in the videos to install. Is there something else I need to do?
A: For exercises that compile third-party code, Windows users may need
to install the RubyInstaller Development Kit (DevKit). DevKit is a
MSYS/MinGW-based toolkit than enables you to build many of the native
C/C++ extensions available for Ruby. DevKit was previously included in
the Windows installer, but now requires a separate download and
installation. The installation instructions are available at https://github.com/oneclick/
Q: Why can't I access the Lake Pend Orielle site (http://lpo.dt.navy.mil)?
A: The Lake Pend Orielle site is not accessible in some geographical areas. We have contacted the owner of the server to try to resolve this issue.
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
Related Courses
-
Introduction
-
Welcome1m 3s
-
-
Problem One: Statistical Analysis
-
Overview of my solution2m 29s
-
Accepting user input7m 59s
-
Validating user input6m 59s
-
Retrieving remote data8m 29s
-
Data calculations6m 30s
-
Output results3m 57s
-
API11m 46s
-
Problem Two: Image Analysis
-
Hints, tips, and tricks2m 53s
-
Overview of my solution3m 51s
-
ImageMatcher12m 19s
-
Matching exact pixels13m 11s
-
Matching similar pixels6m 18s
-
Determining the best match5m 30s
-
Optimizations6m 53s
-
Matching with OpenCV8m 21s
-
Problem Three: Eight Queens
-
Eight Queens problem1m 46s
-
Hints, tips, and tricks3m 54s
-
Overview of my solution5m 55s
-
Queen and board classes6m 10s
-
Displaying the board7m 1s
-
Determining safe positions6m 48s
-
Using loops7m 8s
-
Loops with backtracking5m 12s
-
Recursion primer3m 45s
-
Using recursion6m 52s
-
Further exercises3m 56s
-
-
Problem Four: Accessing Peripherals
-
Hints, tips, and tricks3m 20s
-
Overview of my solution5m 43s
-
Installing Gosu4m 31s
-
Creating PitchMaker9m 7s
-
Adding an indicator9m 12s
-
Changing volume4m 36s
-
Changing pitch4m 54s
-
Problem Five: Recursion and Directories
-
Introduction2m 6s
-
Hints, tips, and tricks3m 15s
-
Overview of my solution2m 54s
-
Making a plan5m 18s
-
Finding images with recursion10m 37s
-
Finding images a simpler way3m 21s
-
Install exiftools2m 21s
-
Inspect images for metadata7m 33s
-
Organize images by caption8m 26s
-
-
Problem Six: Building the Web
-
A templating problem1m 31s
-
Hints, tips, and tricks1m 35s
-
Overview of my solution3m 12s
-
Parsing CSV files6m 9s
-
ERB templating9m 2s
-
CurriculumMaker5m 56s
-
Parsing course data3m 42s
-
Creating an ERB template10m 15s
-
Using the ERB template4m 15s
-
- 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.
CancelTake 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.
Share this video
Embed this video
Video: Loops with smarter backtracking