2 grammar

# Python3 (288)

Implementation using heavy use of ternary ifs.

m=['N','E','S','W']
cords=[int(n) for n in input().split()] + [input()] #Convert first inputs to integers and retrieve third
for n in input(): #Get instructions
if n=='M':
i=[1,0][cords in m[1:3]] #See if vertical or horizontal
j=[-1,1][cords in m[0:2]] #See if negative or positive
cords[i]+=j
else:
i=[-1,1][n=='R'] #Translate turn to numerals
cords=m[m.index(cords)+i] #Change direction relative to current orientation
print(cords)


Omitting the obvious input grumbles, giving the direction strings intrinsic values may have benefited the script size. However, the approach here is perfectly functional (so I believe)

# Python3 (288)

Implementation using heavy use of ternary ifs.

m=['N','E','S','W']
cords=[int(n) for n in input().split()] + [input()] #Convert first inputs to integers and retrieve third
for n in input(): #Get instructions
if n=='M':
i=[1,0][cords in m[1:3]] #See if vertical or horizontal
j=[-1,1][cords in m[0:2]] #See if negative or positive
cords[i]+=j
else:
i=[-1,1][n=='R'] #Translate turn to numerals
cords=m[m.index(cords)+i] #Change direction relative to current orientation
print(cords)


Omitting the obvious input grumbles, giving the direction strings intrinsic may have benefited the script size. However, the approach here is perfectly functional (so I believe)

# Python3 (288)

Implementation using heavy use of ternary ifs.

m=['N','E','S','W']
cords=[int(n) for n in input().split()] + [input()] #Convert first inputs to integers and retrieve third
for n in input(): #Get instructions
if n=='M':
i=[1,0][cords in m[1:3]] #See if vertical or horizontal
j=[-1,1][cords in m[0:2]] #See if negative or positive
cords[i]+=j
else:
i=[-1,1][n=='R'] #Translate turn to numerals
cords=m[m.index(cords)+i] #Change direction relative to current orientation
print(cords)


Omitting the obvious input grumbles, giving the direction strings intrinsic values may have benefited the script size. However, the approach here is perfectly functional (so I believe)

1

# Python3 (288)

Implementation using heavy use of ternary ifs.

m=['N','E','S','W']
cords=[int(n) for n in input().split()] + [input()] #Convert first inputs to integers and retrieve third
for n in input(): #Get instructions
if n=='M':
i=[1,0][cords in m[1:3]] #See if vertical or horizontal
j=[-1,1][cords in m[0:2]] #See if negative or positive
cords[i]+=j
else:
i=[-1,1][n=='R'] #Translate turn to numerals
cords=m[m.index(cords)+i] #Change direction relative to current orientation
print(cords)


Omitting the obvious input grumbles, giving the direction strings intrinsic may have benefited the script size. However, the approach here is perfectly functional (so I believe)