Maze generation algorithm in Erlang