
tableAdd = ("00", "01", "10")

def PROC0(digit1, digit2):
    """
    Input: digit1, digit2, each of which is either 0 or 1.
    Output: a string of two digits which is the sum of the two digits. Therefore, the result could be "00", "01" or "10".
    """
    return tableAdd[digit1+digit2]

def PROC1(digit1, digit2, digit3):
    """
    Input: digit1, digit2, digit3, each of which is either 0 or 1.
    Output: a string of two digits which is the sum of the three digits. Therefore, the result could be "00", "01", "10", or "11".
    """
    firstPROC0Result = PROC0(digit1, digit2)
    secondPROC0Result = PROC0(int(firstPROC0Result[1]),digit3)
    if firstPROC0Result[0] == secondPROC0Result[0] == "0":
        result = "0"
    else:
        result = "1"

    return result+secondPROC0Result[1]

def PROC2(num1, num2):
    """
    Input: num1 and num2 are two multidigit binary numbers. Their lengths do not have to be the same.
    Output: The result of the binary addition of num1 and num2.
    """

    # make the two numbers in same length by padding "0"
    num1Str, num2Str = str(num1), str(num2)
    if len(num1Str) > len(num2Str):
        num2Str = (len(num1Str) - len(num2Str))*"0" + num2Str
    elif len(num1Str) < len(num2Str):
        num1Str = (len(num2Str) - len(num1Str))*"0" + num1Str

    # apply PROC1() to add two digits with the carry
    c = 0
    sum = ""
    for i in range(len(num1Str)-1,-1,-1):
        resultPROC1 = PROC1(int(num1Str[i]), int(num2Str[i]), c)
        sum = resultPROC1[1] + sum
        c = int(resultPROC1[0])
    sum = resultPROC1[0] + sum

    # remove the leading "0"    
    return int(sum)


print(PROC2(0,1))
print(PROC2(1,1))
print(PROC2(0,0))
print(PROC2(101,1))
print(PROC2(111,111))
print(PROC2(10101010,1111100))

