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
Solution Comments
Show commentsProblem Recent Solvers258
Suggested Problems
-
Project Euler: Problem 2, Sum of even Fibonacci
2823 Solvers
-
Put two time series onto the same time basis
350 Solvers
-
Duplicate each element of a vector.
635 Solvers
-
Implement a bubble sort technique and output the number of swaps required
383 Solvers
-
Find the next Fibonacci number
901 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!
Glad you aren't asking for the water pouring in the spaces!