Seating Arrangement (Hackerearth)

Akash and Vishal are quite fond of travelling. They mostly travel by railways. They were travelling in a train one day and they got interested in the seating arrangement of their compartment. The compartment looked something like


So they got interested to know the seat number facing them and the seat type facing them. The seats are denoted as follows :

  • Window Seat : WS
  • Middle Seat : MS
  • Aisle Seat : AS

You will be given a seat number, find out the seat number facing you and the seat type, i.e. WSMS or AS.

INPUT
First line of input will consist of a single integer T denoting number of test-cases. Each test-case consists of a single integer N denoting the seat-number.

OUTPUT
For each test case, print the facing seat-number and the seat-type, separated by a single space in a new line.

CONSTRAINTS
  • 1<=T<=105
  • 1<=N<=108
SAMPLE INPUT
 
2
18
40
SAMPLE OUTPUT
 
19 WS
45 AS

Solution
def find(a):
ch = a%12
if ch==1:
print(a+11,'WS')
elif ch==0:
print(a-11,'WS')
elif ch==6:
print(a+1,'WS')
elif ch==7:
print(a-1,'WS')

elif ch==2:
print(a+9,'MS')
elif ch==3:
print(a+7,'AS')
elif ch==4:
print(a+5,'AS')
elif ch==5:
print(a+3,'MS')
elif ch==8:
print(a-3,'MS')
elif ch==9:
print(a-5,'AS')
elif ch==10:
print(a-7,'AS')
else:
print(a-9,'MS')


n = int(input())
for i in range(n):
a = int(input())
find(a)

Comments

Popular posts from this blog

Sort in specific order (GFG)

Chef and Remissness Problem Code: REMISS (CodeChef)

Short Notes Of computer Network