def add_link_lists(ll1, ll2): curr1 = ll1.head curr2 = ll2.head answer = LinkedList() number1 = "" number2 = "" while curr1 is not None: number1 = str(curr1.data) + number1 curr1 = curr1.next while curr2 is not None: number2 = str(curr2.data) + number2 curr2 = curr2.next total = str(int(number1) + int(number2)) for n in total: answer.add(int(n)) return answer
from GeneralPractice.DataStructurs.LinkedList.SingleUnsortedLinkedList import LinkedList ll = LinkedList() ll.add(5) ll.add(4) ll.add(3) ll.add(2) ll.add(1) def n_to_last_with_size(ll, n): if n > ll.list_size(): return None elif n < 1: return None cur = ll.head count = 1 while count <=ll.list_size()-n: cur = cur.get_next() count +=1 return cur def n_to_last(ll, n): if n < 1: return None cur = ll.head count = 1 pointer = None while cur is not None: if count == n: pointer = ll.head
from GeneralPractice.DataStructurs.LinkedList.SingleUnsortedLinkedList import LinkedList ll = LinkedList() ll.add("E") ll.add("D") ll.add("C") ll.add("B") ll.add("A") ll.add("A") ll.add("A") ll.add("A") def make_cir(): E = ll.search_and_return("E") C = ll.search_and_return("C") E.set_next(C) def find_start(ll): curr = ll.head found = False o = list() while curr is not None and not found: if curr in o: found = True break else: o.append(curr)