Problem E
Hilbert's Hedge Maze

David has elaborate hedge mazes in his garden. For each of
his mazes of different sizes, he wonders how long it would
take to walk between any pair of locations in and around that
maze. A hedge maze of order
-
Start with
. -
Repeat
times:-
Create a new string
by replacing each in with and each with . -
Set
.
-
-
Remove all
’s and all ’s from .
The resulting string gives the instructions for constructing
the hedge maze. In the unbounded plane start at coordinates
After constructing the maze, identify position
Given a number
Input
Input starts with a positive integer
Output
Output
Sample Input 1 | Sample Output 1 |
---|---|
2 3 5 3 4 0 2 4 3 0 2 |
16 11 |