[Solution] Nearest Exit CodeChef Solution
Problem
There are two exits in a bus with seats:
- First exit is located beside seat number .
- Second exit is located beside seat number .
Seats are arranged in a straight line from to with equal spacing between any adjacent seats.
A passenger prefers to choose the nearest exit while leaving the bus.
Determine the exit taken by passenger sitting on seat .
Input Format
- The first line of input will contain a single integer , denoting the number of test cases.
- Each test case consists a single integer , denoting the seat number.
Output Format
For each test case, output LEFT
if the passenger chooses the exit beside seat , RIGHT
otherwise.
You may print each character of the string in uppercase or lowercase (for example, the strings LEFT
, lEft
, left
,
and lEFT
will all be treated as identical).
Explanation:
Test case : The exit is located beside seat . Hence, the passenger can take this exit without moving to any other seat.
Test case : To take exit at seat , the passenger needs to move seats. However, to take the exit at seat , the passenger needs to move seats. Thus, exit at seat is closer.
Test case : The exit is located beside seat . Hence, the passenger can take this exit without moving to any other seat.
Test case : To take exit at seat , the passenger needs to move seats. However, to take the exit at seat , the passenger needs to move seats. Thus, exit at seat is closer.
No comments:
Post a Comment