Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Will rate if done in python def climbing(heights,rest,limit): Assumption: 'heights' is a nonempty list of positive integers that are strictly increasing and both 'rest'

Will rate if done in python

def climbing(heights,rest,limit):
"""
Assumption: 'heights' is a nonempty list of positive integers that are
strictly increasing and both 'rest' and 'limit' are positive integers.
The list 'heights' is the various heights (in feet) of ledges on a cliff.
The value 'rest' represents how many seconds you have to rest between
climbing "bursts" (see the description below).
The value 'limit' is how many seconds you have to climb the cliff, and is
guaranteed to be at least the last height in the list.
Suppose you are able to climb 1 foot per second consecutively for a certain
amount of time, let's call this time 'burst'. However, after at most 'burst'
seconds you have to rest for 'rest' seconds on one of the ledges of the
cliff to regain your stamina. You cannot rest while hanging on to the cliff,
you have to be on a ledge when you rest. You rest the same amount of time
even if your latest climb was not for 'burst' seconds.
What is the minimum value of 'burst' such that you are able to reach the
highest ledge in at most 'limit' seconds?
Example 2:
climbing([50, 100], 1, 100)
100
That is, you can reach the top in a single burst if you can climb for 100
seconds consecutively.
However, if you can only climb for 99 seconds consecutively then the best
you can do is reach ledge 50, rest for 1 second, then reach the top for a
total of 101 seconds.
Example 3:
climbing([50, 99], 1, 100)
50
That is, if you can climb for 50 seconds consecutively then you can reach
the ledge at height 50 in your first burst, rest for 1 second, then reach
the top after 49 more seconds for a total of 100 seconds.
But if you can only climb for 49 seconds consecutively then you can't even
reach the first ledge!
"""
pass

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

Students also viewed these Databases questions