# Railway problems

1) Two trains pass

In the old days when single track was still customary, two trains met at the spot of a side track. The track was long enough to hold 1 engine and 4 wagons or 5 wagons. That corresponded with every day traffic, but yesterday was a strike and now both trains pull 8 wagons.
An extra complication is a not-so-strong bridge at the right end of the side track, which no engine may pass, though it is strong enough for normal wagons.
Both engines can both push and pull wagons with their front- and rear ends.
If both a stop and a reversal of direction of an engine counts as 1 move, what is the minimum number of moves needed for the two trains to pass each other?

If you wish you can check your solution

According to the English language wikipedia, there are about several categories of railway shunting puzzles. This post is about one of these categories, where a train or trains have to be maneuvered around a given track with some limitations.

The history of train shunting puzzles can’t go back further then that of railroads themselves, but a quick Google search did not reveal much.

British puzzle master Henry Dudeney also seems to have published several puzzles in this class, but his American counterpart Sam Loyd published two of them in his Encyclopedia of Puzzles. Besides these two, there is one classical which I’d like to present to you, if only because it’s the first one I ever encountered.

On page 89 of the cyclopedia of puzzles Sam Loyd poses the following problem:

Owing to the widespread interest taken in a simple railroad switch problem which I sprung on my friends some time ago, as well as in response to the request from many for another practical lesson in railroading, I present one which is an offshot from the first, and illustrates the difference between sidetracking a train or passing it through an y-branch., which reverses the direction of the trains.
In this specimen of primitive railroading we have an engine and four cars meeting an engine and three cars, and the problem, as in the previous one, is to ascertain the most expeditious way of passing the two trains by means of the switch or side track, which is only large enough to hold one engine or one car at a time.
No ropes, poles or flying switches are to be used, and it is understood that a car can not be connected to the front of an engine. It shows the primitive way of passing trains before the advent of modern methods, and the puzzle is to tell just how many times it is necessary to back or reverse the direction of the engines to accomplish the feat, each reversal of an engine being counted as a move in the solution.

This puzzle also appeared as nr 48 in Henry Dudeneys “Modern Puzzles”, and as nr 95 in Martin Gardners selection from Loyds Encyclopedia of Puzzles.

If you wish you can check the solution

3) The Switch Problem
Further down in his collection, on page 167, Sam Loyd presents a second problem. You may have noted that in the problem above Sam Loyd referred to a ‘first’ puzzle in this class, and I suppose that he had this puzzle in mind, even though this puzzle is listed after the first. The puzzle collection was probably first published in same daily or weekly newspaper column, and collected afterwards in his cyclopedia. According to Donald Knuth’s reference, the switch problem appeared in the Brooklyn Daily Eagle on 14 March 1897.

This is a practical problem for railroadmen, given to illustrate some of the complications of every-day affairs and is based upon the reminiscences of the days when railroading was in its infancy, before the introduction of double tracks, turn tables or automatic switches.
Yet, I am not going back to the days of our great-grandfathers, for there are those among us who are familiar with the advent of the iron horse, and the good lady who furnished me with the subject matter of the puzzle based it upon personal experience of what she called “the other day”. To tell the story in her own way, she said:
“We had just arrived at the switch station, where the trains always pass, when we found that the Limited Express had broken own. I think the conductor man said the smokestack had got hot and collapsed, so there was no draught to pull it off the track.”

The picture shows the Limited Express, with its collapsed engine, and the approach of the accommodation train from Wayback, which, by some means or other, must pass the stalled train.

The problem being to make the two trains pass, it is understood, that no ropes, poles, flying switches, etc. are to be employed; it is a switch puzzle pure and simple, the object being to get the accommodation train past the wreck and leave the latter train and each of its cars in the position as shown in the sketch.
It is necessary to say that upon the side switch there is but room enough for one car or engine, which is also true of the sections of the switch A, B, C and D.
The problem is tom tell just how many times the engineer must reverse; that is, change the direction of his engine to perform the feat. Of course the broken down engine can not be used as a motor, but must be pushed or pulled along just as if it were a car. The cars may be drawn singly or coupled together in any required numbers.
The problem complies with ordinary rules of practice and it is given to test your ingenuity and cleverness in discovering the quickest possible way to pass the broken down train.

This problem appeared as Puzzle no 30 in Tit Bits, and on March 14, 1897 in the Brooklyn Daily Express.

If you wish you can check the solution

4) Dudeney’s puzzle of passing two trains
How are the two trains in our illustration to pass one another, and proceed with their engines in front? The small sidetrack is only large enough to hold one engine or one car at a time, and no tricks such as ropes or flying switches, are allowed. Every reversal – that is, change of direction – of one of the engines is counted as a move in the solution. What is the smallest number of moves necesary?

To work on the problem, make a sketch of the track, and on it place a nickel and three pennies (heads up) for the engine and cars at the left, and a nickel and two pennies (tails up) for the engine and two cars on the right.
As you can see, this puzzle is identical to one of Sam Loyds puzzles above, so I’m not gonna publish the solution again. This version comes from Dudeney’s collection: 536 puzzles and curious problems, a collection published after Dudeneys death. In this book, it was puzzle 374.

5) Dudeney’s chifu chemulpo puzzle
Here is a puzzle that was once on sale in the London shops. It represents a military train—an engine and eight cars. The[Pg 135] puzzle is to reverse the cars, so that they shall be in the order 8, 7, 6, 5, 4, 3, 2, 1, instead of 1, 2, 3, 4, 5, 6, 7, 8, with the engine left, as at first, on the side track. Do this in the fewest possible moves. Every time the engine or a car is moved from the main to the side track, or vice versa, it counts a move for each car or engine passed over one of the points. Moves along the main track are not counted. With 8 at the extremity, as shown, there is just room to pass 7 on to the side track, run 8 up to 6, and bring down 7 again; or you can put as many as five cars, or four and the engine, on the siding at the same time. The cars move without the aid of the engine. The purchaser is invited to “try to do it in 20 moves.” How many do you require?

If you wish you can check the solution

6) Dudeney published a third puzzle, Mudville railway muddle, with two trains (engine + 40 cars each), which have to pass each other, but I have not been able to locate this puzzle. Professors Knuth short summary suggests to me that it is a simplified version of the puzzle at the top of this blog.

7)Anonymous classic

Move the engine so that the two wagons are interchanged and the engine is in the same spot again. The wagons can not pass through the tunnel, but the engine can. The engine can both push and pull with its front and rear, and even do both at the same time when that comes in handy. What is the minimum number of stops or reversals of direction of the engine that is needed?

If you wish you can check the solution

8)Anonymous classic variation

This puzzle is identical with the previous one, but the extra track allows for a faster solution. It can be found freely in many books and magazines.

(Thanks go to my daughter Margreet for the last two illustrations!)

If you wish you can check the solution

The puzzle at the start of this post was designed by me some 20 years ago. No doubt it was based on one of the many adaptions of puzzle 5. I recently rediscovered a page with notes om railway shunting puzzles, and one of them was this puzzle which I didn’t publish before.

I also would like to thank Professor Don Knuth for his laborious work in compiling indices on the works of Dudeney en Loyd. Most of the historical notes in this post are based on his indices.

9) Online puzzles: at armorgames
There are a couple of sites where you can play online: