Problem 44307. The glass half full
Identical glasses are placed in a triangular tower structure, such that the top level (L = 1) comprises one glass, the next level down (L = 2) comprises three glasses, the next level down (L = 3) comprises six glasses, and so on.
Follow the link to see a diagram shows the first three levels. The glasses in each levels are represented by the blue circles, while the yellow circles represent the positions of the glasses in the next higher level.
Water is poured into the top glass at a constant volumetric flow rate. When the glass is filled, the water starts spilling over and into the glasses below. Note that water only spills outward , meaning that at some point, some glasses will remain empty.
Given the volume of a glass in liters, v, the volumetric flow rate in liters per second, u, and an integer, L, representing a level in the glass structure, return the total number of glasses in that level, g, the number of glasses in that level that will be filled with water, f, and the time, in seconds, it would take to fill all "fillable" glasses in that level, t, starting with no water in any of the levels.
Example:
Input: v = 0.25, u = 0.1, L = 2
Output: g = 3, f = 3, t = 10
Solution Stats
Problem Comments
-
1 Comment
Glad you aren't asking for the water pouring in the spaces!
Solution Comments
Show commentsProblem Recent Solvers253
Suggested Problems
-
Project Euler: Problem 2, Sum of even Fibonacci
2299 Solvers
-
How many trades represent all the profit?
599 Solvers
-
537 Solvers
-
308 Solvers
-
412 Solvers
More from this Author45
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!