挑战Python100题(3)

100+ Python challenging programming exercises 3

Question 21

Question 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: UP 5 DOWN 3 LEFT 3 RIGHT 2 ¡­ The numbers after the direction are steps. 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: If the following tuples are given as input to the program: UP 5 DOWN 3 LEFT 3 RIGHT 2 Then, the output of the program should be: 2

Hints: In case of input data being supplied to the question, it should be assumed to be a console input.

问题:机器人从原点(0,0)开始

猜你喜欢

转载自blog.csdn.net/boysoft2002/article/details/135164236