• Post Reply Bookmark Topic Watch Topic
  • New Topic

i need help starting this code  RSS feed

 
Jonothon Turner
Greenhorn
Posts: 20
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
implementing a rail road yard simulation program. where The user will provide a set of incoming cars, and then a desired outgoing order. Your program will determine if the given incoming cars can be rearranged to the desired outgoing order or not. what I am confused about is how to sort by the desired order?
 
Stephan van Hulst
Saloon Keeper
Posts: 7969
143
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to CodeRanch, Jonothon!

You can solve this problem recursively: given a set of incoming cars and a rail yard, first decide what to do with one of the cars (by sending it to one of the tracks) and then repeat the algorithm for the rest of the cars and the same rail yard instance.

How to solve the problem exactly depends on what you're allowed to do with the rail yard. How many trains are you allowed to send to each track, how many tracks are there, etc.

Do you have a more precise problem description?
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!