This puzzle is originally created by by Roger Penrose. The goal is to guide the train all the way to the station via the railways, without ever reversing or taking sharp turns. The train can only travel forwards. For instance, at the first crossing, where five tracks join, it can only take one of the three tracks that go north - it can not go back where it came from, or take the other southwards track.

Railroad maze

Which route does the train have to take?

Note: With sharp turns, I mean those turns that a train would not be able to make normally because there is no smooth curve to follow, or in other words: the path the train takes should be differentiable.

  • 1
    $\begingroup$ I found an endless loop D: $\endgroup$
    – warspyking
    Mar 5, 2015 at 1:18
  • $\begingroup$ There is no way out. $\endgroup$
    – warspyking
    Mar 5, 2015 at 1:22
  • $\begingroup$ Just map all the possibilities out from finish going backwards. There's no way... $\endgroup$
    – warspyking
    Mar 5, 2015 at 1:23

2 Answers 2


The solution is:

shown on Wolfram. A discussion paper was written by Slavik and Wagon.


  • 1
    $\begingroup$ Good job! It is solvable by hand though, but it did take me a while... $\endgroup$ Mar 5, 2015 at 9:26

It is not a new solution. But I'd like to present the process leading to the solution.

Step 1

There are a number of places that you cannot escape. For instance a circle where all lines come in in the same direction. Once inside, you turn round and round and there is no way out. Sometimes it is a group of circles that trap you in.

In the following picture I have marked in red all regions where you cannot escape. Or regions where you can only escape to another red region. I have marked in red all paths leading to these.

enter image description here

Red paths cannot be used. You would be either in a position where you enter a red region and you get trapped, or you would be leaving a red region but there is no path that can bring you there.

Step 2

Removing all red paths you can already see an outline of the solution.

enter image description here

You might think that you cannot leave the large circles without reversing the train. This is not the case. In the left circle the train can reverse the direction by visiting the circles in the center. In the right circle, you can visit the small group in what looks like a dead end, and get out in the reverse direction. These methods make it possible to enter and leave the large circles.

Final solution

Examing the small loops, you can find a number of useless loops that return the train to a previous place, or worse, loops that send the train heading back to the start. Erasing all these loops reveals a nearly unique solution. It is not really unique since you could travel many extra loops. But if you never travel the same track twice in the same direction then the only alternative I see is when you reverse the direction at the bottom in middle. It can be done in either direction.

enter image description here


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.