Ejemplo n.º 1
0
def main():

    integerOne, lengthIntegerOne = ll.createLoopLL()
    ll.printlinked(integerOne)

    val = checkIfLooped(integerOne)
    print("integerOne loop begins at", val, val.value)
Ejemplo n.º 2
0
def main():

    integerOne, lengthIntegerOne = ll.createLinkedList()
    ll.printlinked(integerOne)

    integerTwo, lengthIntegerTwo = ll.createDaIntersection(integerOne)
    ll.printlinked(integerTwo)

    lengthIntegerTwo += lengthIntegerOne

    intersectionNode = findIntersection(integerOne, integerTwo,
                                        lengthIntegerOne, lengthIntegerTwo)
    print(
        "the interstion Node is ",
        intersectionNode,
        "and its value is ",
        intersectionNode.value,
    )
Ejemplo n.º 3
0
def main():

    integerOne, lengthIntegerOne = ll.createLinkedList()
    ll.printlinked(integerOne)

    integerTwo, lengthIntegerTwo = ll.createPalindromeLL()
    ll.printlinked(integerTwo)

    val = checkIfPalindrome(integerOne, lengthIntegerOne, 1)

    if type(val) != bool:
        print("integerOne is a Palindrome", val)
    else:
        print("integerOne is not a Palindrome")

    val = checkIfPalindrome(integerTwo, lengthIntegerTwo, 1)
    if type(val) != bool:
        print("integerTwo is a Palindrome")
    else:
        print("integerTwo is not a Palindrome")
Ejemplo n.º 4
0
def main():
    integerOne, lengthIntegerOne = ll.createLinkedList()
    ll.printlinked(integerOne)
    integerTwo, lengthIntegerTwo = ll.createLinkedList()
    ll.printlinked(integerTwo)
    (integerOne, integerTwo) = makeThemSame(integerOne, integerTwo,
                                            lengthIntegerOne, lengthIntegerTwo)
    (head, remainder) = sumLinkedRecRev(integerOne, integerTwo, 0)
    if remainder > 0:
        tempHead = ll.Node(1)
        tempHead.next = head
        head = tempHead
    ll.printlinked(head)
    return head
Ejemplo n.º 5
0
import generateLinkedList as ll

head = ll.createLinkedList()
ll.printlinked(head)

setLinked = set()

point = head
while point is not None:
    nextValue = point.next
    if nextValue.value in setLinked:
        point.next = nextValue.next
    setLinked.add(point.value)
    point = point.next

print(setLinked)
ll.printlinked(head)
Ejemplo n.º 6
0
def main():
    head = addLinkedList(integerOne, integerTwo)
    ll.printlinked(head)
    return head
Ejemplo n.º 7
0
import generateLinkedList as ll

integerOne, lengthIntegerOne = ll.createLinkedList()
ll.printlinked(integerOne)

integerTwo, lengthIntegerTwo = ll.createLinkedList()
ll.printlinked(integerTwo)


def getSummation(valOne, valTwo, remainder):
    sumVal = valOne + valTwo + remainder
    remainder = 0
    if sumVal > 10:
        remainder = 1
        sumVal -= 10
    return (sumVal, remainder)


def addLinkedList(integerOne, integerTwo):
    remainder = 0
    sumHead = None
    while integerOne is not None and integerTwo is not None:
        integer1 = integerOne.value
        integer2 = integerTwo.value
        (sumVal, remainder) = getSummation(integer1, integer2, remainder)
        if sumHead is None:
            sumHead = ll.Node(sumVal)
            tailNode = sumHead
        else:
            tailNode.next = ll.Node(sumVal)
            tailNode = tailNode.next
Ejemplo n.º 8
0
def main():
    integer1 = convertToInteger(integerOne)
    integer2 = convertToInteger(integerTwo)
    head = convertToLinkedList(integer1 + integer2)
    ll.printlinked(head)
    return head
Ejemplo n.º 9
0
def main():
    headSum = addTheLinked(integerOne, integerTwo, 0)
    ll.printlinked(headSum)
    return headSum