def test_delete_duplicates(head, expected):
    card = main.Jan05
    expected = linked_list_constructor(expected)
    actual_list = linked_list_constructor(head)
    actual = card.delete_duplicates(card, actual_list)
    while expected and actual:
        if expected.val != actual.val:
            assert False
        expected = expected.next
        actual = actual.next

    assert not expected and not actual
def test_merge_two_lists(nodes1, nodes2, nodes_sorted):
    card = main.Jan04
    l1 = linked_list_constructor(nodes1)
    l2 = linked_list_constructor(nodes2)
    expected = linked_list_constructor(nodes_sorted)
    actual = card.merge_two_lists(card, l1, l2)
    while expected and actual:
        if expected.val != actual.val:
            assert False
        expected = expected.next
        actual = actual.next

    assert not expected and not actual
def test_add_two_numbers(nodes1, nodes2, result):
    card = main.Jan12
    l1 = linked_list_constructor(nodes1)
    l2 = linked_list_constructor(nodes2)
    expected = linked_list_constructor(result)
    actual = card.add_two_numbers(card, l1, l2)
    while expected and actual:
        if expected.val != actual.val:
            assert False
        expected = expected.next
        actual = actual.next

    assert not expected and not actual
def test_merge_k_lists(lists, result):
    card = main.Jan24
    expected = linked_list_constructor(result)
    actual = card.merge_k_lists(card, lists)
    while expected and actual:
        if expected.val != actual.val:
            assert False
        expected = expected.next
        actual = actual.next

    assert not expected and not actual
@pytest.mark.parametrize("mat, result", [
    ([[3, 3, 1, 1], [2, 2, 1, 2], [1, 1, 1, 2]],
     [[1, 1, 1, 1], [1, 2, 2, 2], [1, 2, 3, 3]]),
    ([[1, 2, 3], [3, 2, 1], [2, 1, 3]],
     [[1, 1, 3], [1, 2, 2], [2, 3, 3]]),
    ([[1, 2], [3, 2], [2, 1], [5, 6], [6, 3], [9, 1]],
     [[1, 2], [1, 2], [2, 3], [3, 6], [1, 5], [9, 6]])
    ])
def test_diagonal_sort(mat, result):
    card = main.Jan23
    assert card.diagonal_sort(card, mat) == result


@pytest.mark.parametrize("lists, result", [
    ([linked_list_constructor([1, 4, 5]),
      linked_list_constructor([1, 3, 4]),
      linked_list_constructor([2, 6])],
     [1, 1, 2, 3, 4, 4, 5, 6]),
    ([], []),
    ([[]], []),
    ([linked_list_constructor([2, 6]),
      linked_list_constructor([1, 3, 4]),
      linked_list_constructor([1, 4, 5])],
     [1, 1, 2, 3, 4, 4, 5, 6])
    ])
def test_merge_k_lists(lists, result):
    card = main.Jan24
    expected = linked_list_constructor(result)
    actual = card.merge_k_lists(card, lists)
    while expected and actual: