The manager of Sants station has designed a system for assigning arriving commuter trains to the station’s tracks. There are four commuter rail lines, 1, 2, 3, and 4, and two possible directions: ”N” (north) and ”S” (south). The track assignments are as follows. For line 1, northbound trains use track 8 and southbound trains use track 7. For line 2, the tracks are 10 (north) and 9 (south). For line 3, the tracks are 12 (north) and 13 (south). Finally, for line 4, the tracks are 14 (north) and 15 (south).
Design the function cercanias(linea,sentido), which
takes a positive integer
representing the commuter rail line and a character
indicating the direction (”N” for north and ”S” for south), and returns
the corresponding track number. If the line or direction is invalid, the
function must return 0.
>>> cercanias(3,'N') 12 >>> cercanias(7,'N') 0 >>> cercanias(4,'S') 15 >>> cercanias(2,'W') 0