Metro Problem
Submissions: 751   Accuracy:

38.41%

  Difficulty: Basic   Marks: 1

Metro roams in a city of 20 stations, Starting from Station number 0 to last station 19. It Stops at each station for 1 sec (neglect the time of station switching). A Guy daily waits at station number 11 for the train, your task is to calculate time he has to wait to catch up the train.

Input:
First line contains t, test cases.
Each test case consists of an integer (X) and a character (C). X denotes the current position of the metro while C denotes its direction(U for up and D for down) as visible to that Guy.
Note: Where UP denotes that train is going towards last Station and Down denotes the vice versa. 

Output:
For each test case print the minimum time (in seconds) after which he will be able to catch the metro in a new line.

Constraints:
1<=T<=100
0<=X<=19

Example:
Input: 
4
19 D
0 U
15 U
10 D
Output: 
8
11
12
21

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Saksham Raj Seth
Author: saksham seth


If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.



Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.