WeVerve - Programming Challenge
WeVerve - Programming Challenge
Context
There are 2 super fast trains, Train A and Train B. Train A travels from Chennai to New
Delhi. Train B travels from Trivandrum to Guwahati.
The routes with station code and distances of each station from originating station
are as follows: (STATION (CODE) - DISTANCE ):
Train A Train B
The Merger
During a part of their journey, these trains follow the same route and travel as one
train - Train AB.
● Trains start from their respective source stations and meet at Hyderabad.
● Trains travel as Train AB from Hyderabad till Bhopal as a single train.
● From Bhopal the trains travel again as two independent trains, Train A and
Train B.
● Train A can have passengers in the route for Train B and vice versa. Eg: People
can board from Chennai in Train A and travel to Guwahati.
Merging Rules
Goal
Given the initial bogie order of both trains, your program should print :
Assumptions
Input format
Your program should take as input the order of bogies of each train from the source station
Examples :
TRAIN_A ENGINE NDL NDL KRN GHY SLM NJP NGP BLR
Output format
Examples :
DEPARTURE TRAIN_AB ENGINE ENGINE GHY GHY NJP NJP PTA NDL NDL AGA BPL NGP
WEVERVE SYSTEMS, INC
Sample Input/Output 1
INPUT OUTPUT
Sample Input/Output 2
INPUT OUTPUT