Brandon has a list of quizzes suitable for Assignment 1. The difficulties of these quizzes are...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
Brandon has a list of quizzes suitable for Assignment 1. The difficulties of these quizzes are stored in a list of integers a. The i-th problem's difficulty is represented by a [i] (the higher the integer, the more difficult the problem). Brandon is too busy working on other projects to work on assignment 1 decisions, so he asks Chris to select at least two quizzes from the list for the assignment. Since there are many possible subsets of the quizzes to consider and Chris has no time, he decides to consider only sublists (definition follows) of the list of quizzes. To make grading the assignment easier, Chris wants to pick quizzes that don't vary too much in difficulty. What is the smallest difference between the difficulties of the most difficult selected problem and the least difficult selected problem he can achieve by selecting a sublist of length at least 2 of the original list of quizzes? Time Limit Your program must finish running on any valid input within 3 seconds. Sample Input 1 10 6 9 1 Sample Output 1 3 Sample 1 Explanation If Chris selects all of the quizzes, the maximum difficulty would be 10 and the minimum difficulty would be 1. In this case, the difference he wants to minimize would be 9. If he selects the sublist 6 9, the maximum and minimum difficulties would be 9 and 6 respectively and the difference would be 3. Note that he can't select 10 9, as that's not a sublist of a. Definition: A sublist of a list a is any list you can obtain by removing some (possibly o) elements from the start of a and then removing some (possibly o) elements from the end of it. (It's like the definition of segment from lecture.). Filename Your filename for this question must be ql.py. Input The input consists of a single line containing the integers in the list a, separated by single spaces. Output Print a single integer indicating the smallest difference in difficulties Chris can achieve. Constraints 2 Sample Input 2 7 7 7 Sample Output 2 0 Brandon has a list of quizzes suitable for Assignment 1. The difficulties of these quizzes are stored in a list of integers a. The i-th problem's difficulty is represented by a [i] (the higher the integer, the more difficult the problem). Brandon is too busy working on other projects to work on assignment 1 decisions, so he asks Chris to select at least two quizzes from the list for the assignment. Since there are many possible subsets of the quizzes to consider and Chris has no time, he decides to consider only sublists (definition follows) of the list of quizzes. To make grading the assignment easier, Chris wants to pick quizzes that don't vary too much in difficulty. What is the smallest difference between the difficulties of the most difficult selected problem and the least difficult selected problem he can achieve by selecting a sublist of length at least 2 of the original list of quizzes? Time Limit Your program must finish running on any valid input within 3 seconds. Sample Input 1 10 6 9 1 Sample Output 1 3 Sample 1 Explanation If Chris selects all of the quizzes, the maximum difficulty would be 10 and the minimum difficulty would be 1. In this case, the difference he wants to minimize would be 9. If he selects the sublist 6 9, the maximum and minimum difficulties would be 9 and 6 respectively and the difference would be 3. Note that he can't select 10 9, as that's not a sublist of a. Definition: A sublist of a list a is any list you can obtain by removing some (possibly o) elements from the start of a and then removing some (possibly o) elements from the end of it. (It's like the definition of segment from lecture.). Filename Your filename for this question must be ql.py. Input The input consists of a single line containing the integers in the list a, separated by single spaces. Output Print a single integer indicating the smallest difference in difficulties Chris can achieve. Constraints 2 Sample Input 2 7 7 7 Sample Output 2 0
Expert Answer:
Related Book For
Statistics For Managers Using Microsoft Excel
ISBN: 9780133130805
7th Edition
Authors: David M. Levine, David F. Stephan, Kathryn A. Szabat
Posted Date:
Students also viewed these programming questions
-
The more we learn about how fashion is created, the more we face a moral dilemma that pits our individual freedom of expression and purchasing power against both the environment and the dignity and...
-
Planning is one of the most important management functions in any business. A front office managers first step in planning should involve determine the departments goals. Planning also includes...
-
Which of these statements is false? A. Assets = Liabilities + Equity B. Assets Liabilities = Equity C. Liabilities Equity = Assets D. Liabilities = Assets Equity
-
You place 0.410 kg of cold water inside a freezer that has a constant temperature of 0 °C. The water eventually freezes and becomes ice at 0 °C. (a) What is the change in entropy of the water...
-
The following bill of materials represents the major components for a computer system. Complete the MRP records below. Note the following: Production plans (the MPS) for the 800 Deluxe computer...
-
A six-cylinder, four-stroke, \(10 \mathrm{~cm}\) bore and \(12.5 \mathrm{~cm}\) stroke diesel engine develops \(50 \mathrm{~kW}\) at \(1000 \mathrm{rpm}\). The various efficiencies are: mechanical...
-
Do you agree or disagree with Donahoe that eBays current strategy doesnt mean that certain sellers will lose? Pop quiz: Name the high-tech company that got its start in someones living room, grew...
-
Frasier is giving a speech and the power of his sound is 3 . 5 8 mW . What is the sound intensity level 4 . 5 9 m away from Frasier?
-
According to the ethical guidelines for a number of professional organizations, incompetence, corruption, or dishonest conduct on the part of health care practitioners is unethical and never...
-
The demand function for hospital inpatient days in a local community is P = 4500 5Q, P is the price of the hospital inpatient day and Q is the number of hospital inpatient days demanded. Hospitals...
-
What is a set amount of money by the employer to help them with moving expenses. The transferee is responsible for using that money to hire a moving service, transportation and any other expenses...
-
There are some typical input artifacts for object-oriented design. identify some of the input artifacts ?
-
I need one to three paragraphs written about the awk command in unix. Everything should be in a power point presentation. Make sure it contains the following: Command name Description How to use the...
-
What is a data dictionary and what would it contain for object-oriented design?
-
Research Online for a local or surrounding area Agency/Organization that provides services for people seeking inpatient substance abuse treatment. Complete the following Agency Summary (formerly...
-
2. Assume a person bends forward to lift a load "with his back" as shown in Figure P12.42a. The person's spine piv- ots mainly at the fifth lumbar vertebra, with the principal supporting force...
-
A standard deck of cards is being used to play a game. There are four suits (hearts, diamonds, clubs, and spades), each having 13 faces (ace, 2, 3, 4, 5, 6, 7, 8, 9, 10, jack, queen, and king),...
-
An agent for a real estate company wanted to predict the monthly rent for apartments, based on the size of the apartment. The data are stored in Rent. Use the results of that problem. a. At the 0.05...
-
Suppose you select one value from a uniform distribution with a = 0 and b = 10. What is the probability that the value will be a. Between 5 and 7? b. Between 2 and 3? c. What is the mean? d. What is...
-
What is an overnight reverse repurchase agreement (ON RRP)? What role does the interest on ON RRP play in the way the Fed hits its target for the federal funds rate in the current ample-reserves...
-
A Federal Reserve publication observed that today, the The Feds primary tool for adjusting the federal funds rate is interest on reserve balances. a. Briefly explain the reasoning behind this...
-
In the following graph of the federal funds market, briefly explain whether the banking system is in a scarce reserves regime or an ample-reserves regime. In this situation, briefly explain whether...
Study smarter with the SolutionInn App