Esempio n. 1
0
            while diff*-1 != 0:
                first.append(0)
                diff += 1
    result = LinkedList()
    carry = False

    currentF = first.head
    currentS = second.head
    carry = 0

    while currentF:
        tSum = currentF.data + currentS.data + carry

        if tSum>=10:
            carry = 1
            tSum = tSum - 10
        else:
            carry = 0

        result.append(tSum)
        currentS = currentS.next_node
        currentF = currentF.next_node

    if carry == 1:
        result.append(1)
    return result
#should return 2 - 1 - 9
first.show()
second.show()
add(first, second).show()
Esempio n. 2
0
from linkedList import LinkedList

data = LinkedList()

data.append('A')
data.append('B')
data.append('C')
data.append('D')
data.append('E')
data.append('F')
data.append('G')

data.show()
print data.size()