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 >
Some ideas: (1) The important is knowing which two cups are inputs to the ith cup. (2) The important is know the Minimum Lleft that will bring you water from your left side and what level Lright will bring you water from your right side (3) So you need to know which cups provide water to cup ith. This is easier, thinking quick, if you start numbering from 0. Cup ith will fill (i-1)*2+1 and i*2, what means that cup kth will receive water from (for k%2=1) (k-1)/2 and (k+1)/2 (for k%2=0) k/2 and k/2+1 (4) With that you should check that for any L you will calculate the difference L-Lleft and L-Lright. When positive the water provided is the result of dividing by 2^n the calculated difference, where n is the level of the cup.