Beispiel #1
0
def run():
    base_list = [3, 5, 8, 5, 10, 2, 1]
    link_list = LinkedList()
    link_list.build(base_list)
    print(link_list)

    part_list = partition_around(link_list, 5)
    print(part_list)
Beispiel #2
0
def run():
    base_list = ['n', 'o', 't', 'z', 'o', 'z', 'g', 'q', 'm']
    list1 = LinkedList()
    list1.build(base_list)

    list2 = LinkedList()
    list2.build(['z', 'g', 'q'])
    list2.get_last().set_next(list1.get_head())

    print(list1)
    print(list2)
    doesit = does_intersect(list2, list1)


    if doesit == None:
        print("NO")
    else:
        print("YES : %s" % doesit.get_data())
Beispiel #3
0
def run():
    base_list = ['n', 'o', 't', 'z', 'o', 'z', 'g', 'q', 'm']
    link_list = LinkedList()
    link_list.build(base_list)
    print(link_list)
    if is_palindrome(link_list):
        print("It's a palindrome")
    else:
        print("It's NOT a palindrome")

    base_list = ['m', 'q', 'g', 'z', 'o', 'z', 'g', 'q', 'm']
    link_list = LinkedList()
    link_list.build(base_list)
    print(link_list)
    if is_palindrome(link_list):
        print("It's a palindrome")
    else:
        print("It's NOT a palindrome")
Beispiel #4
0
def run():
    list1 = [7, 1, 6]
    list2 = [5, 9, 2]
    num1 = LinkedList()
    num2 = LinkedList()
    num1.build(list1)
    num2.build(list2)

    summed = sum_list_reverse(num1, num2)
    print(summed)

    list1 = [6, 1, 7]
    list2 = [2, 9, 5]
    num1 = LinkedList()
    num2 = LinkedList()
    num1.build(list1)
    num2.build(list2)

    summed = sum_list(num1, num2)
    print(summed)