title: Binary addition of two lists of boolean values
body: <p>I was given the following prompt:</p>
  
  <blockquote>
    <p>create a function: BoolAdd(A,B) that performs binary addition on lists
    A and B (A and B have the same length N) of Boolean values and returns
    a list of two elements. The first element is an overflow, which means
    that it is returned with the value FALSE unless the addition does not
    fit into the same length list as A and B originally. The second
    element of the output list is a list of Boolean values that
    corresponds to the vector sum of A and B. Make sure that BOOL_ADD is
    defined so it works regardless of the value chosen for N.</p>
  </blockquote>
  
  <p>I'm unsure on how to perform the binary addition, then convert it to boolean. I'm also not sure when overflow would ever be changed to TRUE. Earlier in the question we wrote the following HalfAdder function:</p>
  
  <pre><code>def HalfAdder(A,B):
      S = int((A and not B) or (not A and B))
      C = int(A and B)
      return (S, C)
  </code></pre>
  
  <p>and the FullAdder function:</p>
  
  <pre><code>def FullAdder(A,B,C):
      AB = int((A and not B) or (not A and B))
      S = int((C and not AB) or (not C and AB))
      CAB = int(C and AB)
      C1 = int((A and B) or (CAB))
      return (S,C1)
  </code></pre>
  
  <p>Would either of those be incorporated?</p>
  
  <p>Here's what I have so far, but it's not working out:</p>
  
  <pre><code>def BoolAdd(A,B):
      L = []
      overflow = False
      for i in range (0,len(A)):
              x = bin(A[i]+B[i])
              x = bool(x)
              L.append(x)
      if (len(L) &gt; len(A)):
          overflow = True
  
      return [overflow, L]
  </code></pre>
  
  <p>Any ideas on what I'm doing wrong, or how to approach this problem?</p>