12
1
Given a WxH
grid, how many possible mazes are there?
Things you know about the maze:
- The grid is exactly
H
squares high andW
squares wide. - There are three types of squares: Start, Finish, and Empty. Your maze must contain exactly 1 Start and 1 Finish, and all remaining squares are Empty.
- There are walls surrounding the entire maze.
- Walls can exist on the edge between any two squares, unless it breaks the below rule:
- There must exist a path from the Start square to the Finish square.
Therefore, given two numbers, W
and H
, you must return a single number representing the number of possible square/wall configurations. You are guaranteed that W*H > 1
For example, the 2x2
maze has exactly 100
different possible configurations.
This is a code-golf so the shortest answer wins!
Are there any constraints on size and/or runtime? Unless somebody finds an algorithm that can calculate the count efficiently (which looks tough), I expect that most solutions will have exponential runtime. Meaning, that they will implode at even moderate sizes. – Reto Koradi – 2015-07-16T20:41:02.730
@RetoKoradi no, no runtime constraints. I'm not sure if constraints would make the problem impossible or not. – Nathan Merrill – 2015-07-16T20:56:29.420