Implementing Recursive Division

Learn how to implement the Recursive Division algorithm using Ruby.

The RecursiveDivision class

The algorithm really is as simple as described. First, we’ll “blank out” the grid by linking every cell to its neighbors (effectively removing all interior walls) and then recursively split the grid in half by adding walls back in. Unlike the other algorithms we’ve implemented, we’re going to break this one into a few different methods to help with the recursion. It’ll start with the on(grid) method.

Get hands-on with 1200+ tech skills courses.