Hacker Newsnew | past | comments | ask | show | jobs | submitlogin

Well it's not really fun nor a puzzle, they simply can't pass each other, and the dispatcher will have to look for the next suitable sidings.


As a puzzle, suppose ABC is going that way -> and and 123 is going <- that way, each 3 miles long, broken into segments A/B/C and 1/2/3, respectively. Let '-' be the siding, able to hold a mile-long set of cars.

   ABC ... 123
       `-'
Move C into _, uncouple from AB, and back AB to return to the mainline.

    AB ... 123
       `C'
Move AB and 123 to the left, past the siding:

   AB123 ... 
         `C'
Uncouple 1, move 23 into the siding to couple to C, and return C to the mainline:

     AB1 ... 23C
         `-'
Uncouple 23 from C, pick up 1, and move back to the right side of the siding:

      AB ... 123.C
         `-'
You've now gotten C past 123. Repeat with B then A, leaving the track as 123 ... ABC.

This solution limits the maximum length to 3 miles. A 4 mile long solution would keep 1 coupled to 23 while moving C from the siding back to the mainline.




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: