title: Project 2 Human Pyramid Calculations
body: <p>For simplicity we will assume that everyone in the pyramid weighs exactly 200 pounds. Person
  A at the top of the pyramid has no weight on her back. People B and C are each carrying half of
  person A's weight. That means that each of them is shouldering 100 pounds.
  Now, let's look at the people in the third row. Let’s begin by focusing on person E. How much
  weight is she supporting? Well, she’s directly supporting half the weight of person B (100
  pounds) and half the weight of person E (100 pounds), so she’s supporting at least 200 pounds.
  On top of this, she’s feeling some of the weight that people B and C are carrying. Half of the
  weight that person B is shouldering (50 pounds) gets transmitted down onto person E and half
  the weight that person C is shouldering (50 pounds) similarly gets sent down to person E, so
  person E ends up feeling an extra 100 pounds. That means she’s supporting a net total of 300
  pounds. </p>
  
  <p>Write a recursive function (using no loops), weightOn(r,c), which returns the weight
  on the back of the person in row r and and column c. Rows and columns are 0-based,
  so the top position is (0,0), for example, and person H is in position (3,1). The following
  also hold:
  weightOn(0,0) == 0.00
  weightOn(3,1) == 425.00
  Weights should be floating-point numbers.</p>
  
  <p>I have already tried a lot. I will include my most recent code below.</p>
  
  <pre><code>t = 0.0
  x = 0.0
  
  def weightOn(r, c):
  
      global t
      if r &lt; 0:
          print('Not valid')
      elif r == 0 and c == 0:
          return t
      elif r &gt; 0 and c == 0:
          t += 200 / (2 ** r)
          return weightOn(r - 1, 0)
      elif r &gt; 0 and c == r:
          t += 200 / (2 ** r)
          return weightOn(r - 1, 0)
      elif r &gt; c &gt; 0:
          mid(r, c)
          return t
  
  def mid(r, c):
  
      global x
      x = weightOn(r - 1, c - 1) + weightOn(r - 1, c)
  '''I have also tried: x = (((weightOn(r - 1, c - 1) + 200) / 2) + ((weightOn(r - 1, c) + 200) / 2))'''
      return x
  
  r = int(input('r: '))
  c = int(input('c: '))
  weightOn(r, c)
  if r &gt; c &gt; 0:
      print(x)
  else:
      print(t)
  </code></pre>
  
  <p>It always brings up the wrong output. I can correctly pull up all of the edges (when c == 0 or c == r). But other than that it won't work.</p>
  
  <p>Ex. Input (3, 1) outputs 500
  (3, 2) outputs 550</p>