This question was asked in a forum. Any suggestions?
There is a pyramid with 1 cup at level , 2 at level 2 , 3 at level 3 and so on..
It looks something like this
1 2 3 4 5 6
every cup has capacity C. you pour L liters of water from top . when cup 1 gets filled , it overflows to cup 2,3 equally, and when they get filled , Cup 4 and 6 get water only from 2 and 3 resp but 5 gets water from both the cups and so on.
Now given C and L .Find the amount of water in ith cup ?
Each glass has an incoming flow, an amount of water in the glass, and maybe some outgoing flow (overflow).
If each glass can contain 1 unit of water, and you pour 15 units of water, you get the following (overflow amount in parenthesis):
The incoming flow to the first level is L. The incoming flow from glass
con levelrisFin(c, r), and could be written as:The amount of water in that glass is:
And the outgoing flow is:
I don’t see any obvious formula for evaluating
A(c, r)without doing it recursively.To get from an index to a row and glass position, you can do: