c or c++ or Java or python 2. Dam Design Your company is designing a dam to
Fantastic news! We've Found the answer you've been seeking!
Question:
c or c++ or Java or python
Transcribed Image Text:
2. Dam Design Your company is designing a dam to be built across a stream to create a small lake. To reduce materials cost, it will be made of one or more concrete walls with mud packed in between them. Determine the maximum height of the mud segments in the dam with the following restrictions: • One unit width of the gap between walls will contain one segment of packed mud • The height of mud in a segment cannot exceed 1 unit more than an adjacent wall or mud segment. ► the placement of a number of walls and their heights, determine the maximum height of a mud segment that can be built. If no mud segment can be built, return 0. Example wallPositions = [1, 2, 4, 7] wallHeights = [4, 6, 8, 11] 10 Mud segments Wall segments • There is no space between the first two walls. • Between positions 2 and 4, there is one unit open for mud. Heights of the surrounding walls are 6 and 8, so the maximum height of mud is 6+1=7₁ • Between positions 4 and 7 there are two units. The heights of surrounding walls are 8 and 11. o The maximum height mud segment next to the wall of height 8 is 9. o The maximum height mud next to a mud segment of height 9 is 10. • Overall, mud segment heights are 7, 9 and 10, and the maximum height is 10. HANN 44444 Function Description Complete the function maxHeight in the editor below. maxHeight has the following parameter(s): int wallPositions[n]: an array of integers int wallHeights[n]: an array of integers Returns: int: the maximum height mud segment that can be build Constraints • 1 ▾ Sample Case 0 Sample Input For Custom Testing STDIN Function 3 1 3 73 433 5 wallPositions [] size n = 3 wallPositions = [1, 3, 7] → wallHeights [] size n = 3 wallHeights = [4, 3, 3] → Sample Output Explanation 3 4 5 4 3 Mud segments Wall segments The wallPositions = [1, 3, 7] and wallHeights = [4, 3,3]. There can be a segment of height 4 at position 2 supported by walls of heights 4 and 3. Between positions 3 and 7, there can be a segment of height 4 at positions 4 and 6. Between them, a segment can be built of height 5 at position 5. ✓ Sample Case 1 Sample Input For Custom Testing STDIN Function 2 1 10 2 1 5 7 Sample Output wallPositions [] size n = 2 wallPositions = [1, 10] 2 wallHeights [] size n = 2 wallHeights = [1, 5] Explanation 3 4 5 7 7 Mud segments Wall segments The wallPositions = [1, 10] and wallHeights = [1, 5]. The heights of the mud segments from positions 2 through 9 are [2, 3, 4, 5, 6, 7, 7, 6]. 2. Dam Design Your company is designing a dam to be built across a stream to create a small lake. To reduce materials cost, it will be made of one or more concrete walls with mud packed in between them. Determine the maximum height of the mud segments in the dam with the following restrictions: • One unit width of the gap between walls will contain one segment of packed mud • The height of mud in a segment cannot exceed 1 unit more than an adjacent wall or mud segment. ► the placement of a number of walls and their heights, determine the maximum height of a mud segment that can be built. If no mud segment can be built, return 0. Example wallPositions = [1, 2, 4, 7] wallHeights = [4, 6, 8, 11] 10 Mud segments Wall segments • There is no space between the first two walls. • Between positions 2 and 4, there is one unit open for mud. Heights of the surrounding walls are 6 and 8, so the maximum height of mud is 6+1=7₁ • Between positions 4 and 7 there are two units. The heights of surrounding walls are 8 and 11. o The maximum height mud segment next to the wall of height 8 is 9. o The maximum height mud next to a mud segment of height 9 is 10. • Overall, mud segment heights are 7, 9 and 10, and the maximum height is 10. HANN 44444 Function Description Complete the function maxHeight in the editor below. maxHeight has the following parameter(s): int wallPositions[n]: an array of integers int wallHeights[n]: an array of integers Returns: int: the maximum height mud segment that can be build Constraints • 1 ▾ Sample Case 0 Sample Input For Custom Testing STDIN Function 3 1 3 73 433 5 wallPositions [] size n = 3 wallPositions = [1, 3, 7] → wallHeights [] size n = 3 wallHeights = [4, 3, 3] → Sample Output Explanation 3 4 5 4 3 Mud segments Wall segments The wallPositions = [1, 3, 7] and wallHeights = [4, 3,3]. There can be a segment of height 4 at position 2 supported by walls of heights 4 and 3. Between positions 3 and 7, there can be a segment of height 4 at positions 4 and 6. Between them, a segment can be built of height 5 at position 5. ✓ Sample Case 1 Sample Input For Custom Testing STDIN Function 2 1 10 2 1 5 7 Sample Output wallPositions [] size n = 2 wallPositions = [1, 10] 2 wallHeights [] size n = 2 wallHeights = [1, 5] Explanation 3 4 5 7 7 Mud segments Wall segments The wallPositions = [1, 10] and wallHeights = [1, 5]. The heights of the mud segments from positions 2 through 9 are [2, 3, 4, 5, 6, 7, 7, 6].
Expert Answer:
Answer rating: 100% (QA)
def maxHeight wallpos wallh mudmaxH 0 for i in rangelenwallpos1 we are checking here that if there i... View the full answer
Related Book For
Posted Date:
Students also viewed these electrical engineering questions
-
Java Help! Convert the following code from Python to Java Python: class Fruit: def __init__(self, name): self.name = name @property def name(self): return self._name @name.setter def name(self,...
-
can anyone help with solution in python or java ? 2. Busy intersection There is a busy intersection between two one-way streets: Main Street and 1st Avenue. Cars passing through the intersection can...
-
Convert the following JAVA code into Python please provide screenshots of the output as well as the pythoncode. Exercise 2: Applying higher order functions The following Java code implements...
-
You are the manager of a large car dealership. At present, you rely on a large pool of dealers to sell your product, but you have noticed recently that consumer opinion appears to be turning away...
-
Indigenous religions generally are characterized by three basic patterns. What are those patterns? How would you define each pattern in your own words? In what ways do you see these patterns as...
-
We also have data on the protein content on the 77 cereals in Exercise 45. Does protein content vary by shelf? Heres a boxplot and an ANOVA table. a) What kind of design or study is this? b) What are...
-
A single pressure transmitter (1oo1) is being used in a SIF to initiate a trip when the pressure output signal goes below 6 mA. This transmitter is connected to a safety PLC that is programmed to...
-
The Mark Goodwin Resort is an elegant summer resort located in a remote mountain setting. Guests visiting the resort can fish, hike, go horseback riding, swim in one of three hotel pools, or simply...
-
Financial health, from an organizational standpoint, refers to the overall state of a company's financial well-being and its ability to effectively manage its financial resources to meet its...
-
Since the early 1990s, woodstove sales have declined from 1,200,000 units per year to approximately 100,000 units per year. The decline has occurred because of (1) stringent new federal EPA...
-
Explain to me how to answer these questions, especially if there a query that can be run to add random sales for that product? You * You are working for a company with retail stores located...
-
A company has projected the following sales for the spring quarter of 2014: April May $200,000 $250,000 June $275,000 65% of all sales are paid for with cash. The remainder is on credit. The pattern...
-
Two countries are capable of producing beans and whiskey. The first country, Absurdistan, can produce beans at a cost $15.00 per ton, and whiskey for $5.00 per barrel. The second country, Mongolia,...
-
Determine the optimal results for the following formulation using the simplex method (show all iterations) Maximize Z = 5x1 + 9x2 + 7x3 subject to X1 + 3x2 + 2x3 10 3x1 + 4x2 + 2x3 12 2x1 + x2 + 2x3 8
-
A company purchased equipment at the beginning of 2024 for $650,000. In 2024 and 2025, the company depreciated the asset on a straight-line basis with an estimated service life of eight years and a...
-
For a recent 2-year period, the balance sheet of Cheyenne Company showed the following stockholders' equity data at December 31 (in millions). 2020 2019 Additional paid-in capital $890 $820 Common...
-
Discuss how the four elements of the marketing mix (product, pricing, distribution, and promotion) are approached for either the business banking or trust market. How does this differ from retail...
-
Match the following. Answers may be used more than once: Measurement Method A. Amortized cost B. Equity method C. Acquisition method and consolidation D. Fair value method Reporting Method 1. Less...
-
Ling and Morwong are small family-owned companies engaged in vegetable growing and distribution. The Spencer family owns the shares in Morwong and the Rokocoko family owns the shares in Ling. The...
-
Max Inc. acquires 40% of the shares of Guarasci Inc. for $80,000 on January 1, 2013. During 2013, Guarasci earned $50,000 and paid dividends to its shareholders of $10,000. During 2014, Guarasci...
-
How is fair value determined?
-
Parson's Turbine is a: (a) Simple impulse turbine (b) Simple reaction turbine (c) Pressure compounded turbine (d) Velocity compounded turbine
-
In a reaction steam turbine, steam expands: (a) In nozzle only (b) In moving blades only (c) Partly in nozzle partly in blades (d) None of the above
-
Curtis turbine is: (a) Simple impulse turbine (b) Simple reaction turbine (c) Pressure compounded turbine (d) Velocity compounded turbine
Study smarter with the SolutionInn App