# A 1-D labyrinth

Bob is busy saving the world on Puzzling Stack Exchange by tracking down yet another super-villain. Alice rushes in holding a long paper.

A: I made a discovery you will like.

B: I am not on Facebook.

A: Whatever. You have probably seen 3-D or 4-D labyrinths. But have you seen a 1-D labyrinth?

B: 1-D? That cannot be much of a challenge, can it?

A: It can. Look here, I have a map.

ab A bcefgi B acdfghi C bcfgi D bcdg E cefh F efghi G begi H dehi I bcdfgij J j


B: That's a map? A single line?

A: What did you expect? It is a 1-D labyrinth!

B: Hm... OK, maybe. How does it work?

B: These things don't exist!

A: Exactly that type! The access is a long tunnel. There are plenty of checkpoints and heavy doors controlled by buttons. The buttons are all over the place. Normally they are operated by guards. But they are gone.

B: If they are gone, how are you going to open the doors?

A: That is why I need you. Look at the map. The uppercase letters are the heavy doors. The lowercase letters are the buttons operating the corresponding door. You lift a door by pressing the button. You must keep pressing the button or the door slams shut immediately. Some buttons can be operated from outside. I need you to press these buttons so I can cross the first doors. Then I press some other buttons inside and you cross the doors.

B: Isn't it, like, dangerous?

A: No.... I don't think so... And it is exciting! I want to see if together we manage to pass all the doors. Every time you open a door it gives access to new buttons. It is bound to lead somewhere. Let's go and have a try!

B: I have a better idea. I will just put the "map" on Stackexchange and they will crack it in no time.

So dear puzzler, care to help Alice and Bob cross the tunnel?

ab A bcefgi B acdfghi C bcfgi D bcdg E cefh F efghi G begi H dehi I bcdfgij J j


Alice and Bob enter from the left. One of them moves one position at a time. To pass a door (an uppercase letter), the other player must stand at a corresponding button (the lowercase letter). If a player leaves a button it shuts the door, possibly killing anyone standing under the door. The goal is to bring Alice and Bob safely to the right.

I think that the easiest way to solve this 1-D maze is to think of it as

a 2-D maze where the locations of Alice and Bob are your x- and y-coordinates.

This allows you to visualize it as follows:

It is of course symmetric across the diagonal, since you could switch the places of Alice and Bob without changing the problem. Shown in red is the solution where Alice stays ahead of Bob throughout.

In text form a solution is:

Alice: AB
Bob: A
Alice: C
Bob: B
Alice: D
Bob: B
Alice: EFG
Bob: B
Alice: HI
Bob: C
Alice: I
Bob: DE
Alice: H
Bob: E
Alice: G
Bob: EFGHI
Alice: G
Bob: I
Alice: HI
Bob: IJ
Alice: J

• The 2D visualization is interesting, but how does it work? Sep 4, 2022 at 13:51
• @TonyEnnis If you stand in front of door X, you see some buttons say acdf. This bunch of buttons lets you draw horizontal and vertical lines between doors A and B, between C and E and between F and G. You draw these lines in the row and column X. Repeat that for all buttons in the map, and you end up with the 2D map. Sep 4, 2022 at 20:03
• That's helpful, @ZizyArcher, but how is it used to solve the problem. I don't see how to navigate it. Sep 5, 2022 at 3:00
• @TonyEnnis You want both of them to get from A to J, so you need to find a path following those lines (previous comment as how to draw them) from start to end. How to find a path? Well, with such a simple maze you can simply take a glance and draw one of many options. How does that translate to where people stand and what they do? Bob, standing in front of door B (line between A and B), presses buttons efg that open the 3 doors and lets Alice go from standing in front of door E to standing in front of door H (this is the red line in top mid of the map) Sep 5, 2022 at 6:41
• I think, when you wrote "Bob: EFGHI", your chart swaps the roles of Alice and Bob compared to your text solution. It happens a few more times after that too. Just something that slightly confused me when trying to decode how your solution worked. Sep 5, 2022 at 13:42