Question: Python Part IV: Debugging (10 points) You have been given two stepladders and two small robots that can climb up and down the ladders, one
Python Part IV: Debugging (10 points) You have been given two stepladders and two small robots that can climb up and down the ladders, one step at a time. The robots can be programmed using a language that contains exactly three commands, which are always given using uppercase letters: , F, , , B, and , R' . The command 'F' moves a robot up the ladder by 1 position: 'B' moves a robot down by 1 position (unless the robot is already at position 0; and R' resets the robot back to position 0. Any invalid commands are ignored by the robot. Fix the function robot.competition that takes the following arguments, in this order: I, robot 1: a list of commands for Robot #1 2. robot 2: a list of commands for Robot #2 This function is supposed to calculate which robot has moved the furthest from the starting position based on the commands given to it. Note: In the provided source code, any variable ending with 1 (such as index1 or positionl) is used for Robot #1 . Likewise, an ending of 2 indicates a variable for Robot #2. After iterating over all the elements of both the lists, compare positionl and position2. If positionl is greater than position2, then return 1. If position1 is less than position2, then return 2. Otherwise, return 0 Examples on Return Value robot.competition ('F,'B,'B,A'R, 'F,'F', robot.competition (['F'B,B, 'A,'R',F,'F robot.competition (, [) Remember: CodeLoad has additional tests for you to try! Upload your code there and see how your code matches up against harder tests
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
