subject

A certain robot can perform only 4 types of movement. It can move either up or down or left or right. These movements are represented by ’U’, ’D’, ’L’, ’R’. Assume all these movements to be of unit distance. Write a function named theRoundTrip that takes all the movements the robot made in a day as input and output True of bool type if the robot returned to its starting position after its journey. Otherwise return False. If the input is bad print the message "bad input" and return to solve the next question.

Have a main function from which the answer to questions are retrieved and run the program as a whole.

Examples:
Test Case 1:
input: movement = [’U’, ’L’, ’D’, ’R’]
output: True
Explanation: In a 2D plane a unit movement up by 1, left by 1, down by 1 and right by 1 would result in arriving at the starting posistion. So we return True.

Test Case 2:
input: movement = [’U’, ’U’, ’R’, ’L’, ’D’, ’R’]
output: False
Explanation: After traversing this movement we see that we have not arrived at the start- ing position. So we return False.

Test Case 3:
input: movement = [’U’, ’U’, ’I’, ’L’, ’D’, ’R’] output: bad input

ansver
Answers: 1

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 11:30
To hide gridline when you display or print a worksheet
Answers: 1
question
Computers and Technology, 23.06.2019 11:50
While preforming before operation pmcs, you notice the front right tire appears slightly under-inflated. what is the proper action?
Answers: 3
question
Computers and Technology, 24.06.2019 06:30
Adrawing that places all lines parallel to the z axis at an angle from the horizon is 99 ! a. an oblique drawing b. a perspective drawing c. an auxiliary view d. a one-point perspective drawing
Answers: 2
question
Computers and Technology, 24.06.2019 15:30
What is not a type of text format that will automatically be converted by outlook into a hyperlink?
Answers: 1
You know the right answer?
A certain robot can perform only 4 types of movement. It can move either up or down or left or right...
Questions
question
Mathematics, 19.05.2020 14:02
question
English, 19.05.2020 14:02
question
Mathematics, 19.05.2020 14:02
Questions on the website: 13722361