It's a question that has brought dread to high school math students for generations: "Two trains leave Chicago" on different routes at different speeds, which one will reach St. Louis first? A court ruling may throw a new variable into the mix: Is the train carrying freight or passengers?

The U.S. Court of Appeals for the District of Columbia Circuit on Friday struck down a 2008 law intended to make sure that Amtrak passenger trains arrived on time, even if that meant freight trains had to cool their heels while Amtrak rushed through.

Just who will ultimately decide the fate of passengers versus freight — the Supreme Court or Congress — wasn't immediately clear after the latest round in a five-year court battle that the freight railroads have waged against Amtrak and the Federal Railroad Administration (FRA).

To understand the case and the ruling requires a trip back to the creation of Amtrak in 1970. With the nation's private passenger rail service in crisis, Congress stepped in to establish a unique corporation to take over from the faltering rail lines. It created a private, for-profit company that was endowed with extraordinary powers, all in the interest of revitalizing passenger rail service in an era that saw airlines stealing travelers away.

Among those powers: Amtrak got priority over the freight rail trains when it came to scheduling. This despite the fact that the freight railroads own and maintain the entire U.S. rail system outside the Northeast corridor. Congress decided it needed to clarify just what that meant in 2008, so it passed another law that said Amtrak and the FRA should come up with a way of defining "priority." And, Congress said, if the freight railroads did anything to violate those defining metrics, Amtrak could appeal to the federal Surface Transportation Board for relief.

Amtrak and the FRA decided that if 80 percent of Amtrak's trains got to the station on schedule everything would be copacetic.

Welcome aboard! Steam locomotives have been around since 1800s, and now we're getting Bullet Trains! See where train technology has been, and where it's going!

Welcome aboard! Steam locomotives have been around since 1800s, and now we're getting Bullet Trains! See where train technology has been, and where it's going!

The freight railroad trade group, the Association of American Railroads (AAR), filed suit in 2011. The case made it to the U.S. Supreme Court, which sent it back to the D.C. appeals court.

The appeals court ruled on Friday that the law was unfair because it allowed Amtrak a hand in setting the rules for the industry of which it was a part. In essence, Amtrak was playing the role of a regulator rather than a competitor for the right to use the rail lines.

After the ruling came down, none of the parties — the AAR, Amtrak or the FRA — said they were sure what step came next.

Amtrak issued a statement saying it was disappointed by the ruling.

"The members of Congress from both parties who approved that law intended to ensure that Amtrak trains receive priority over freight trains. We hope that this legal morass will be resolved soon," the Amtrak statement said.

The AAR applauded the court's determination that "there was a fundamental constitutional flaw in allowing Amtrak to regulate freight railroads."