def main(): integerOne, lengthIntegerOne = ll.createLoopLL() ll.printlinked(integerOne) val = checkIfLooped(integerOne) print("integerOne loop begins at", val, val.value)
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, )
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")
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
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)
def main(): head = addLinkedList(integerOne, integerTwo) ll.printlinked(head) return head
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
def main(): integer1 = convertToInteger(integerOne) integer2 = convertToInteger(integerTwo) head = convertToLinkedList(integer1 + integer2) ll.printlinked(head) return head
def main(): headSum = addTheLinked(integerOne, integerTwo, 0) ll.printlinked(headSum) return headSum