title: 3Sum function debugging
body: <p>I have been asked to fix this chunk of code. It is to do with sets and the 3Sum problem. I have used print statements and i am very close to the answer, but i get an IndexingError (list index out of range). Any help would be great</p>
  
  <pre><code>def count_c(A, B, C):
  
      """Counts the number of pairs a in A and b in B so that a + b == c
  
      nb. Assumes that A and B are sorted
      """
      rv = 0
      n = len(A)
      m = len(B)
      #t = len(C)
      AL, BL, CL = list(A), list(B), list(C)
      # i and j are "fingers" on A and B
      i, j = 0, m-1
  
      while i &lt; n and j &gt;= 0:
  
          for c in CL:
              a, b = AL[i], BL[j] #correct
              print ('a,b = ', (a,b))
              s = a + b #correct
              print('s = ', s)
              print ('i , j =', (i,j))
  
              if s == c:
                  # found a pair that works
                  rv = rv + 1 #correct
                  # start again with a smaller b
                  j = j - 1 #correct
              elif s &gt; c:
                  # too big. decrease the b contribution
                  j = j - 1
              else:
                  # means s &lt; c, increase the a contribution
                  i = i + 1
  
      return rv
  
  def three_sum(A, B, C):
      """Solves 3SUM+"""
  
      return count_c(A,B,C)
  </code></pre>
  
  <p>IndexingError (list index out of range)</p>