def test_nine():
    ll = LinkedList(Node(1, Node(2, Node(3, Node(4, Node(5))))))
    actual = ll.kthFromEnd(5)
    expected = 'Same length'
    assert actual == expected
def test_list_head():
    node = Node(45)
    actual = LinkedList(node).head
    expected = node
    assert actual == expected
def test_empty_list():
    actual = LinkedList().head
    expected = None
    assert actual == expected
def test_insert_in_list():
    link_list = LinkedList()
    link_list.insert(75)
    actual = link_list.head.value
    expected = 75
    assert actual == expected
def test_kth_middle_value():
    link_list = LinkedList()
    link_list.insert(1)
    link_list.insert(10)
    link_list.insert(100)
    link_list.insert(1000)
    actual = link_list.kthFromEnd(2)
    expected = 100
    assert actual == expected
def test_insert_node():
    ll = LinkedList()
    ll.insert('first')
    assert ll.head.value == "first"
    ll.insert("second")
    assert ll.head.value == "second"
def one_list():
    ll = LinkedList()
    ll.insert('one')
    return ll
def test_insert_after_empty():
    ll = LinkedList()
    with pytest.raises(Exception) as context:
        ll.insert_after(1, 1)
    assert str(context.value) == "Cannot `insert_after` on empty LinkedList"
def test_insert_after_exists():
    ll = LinkedList()
    ll.insert(2)
    ll.insert(1)
    ll.insert_after(3, 2)
    assert str(ll) == '{ 1 } -> { 2 } -> { 3 } -> NULL'
def test_insert_before_reference_does_not_exist():
    ll = LinkedList()
    with pytest.raises(Exception) as context:
        ll.insert(1)
        ll.insert_before(3, 5)
    assert str(context.value) == 'No node containing: 5'
def test_insert_before_exists():
    ll = LinkedList()
    ll.insert(3)
    ll.insert(1)
    ll.insert_before(2, 3)
    assert str(ll) == '{ 1 } -> { 2 } -> { 3 } -> NULL'
def test_insert_before_empty():
    ll = LinkedList()
    with pytest.raises(Exception) as context:
        ll.insert_before(3, 5)
    assert str(context.value) == "Cannot `insert_before` on empty LinkedList"
def test_append_empty():
    ll = LinkedList()
    ll.append('test')
    assert str(ll.head) == "test"
def test_empty_list():
    linked_list = LinkedList()
    assert linked_list
    assert isinstance(linked_list, LinkedList)
    assert linked_list.head is None
def test_zip_primary_list_longer():
    ll_primary = LinkedList([1, 2, 3])
    ll_secondary = LinkedList(['a'])
    ll_primary.zip(ll_secondary)
    print(str(ll_primary))
    assert str(ll_primary) == '{ 1 } -> { a } -> { 2 } -> { 3 } -> NULL'
def test_k_is_greater_than_list_length():
    ll = LinkedList()
    val = 1
    with pytest.raises(Exception) as context:
        ll.kth_from_end(val)
    assert str(context.value) == f'Invalid index: {val} is out of range on linked list'
def test_zip_secondary_list_longer():
    ll_primary = LinkedList([1])
    ll_secondary = LinkedList(['a', 'b', 'c'])
    ll_primary.zip(ll_secondary)
    print(str(ll_primary))
    assert str(ll_primary) == '{ 1 } -> { a } -> { b } -> { c } -> NULL'
def test_k_is_equal_to_list_length():
    ll = LinkedList([1, 2, 3])
    val = 3
    with pytest.raises(Exception) as context:
        ll.kth_from_end(val)
    assert str(context.value) == f'Invalid index: {val} is out of range on linked list'
def empty_list():
    return LinkedList()
def test_k_is_negative():
    ll = LinkedList()
    val = -1
    with pytest.raises(Exception) as context:
        ll.kth_from_end(val)
    assert str(context.value) == f'Invalid index: {val} is out of range on linked list'
def two_list():
    some_list = LinkedList(["one"])
    some_list.insert("two")
    return some_list
def test_ll_is_size_one():
    ll = LinkedList([100])
    assert ll.kth_from_end(0) == 100
def test_kth_size_one():
    link_list = LinkedList()
    link_list.insert(1)
    actual = link_list.kthFromEnd(0)
    expected = 1
    assert actual == expected
def test_kth_is_in_ll_somewhere():
    ll = LinkedList([1, 2, 3, 4])
    assert ll.kth_from_end(0) == 4
    assert ll.kth_from_end(1) == 3
    assert ll.kth_from_end(3) == 1
def test_list_includes_one():
    node = Node(100)
    actual = LinkedList(node).includes(100)
    expected = True
    assert actual == expected
def test_zip_lists_of_same_size():
    ll_primary = LinkedList([1, 2, 3])
    ll_secondary = LinkedList(['a', 'b', 'c'])
    ll_primary.zip(ll_secondary)
    print(str(ll_primary))
    assert str(ll_primary) == '{ 1 } -> { a } -> { 2 } -> { b } -> { 3 } -> { c } -> NULL'
def test_if_list_includes_two():
    node = Node(50)
    actual = LinkedList(node).includes(49)
    expected = False
    assert actual == expected
def test_zip_one_empty_list():
    ll_primary = LinkedList([1, 2, 3])
    ll_secondary = LinkedList()
    ll_primary.zip(ll_secondary)
    print(str(ll_primary))
    assert str(ll_primary) == '{ 1 } -> { 2 } -> { 3 } -> NULL'
    def add(self, key, value):
        index = self.hash(key)
        if not self._bucket[index]:
            self._bucket[index] = LinkedList()

        self._bucket[index].append_item([key, value])
def test_eight():
    ll = LinkedList(Node(1, Node(2, Node(3, Node(4, Node(5))))))
    actual = ll.kthFromEnd(0)
    expected = 5
    assert actual == expected