Question: answer it by using python program You have been given two stepladders and two small robots that can climb up and down the ladders, one
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 indexl or position1) 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 positionl is less than position2, then return 2. Otherwise, return 0 Examples: Function Call Return Value robot.competition(['F,'B,'B,A,'R,'F'F', 0 robot.competition(L'F,'B,B'A'R,F,F'1, 2 robot.competition ([), [)
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
