Train station¶
The head of the Sant Ts train station has designed a system to distribute the different commuter trains between the different station tracks. There are 4 train lines: 1, 2, 3 and 4 and two possible orientations, N (North) and S (South). The distribution rules are the following:
Line 1 North –> track 1
Line 1 South –> track 5
Line 2 North –> track 4
Line 2 South –> track 9
Line 3 North –> track 12
Line 3 South –> track 2
Line 4 North –> track 10
Line 4 South –> track 7
Write the function stop() that gets an integer that
represents the train line and a letter (string) that represents the
orientation and returns the corresponding track number (integer). If
either the line or the orientation are not valid, the function must
return 0. Save this function into a file named stop.py. Examples:
>>> stop (1, 'N') 1 >>> stop (1, 'S') 5 >>> stop (2, 'N') 4 >>> stop (2, 'S') 9 >>> stop (3, 'N') 12 >>> stop (3, 'S') 2 >>> stop (4, 'N') 10 >>> stop (4, 'S') 7 >>> stop (2, 'K') 0 >>> stop (7, 'N') 0Note
More tests are provided in the
test-stop.txt
Solutions
A solution of these functions is provided in the stop.py