365. Railway Switch. How can two trains pass each other using the switch depicted here and continue moving forward with their locomotives? The small side spur is only sufficient to accommodate either a locomotive or one car at a time. No tricks with ropes or flying are allowed. Each change of direction made by one locomotive counts as one move. What is the minimum number of moves?

![](https://cdn.mathpix.com/cropped/2024_05_21_56f37ca27ac3d928838dg-118.jpg?height=207&width=1154&top_left_y=1227&top_left_x=451)

For a more convenient solution, draw the railway tracks on a piece of paper and place a hryvnia coin and three two-kopek coins (heads up) to represent the left train, and a hryvnia coin with two two-kopek coins (tails up) to represent the right train.
365. Draw the path diagram as shown in the figure, take 5 chips marked \(X, L, R, A\) and \(B\). The locomotives are \(L\) and \(R\), the two cars on the right are \(-A\) and \(B\). The three cars on the left should not be separated, so we will denote them as \(X\). The dead-end is marked as \(S\). Next,

![](https://cdn.mathpix.com/cropped/2024_05_21_56f37ca27ac3d928838dg-274.jpg?height=251&width=811&top_left_y=1825&top_left_x=631)

proceed as follows: \(R\) to the left, \(R\) to \(S, X L\) to the right, \(R\) to the left, \(X L A\) to the left, \(L\) pushes \(A\) to \(S, L\) to the left, \(X L\) to the right, \(R\) to \(A, R A\) to the left, \(X L B\) to the left, \(L\) directs \(B\) to \(S, L\) to the left, \(L X\) to the right, \(R A\) to \(B, R A B\) straight. In total, it took 14 moves, since in the first and third moves (\(R\) to the left and \(X L\) to the right) there is no change in direction. It is impossible to solve the problem in fewer moves.