title: Find the time it takes fluid to reach the nth cup
body: <p>This is an additional assignment that i got from my teacher.</p>
  
  <p>Cups are arranged in a treelike structure, something like this:</p>
  
  <pre><code>  1
   2 3
  4 5 6
  </code></pre>
  
  <p>It takes 10 seconds to fill up cup 1, then it overflows into cup 2 and 3. (Assume there is no spillage). Cups 2 and 3 then take 20 seconds to fill up due to the water flow being split. In total, to fill up cup 3 by pouring water into cup 1, it would take 30 seconds. For cup 5 it would take 50 seconds, and so on.</p>
  
  <p>Here is a table with the correct values for the row and seconds fluid takes to reach the next cup.</p>
  
  <pre><code>    1(10)
   2(30) 3(30)
  4(70) 5(50) 6(70)
  </code></pre>
  
  <p>The problem proposed is to solve this for an arbritrary number of rows with the boundary of r &lt;= 50:
  Given the row r and the cup c, how long will it take for that cup to fill?</p>
  
  <p>I have been racking my head over this for around 24 hours now, and i am no closer to solving it. I know that this has something to do with Pascal's triangle and Recursion. I would also like to note that this is not a graded assignment, but just an ungraded interesting problem proposed by a teacher.</p>
  
  <p>EDIT:
  Added a more comprehensible data structure along with my notes.</p>
  
  <pre><code>1:   1
  2:  1 2
  3: 1 2 3
  </code></pre>
  
  <p>Given this structure i have figured out that the proportions of water flow distribution to the cups below it is relevant to Pascal's triangle according to the following formula</p>
  
  <pre><code>h(r,c)=P(n,c)/2^(n-1)
  where P(n,c) returns the number contained in the according row in Pascal's triangle
  </code></pre>
  
  <p>Then i used this to calculate the seconds with the following formula:</p>
  
  <pre><code>t(r,c)=(2^(n-1)/P(n,c))*10
  </code></pre>
  
  <p>This is true for the first 3 rows, but falls apart after that because of the fact that then the flow of water from 2 cups above a cup does not start at the same time.</p>
  
  <p>I also tried an recursive function which would calculate its parents, which reside in (r-1,c) and (r-1,c-1) and apply the previous formula, but it was incorrect due to the reason i explained above.</p>