How to resolve the algorithm Water collected between towers step by step in the Phix programming language
Published on 12 May 2024 09:40 PM
How to resolve the algorithm Water collected between towers step by step in the Phix programming language
Table of Contents
Problem Statement
In a two-dimensional world, we begin with any bar-chart (or row of close-packed 'towers', each of unit width), and then it rains, completely filling all convex enclosures in the chart with water.
In the example above, a bar chart representing the values [5, 3, 7, 2, 6, 4, 5, 9, 1, 2] has filled, collecting 14 units of water. Write a function, in your language, from a given array of heights, to the number of water units that can be held in this way, by a corresponding bar chart. Calculate the number of water units that could be collected by bar charts representing each of the following seven series:
See, also:
Let's start with the solution:
Step by Step solution about How to resolve the algorithm Water collected between towers step by step in the Phix programming language
Source code in the phix programming language
You may also check:How to resolve the algorithm Loops/Infinite step by step in the Raku programming language
You may also check:How to resolve the algorithm Greatest element of a list step by step in the AArch64 Assembly programming language
You may also check:How to resolve the algorithm Elementary cellular automaton/Infinite length step by step in the Racket programming language
You may also check:How to resolve the algorithm Averages/Median step by step in the Forth programming language
You may also check:How to resolve the algorithm Horizontal sundial calculations step by step in the Nim programming language