Robot Steps

 avatar
unknown
plain_text
2 years ago
566 B
8
Indexable
Q : A robot moves in a plane starting from the original point (0,0). The robot can move toward UP, DOWN, LEFT and RIGHT with a given steps. The trace of robot movement is shown as the following:

commands = [ "UP 7", "LEFT 1", "DOWN 2", "RIGHT 5", "RIGHT 2"]

Please write a program to compute the distance from current position after a sequence of movement and original point. If the distance is a float, then just print the nearest integer.



----------------------------------------------
Example:
commands = ["UP 5", "DOWN 3", "LEFT 3", "RIGHT 2"]
Answer is : 2
Editor is loading...