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, 23.06.2019 13:30
What is the primary difference between the header section of a document and the body? a. the body is displayed on the webpage and the header is not. b. the header is displayed on the webpage and the body is not. c. the tag for the body is self-closing, but the tags for the headers must be closed. d. the tag for the header is self closing, but the tag for the body must be closed.
Answers: 3
question
Computers and Technology, 24.06.2019 03:30
Which explains extrinsic motivation? a)motivation in which there is a reward b)motivation that is personally satisfying c)motivation that is personally meaningful d)motivation in which the subject is interesting
Answers: 1
question
Computers and Technology, 24.06.2019 19:20
Which command suppresses the visibility of a particular row or column in a worksheet?
Answers: 1
question
Computers and Technology, 25.06.2019 02:30
Ahammer should not be applied to the gear shafts of an electric rotisserie because the shafts may be made of
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
History, 08.07.2019 17:10
question
History, 08.07.2019 17:10
Questions on the website: 13722360