I need help with a python problem. I have to write a program that can calculate the euclidean distance (d = x2+ y2) of a robot. The robot starts at the origin (0,0) and is facing North. The robot can...


I need help with a python problem. I have to write a program that can calculate the euclidean distance (d = x2+ y2) of a robot. The robot starts at the origin (0,0) and is facing North. The robot can receive 3 possible commands:




  • -2: turn left by 90 degrees




  • -1: turn right by 90 degrees




  • 1




in its path, the robot can come across obstacles. The ithobstacle has coordinates (obstacle[i][0], obstacle[i][1]). When the robot meets an obstacle it goes down by 1 and continues to execute the sequence till the end.


example 1:


commands = [4,-1,3]
obstacle = []


output: The robot is at distance of: 25
(It's at the point (3,4) )






example 2:


commands = [4,-1,4,-2,4]
obstacle = [(2,4)]


output: The robot is at a distance 65.
(The robot gets stuck at (1,4) before turning left and finishing at (1,8) )

Mar 13, 2021
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here