Skip to Main Content
Mazes for Programmers
book

Mazes for Programmers

by Jamis Buck
July 2015
Intermediate to advanced content levelIntermediate to advanced
286 pages
6h 31m
English
Pragmatic Bookshelf
Content preview from Mazes for Programmers

Implementing Eller’s Algorithm

Eller’s algorithm works strictly one row at a time, so our implementation will take advantage of that by leaning on a row-centric state object. Once we have that state object, the rest of the algorithm comes together quickly.

We’ll start with the RowState class, which we’ll place under the namespace of the Ellers class. It will all go in ellers.rb.

ellers.rb
 
class​ Ellers
 
 
class​ RowState
 
def​ initialize(starting_set=0)
 
@cells_in_set = {}
 
@set_for_cell = []
 
@next_set = starting_set
 
end
 
end
 
 
end

It’s certainly not much yet, but it does get us started. The initialize method has a starting_set parameter (defaulting to 0), which will be used to determine what value is used for new sets. It ...

Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Exercises for Programmers

Exercises for Programmers

Brian P. Hogan

Publisher Resources

ISBN: 9781680501315Errata Page