# Alice and the Fractal Hedge Maze

This is an entry to the 12th fortnightly challenge.

Alice: Would you tell me, please, which way I ought to go from here?
Cheshire Cat: That depends a good deal on where you want to get to.
Alice: I don't much care where...
Cheshire Cat: Then it doesn't much matter which way you go!
Alice: ... so long as I get somewhere.
Cheshire Cat: Oh, you're sure to do that, if only you walk long enough.

Alice is in the most puzzling part of Wonderland yet. Following the white rabbit, she emerged found herself in the middle of a hedge maze. The rabbit provided her with a map before scurrying off, but it only seemed to make her more confused. She needs your help to figure out how to escape the maze.

The maze has 12 potential exits, numbered on the map. Each of the squares labeled A, B, C and D represent smaller copies of the entire maze. These submazes each have their own submazes, like infinitely many nested Matryoshka dolls, except that every doll has four dolls nested inside it.

Below the map is a bird's eye view of the actual maze, where you can see how the passages become smaller and smaller in a fractal fashion (only three levels of recursion are actually pictured). Fortunately, Alice has an ample supply of cakes and elixirs to change her size as necessary.

One last note: the little orange curve between B and D is a bridge which can be crossed over and walked under, but jumping from the bridge to the path below is not allowed.

# Sources

Though I created this particular puzzle, the concept of a fractal maze is nothing new. Here are some other notable examples of cool fractal mazes, which served as inspiration for this one.

• As far as I can tell, the concept of a fractal maze was created my Mark J. P. Wolf. He has made at least two mazes, taken from mathpuzzle.com.

• These are from the blog Skeptic's Play:

• Two devious looking mazes which I found referenced in this forum, but couldn't find the original sources for.

• When Alice is scaled down to fit into the smaller mazes, does she move correspondingly slower? – Gareth McCaughan Jul 14 '16 at 18:17
• Does Alice start at the single full-sized "You are here"? – Gareth McCaughan Jul 14 '16 at 18:18
• @GarethMcCaughan Yes, she moves slower as she shrinks, and yes, Alice starts at the largest "You Are Here" (also, there aren't any copies of Alice in the smaller mazes). – Mike Earnest Jul 14 '16 at 18:25
• Cool puzzle. +1 – hexomino Jul 14 '16 at 18:58
• +1 for doing the research and adding the references. I was actually playing with such an idea myself (in my head) and did not know, that such mazes exist and are called "fractal mazes". Glad you made such a nice example for the challenge! – BmyGuest Jul 14 '16 at 20:08

Here is a link to a prezi. If there is anyway to export it that would be great but I'm not exactly sure how it works.

Just keep clicking next through it.

https://prezi.com/oh2efo-ejbv9/untitled-prezi/?utm_campaign=share&utm_medium=copy

GIF

And the path in the format from-to (level). If the number includes a letter it comes from/goes to an internal maze box, if it does not it goes to the outside of the current level.

IN-A3 (1)
3-B1 (2)
1-12 (3)
B12-B11 (2)
11-A10 (3)
10-C4 (4)
4-B6 (5)
6-D8 (6)
8-10 (7)
D10-7 (6)
B7-7 (5)
D7-9 (4)
A9-8 (3)
B8-D3 (2)
3-B4 (3)
4-B6 (4)
6-D8 (5)
8-10 (6)
D10-7 (5)
B7-D10 (4)
10-8 (5)
D8-6 (4)
B6-4 (3)
D4-5 (2)
A5-1 (1)
OUT

• Nice! A shorter path than mine :) – Wesley Situ Jul 14 '16 at 21:16
• This is the optimal solution, in terms of number of size changes, well done! The prezi you made was very satisfying to navigate, I was happy to see the imaginary maze brought to life. – Mike Earnest Jul 14 '16 at 23:15
• I've played with Prezi a bit, but never seen quite such an appropriate use case! Anyone who hasn't should try the Prezi link for a nice walkthrough. Very nicely demonstrated. – Dan Russell Jul 15 '16 at 14:45
• Superb use of Prezi! Simply superb. Hang around for a little extra bounty from me. :) – CodeNewbie Jul 16 '16 at 6:08
• It just took you 3 hours to solve it and make the beautiful prezi Oo ? Well done – pwnsauce Jul 28 '16 at 15:27

The path you can take out is

Enter A3
Enter B1
Exit B12
Enter B11
Enter A10
Enter C4
Enter B6
Enter D8
Exit D10
Exit B7
Exit C7
Exit A9
Exit B8
Enter D3
Enter B1
Exit B12
Enter B11
(Repeat)
Exit B8
Enter D1
Exit D12
Enter D11
Enter A10
(Repeat)
Exit A9
Exit D10
Enter B7
Enter D10
Exit D8
Exit B6
Exit D4
Exit A5

How I reached this conclusion

A few rules that you can make

Enter 4, Exit 7
Enter 4
Enter B6
Enter D8
Exit D10
Exit B7
Exit 7

Enter 10, Exit 9
Enter 10
Enter C4
Enter 4, Exit 7
Exit C7
Exit 9

Enter 11, Exit 2|8|9|10
Enter 11
Enter A10
Enter 10, Exit 9
Exit A9
Exit 2|8|9|10

• Formatting is fine, but some drawing would be even better :c) – BmyGuest Jul 14 '16 at 20:09
• What exactly does "(Repeat)" mean? – Gareth McCaughan Jul 14 '16 at 20:12
• @GarethMcCaughan I'm assuming that he's repeating the Enter A10, Enter C4, Enter B6, Enter D8, Exit D10, Exit B7, Exit C7, Exit A9 block. Because is you place that instead of repeat it works to get you out of the maze. – dcfyj Jul 14 '16 at 20:30
• @GarethMcCaughan Ahh, I meant to repeat the previous paths that were used to do the same enter/exit. It was a lot of steps to retype and didn't want to make the block longer than it already was. – Wesley Situ Jul 14 '16 at 21:12
• This is a good solution, +1. I gave the other answer the green tick since it was shorter. – Mike Earnest Jul 14 '16 at 23:22

This puzzle definitely caught my fancy! The leap was when I realized that all moves could be expressed as compositions of "prime" moves, which don't enter any of the submazes: 1-12, 2-8, 2-10 and 8-10 (and their reverses). So I just drew the maze with blank submazes, added the prime moves to the submazes, saw which moves I could do now and added those to the submazes, and repeated until I had "built" the solution (3-5).

3-5: B 1-12*
B 11-8
D 3-5

11-8: A 10-9

10-9: C 4-7

4-7: B 6-7

6-7: D 8-10*

3-5: D 4-6

4-6: B 1-12*
B 11-8
D 1-12*
D 11-8


I...haven't actually expanded the solution out all the way, but I'm mostly sure it's identical to gtwebb's.

• So now you just have to finish :) – user58 Jul 18 '16 at 18:59

Found the same path as @gtwebb. I used the following notation: 1 - node 1 on external square, A7 - node 7 on A, CB11 - node 11 on B inside C. So from CAB6 there are edges to CA4 and CABD8.

First I ran the classic BFS... which didn't stop (until my patience ran out). Priority queue came to rescue, causing nodes with minimal length, which are closest to the external border, to be handled first. This found solution in under 1000 iterations and under 1 second.

Here's the script. It uses a, b, c instead of 10, 11, 12 to make things little bit easier.

And here's the solution: