Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

answer it by using python program
image text in transcribed
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

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

7th edition

978-1111825911, 1111825912, 978-1133684374, 1133684378, 978-111182591

More Books

Students also viewed these Databases questions