Elevator Doors

View as PDF

Submit solution

Points: 3
Time limit: 2.0s
Memory limit: 128M

Author:
Problem type

When a person presses the button to go into an elevator, the elevator on the nearest floor will travel to the user's floor and open its doors. You are tasked to determine which elevator out of two will open its doors for the person that presses the button.

Input Specification

There are three types of floors in the building: The main floors, the ground floor, and the parking floor. There will be three lines of input, all of them being a character that denotes the floors. The main floors are integers in the range of 1-9. The ground floor, below the main floors, is represented by the letter G. Finally, the parking floor, the lowest floor, is represented by the letter P.

The first line is the floor that the button for the elevator was pressed.

The second and third lines are the floors where the first and second elevator are, respectively.

Output Specification

Print out the number of the elevator that will open for the passenger: 1 for the first elevator, 2 for the second elevator, or, if both are equally as close, print 0 instead.

Sample Input

3
4
1

Sample Output

1

Comments

There are no comments at the moment.