Question: Problem # 3 : Spinning Up the Robot Suppose you are programming a robot that needs to spin its flywheel to a specific speed before

Problem #3: Spinning Up the Robot
Suppose you are programming a robot that needs to spin its flywheel to a specific speed before it can shoot a ball. The wheel spins around and around for many rotations (while-loop iterations) until it reaches the minimum required speed and then shoots the ball. Complete the function when_shoot, which returns the iteration during which the ball could be shot because the flywheel has reached the required minimum speed. The first iteration is iteration #0. The function takes three parameters:
ramp_rate: the number of rotations per minute (rpm) the flywheel increases per iteration
set_speed: the minimum rpm needed before the robot can shoot
hits: a list of iteration #s in which the robot gets hit by another robot. If the robot gets hit during an iteration, its speed decreases by 30 rpm instead of increasing by ramp_rate.
Function Call
Expected Return Value (integer)
when_shoot(15,10,[0])
1
when_shoot(5,3000,[3,10,100,500])
624
when_shoot(10,2500,[15,103,200])
261
when_shoot(15,4000,[26,105,137,265])
278
when_shoot(5,300,[3,4,59])
71

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!