Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Description:(PYTHON) John was sitting near to a fireplace in his house, trying to get some warmth from the fire. Fighting his cold at the end

image text in transcribed

Description:(PYTHON) John was sitting near to a fireplace in his house, trying to get some warmth from the fire. Fighting his cold at the end of a freezing, short, dark winter day, he started wondering why it always had to be so cold during this season. That was when he came up with an idea. John stated that winter is the initial part of the year in which it is always colder than in the remaining part. This latter part is called 'summer'. Then he assumed that summer is always warmer than winter; that is, any temperature measured in winter is colder than every temperature measured in summer. Then he searched the Internet and found the previous year' s meteorological data, which contained the year's temperature measurements. He began to wonder if it might be possible to divide the year into winter and summer so that winter comes before summer and each winter' s temperature measurement is smaller than any temperature measured in summer. In case there are many such possible partitions, find the one in which the winter period is as short as possible. (It is quite cold now; there is really no reason for winter to be longer than necessary...) Write a function: def solution( T ) that, given a sequence T of temperature measurements (specified as integer numbers), finds the partition of the year into winter and summer that meets the conditions above and makes winter as short as possible, then retums the length of the winter. Both winter and summer have to be at least one day long. For example, given: T=[5,2,3,8,6] the function should return 3 , as after partitioning the year into winter: [5,2,3] and summer: [8,6], each winter' s measurement is smaller than each summer' 5 temperature

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

More Books

Students also viewed these Databases questions

Question

I receive useful feedback about my performance.

Answered: 1 week ago

Question

I am encouraged to offer opinions/suggestions.

Answered: 1 week ago