Here is the completed code for this problem. Comments are included, go through it, learn how things work and let me know if you have any doubts or if you need anything to change. If you are satisfied with the solution, please rate the answer. Thanks
#code
#REQUIRED METHOD
def taxi_zum_zum(moves):
#creating a list of directions
directions=['N','E','S','W']
#dir points the current index of
directions
dir=0
#current position
x=0
y=0
#looping through each character in
moves
for i in
moves:
#if character is L,
turning left
if
i=='L':
#decrementing dir
dir-=1
#if dir goes below 0, starting from other side
if dir<0:
dir=3
elif
i=='R':
#doing the same for turning right
dir+=1
if dir>3:
dir=0
elif
i=='F':
#in the question it was M for moving forward, but in the given
output,
#it is shown as F. Also, in common logic, x should be incrementing
while
#going east and decrementing while going west. but according to the
sample
#run, it is just opposite, clearly someone is high when writing
this question.
#anyway, I have written this solution according to the given output
only.
if directions[dir]=='N':
y+=1 #going up/north
elif directions[dir]=='S':
y-=1 #going down/south
elif directions[dir]=='E':
x-=1 #going east/right
elif directions[dir]=='W':
x+=1 #going west/left
#returning a tuple containing final
position
return (x,y)
#testing
print(taxi_zum_zum('RFRL'))
print(taxi_zum_zum('LLFLFLRLFR'))
print(taxi_zum_zum('FR'*1000))
print(taxi_zum_zum('FFLLLFRLFLRFRLRRL'))
#output
(-1, 0)
(-1, 0)
(0, 0)
(-3, 2)
Please help me with a solution using Python Taxi zum zum def taxi zum_zum(moves) : A...