Mazes – from Ruby to Python

Mazes for Programmers is a great book. Definitely one of the greatest books of all time! (about mazes:-)

The book has great code for mazes but unfortunately, for me, the code is in Ruby and I am not yet ready to start coding with Ruby.

But I feared not!

I like Python and Xtend, so I tend to prefer them when coding. And since the Mazes for Programmers is about algorithms and techniques, not about Ruby, I decided to translate some of the code to Python.

I chose base classes of Cell and Grid and two algorithms: Binary Tree and Recursive Backtracker for translation and I discovered that Ruby is an easy language to read and it’s similar to Python in many ways

Below is the translated Python code (the original Ruby code is found from here). I did some modifications, so the Python code is not exactly as the Ruby code.

(edit 12.09.2015: Gist below is the latest code and has more than two algorithms. It reflects latest version)

Leave a Reply

Your email address will not be published. Required fields are marked *