My guess is that the "and so on..." means we should be able to solve
this assuming the pyramid is as high as it needs to be in order not to
overflow.

With this the problem gets more interesting.  I worked it out a bit
farther:

L/C --- Filled cups
1 --- 1
3 --- 2,3
5 --- 5
7 --- 4-6
8 1/3 --- 8,9
11 --- 13
13 2/3 --- 12, 14
15 --- 7,10

At this point, 17,20 are 1/8 full and 18,19 are 7/8 full.  11,15 are
empty but beginning to receive water.

I know I can build a simulation of what I'm doing by hand to always
get the answer, but I'm thinking there is a simple recurrence or other
algorithm.  Any anybody see it?

Gene

On Sep 10, 2:42 pm, Dave <[email protected]> wrote:
> @Ishan: Here is the algorithm:
>
> If L <= C, then
>     cup1 = L
>     cup2 = cup3 = cup4 = cup5 = cup6 = overflow = 0
> else if L < 3*C, then
>     cup1 = C
>     cup2 = cup3 = (L-C)/2
>     cup4 = cup5 = cup6 = overflow = 0
> else if L < 5*C, then
>     cup1 = cup2 = cup3 = C
>     cup4 = cup6 = (L-3*C)/4
>     cup5 = (L-3*C)/2
>     overflow = 0
> else if L < 7*C, then
>     cup1 = cup2 = cup3 = cup5 = C
>     cup4 = cup6 = (L-3*C)/4
>     overflow = (L-5*C)/2
> else if L >= 7*C, then
>     cup1 = cup2 = cup3 = cup4 = cup5 = cup6 = C
>     overflow = L-6*C
>
> And so on.
>
> Dave
>
> On Sep 10, 9:40 am, Ishan Aggarwal <[email protected]>
> wrote:
>
>
>
> > 1.)
>
> > there is apyramidwith 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 M .Find the amount of water in ith cup.
>
> > --
> > Kind Regards
> > Ishan Aggarwal
> > [image: Aricent Group]
> > Presidency Tower-A, M.G.Road,Sector-14
> > Gurgaon,Haryana.122015 INDIA
> > Phone : +91-9654602663
> > [email protected] <[email protected]>

-- 
You received this message because you are subscribed to the Google Groups 
"Algorithm Geeks" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/algogeeks?hl=en.

Reply via email to