Taxi zum zum def taxi_zum_zum(moves): A taxicab cruising around the Manhattan street grid starts at the origin (0,0) of the infinite twodimensional lattice grid of all pairs of integers, denoted by ℤ2. This taxicab has a direction that is always one of the four main compass directions, initially heading north. The taxicab then faithfully executes the given sequence of moves, guaranteed to be a string made up of the characters 'L' for turning 90 degrees left (while standing in place), 'R' for turning 90 degrees right (ditto), and 'F' for moving one step forward towards the current heading. This function should return the final position of the taxicab in the integer grid coordinates of this infinitely spanning Manhattan. moves expected result 'RFRL' (1, 0) 'LFFLF' (-2, -1) 'LLFLFLRLFR' (1, 0) 'FR' * 1000 (0, 0)
Taxi zum zum
def taxi_zum_zum(moves):
A taxicab cruising around the Manhattan street grid starts at the origin (0,0) of the infinite twodimensional lattice grid of all pairs of integers, denoted by ℤ2. This taxicab has a direction that is
always one of the four main compass directions, initially heading north. The taxicab then faithfully executes the given sequence of moves, guaranteed to be a string made up of the characters 'L' for turning 90 degrees left (while standing in place), 'R' for turning 90 degrees right (ditto), and 'F'
for moving one step forward towards the current heading. This function should return the final position of the taxicab in the integer grid coordinates of this infinitely spanning Manhattan.
moves | expected result |
'RFRL' | (1, 0) |
'LFFLF' | (-2, -1) |
'LLFLFLRLFR' | (1, 0) |
'FR' * 1000 | (0, 0) |
'FFLLLFRLFLRFRLRRL' | (3, 2) |
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images