Maze Walker

You are given a program which is capable of traversing 2D mazes. However, the solution isn’t perfect and fails to find the exit in certain types of mazes. Moreover, the current solution is messy, doesn’t follow any sensible coding principles (e.g. SOLID) and is completely untested.

The code for this kata can be found at Buddy/Maze-Walker

The program takes input from a text file representing the maze.
There are two example mazes provided in the repository.

  • maze1.txt​ ​is an example of a maze where the current solution succeeds.
  • maze2.txt​ is an example of a maze where the existing solutions fails to find the exit.
Currently the program outputs the x,y position of the dumb maze walker at each step.

Refactoring Work

Your goal is to modify this program to work with all the example mazes in two steps:

  1. Refactor the code
    • Ensure code is covered by a characterization test before refactoring that area. You don't want to regress and not now it!
    • It should be easy to read, follow the SOLID design principles.
  2. Branch by abstraction and extend the existing maze walker to find the exit in both example mazes
    • Enable toggling between the two implementations at runtime.


  • The only valid movements in the mazes are up, down, left and right. You can’t move diagonally.
  • Both maze walkers, new and old, should be demonstrably correct through testing.
  • You can edit the DumbMazeWalker class, but you must not change the way in which it ultimately traverses the points in the maze. You can change the output function if you want, though.
  • You must not change the technique the existing DumbMazeWalker uses to traverse the maze, i.e. the existing maze walker must traverse the maze in the same sequence of steps after your refactorings.


Make it easy to see what’s going on with your new maze walker log all of the maze as each step like output1.txt​.
Currently the program only outputs the x,y position of the dumb entity at each step.