Elevator (Codeforces 120A)
Tags: Implement, brute force

A sky scraper with 1000 floors has been built in the city of N. It has modern superfast elevators to help to travel from one floor to another. Each elevator has two doors, the front one and the back one. If one goes in through the front door, he goes out through the back one and vice versa. The elevator has two rails numbered with numbers 1 and 2. Rail 1 is located to the left of the entrance to the front door (or correspondingly, to the right of the entrance to the back door). Rail 2 is located opposite it, to the right of the entrance to the front door and to the left of the entrance to the back door. We know that each person in the city of N holds at a rail with the strongest hand. One day a VIP person visited the city and of course, he took a look at the skyscraper and took a ride in the elevator. We know the door through which he entered and the rail he was holding at. Now we need to determine as soon as possible whether he is left-handed or right-handed.

Input: The first line indicates the door through which the very important person entered the elevator. It contains "front" if the person enters the elevator through the front door and "back" if he entered the elevator through the back door. The second line contains integer a (1 ≤ a ≤ 2) which denotes the number of the rail at which the person was holding.

Output: Print character "R" if the VIP is right-handed or "L" if he is left-handed.


Sample Inputs:
front
1

Sample Outputs:
L

Solution (Python):
import sys
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
line_one = str(input())
line_two = str(input())
if line_one == 'front':
    if line_two == '1':
        print('L')
    if line_two == '2':
        print('R')
if line_one == 'back':
    if line_two == '2':
        print('L')
    if line_two == '1':
        print('R')

Solution (Python):
f1 = open('input.txt', 'r')
f2 = open('output.txt', 'w')
x = f1.readline()
y = f1.readline()
if x[0] == 'f' and y[0] == '1':
    f2.write('L')
    f2.close
elif x[0] == 'f' and y[0] == '2':
    f2.write('R')
    f2.close
elif x[0] == 'b' and y[0] == '2':
    f2.write('L')
    f2.close
else:
    f2.write('R')
    f2.close
f1.close

Solution (Python):
import sys
sys.stdin = open('input.txt', 'r')
sys.stdout = open('output.txt', 'w')
x = str(input())
c = int(input())
if x == 'front' and c == 1 or (x == 'back' and c == 2):
    print('L')
else:
    print('R')