Exemplo n.º 1
0
def test_multi(n1, n2, n3):
    l1 = mklist(*map(int, reversed(str(n1))))
    l2 = mklist(*map(int, reversed(str(n2))))
    l3 = mklist(*map(int, reversed(str(n3))))

    r = add_two_numbers_v2(l1, l2, l3)
    assert rll2int(r) == (n1 + n2 + n3)
Exemplo n.º 2
0
def test_random(n1, n2):
    l1 = mklist(*map(int, str(n1)))
    l2 = mklist(*map(int, str(n2)))

    r = add_two_numbers_v1(l1, l2)
    assert ll2int(r) == (n1 + n2)

    r2 = add_two_numbers_v2(l1, l2)
    assert r == r2
Exemplo n.º 3
0
def test_random(n1, n2):
    l1 = mklist(*map(int, reversed(str(n1))))
    l2 = mklist(*map(int, reversed(str(n2))))

    r1 = add_two_numbers_v1(l1, l2)
    r2 = add_two_numbers_v2(l1, l2)
    r3 = add_two_numbers_v3(l1, l2)

    assert r1 == r2
    assert r1 == r3
Exemplo n.º 4
0
def test_multi(check_itr=1000):
    for _ in range(check_itr):
        a = []
        no_dup = randint(2, 100)
        for i in range(no_dup):  # no dup array length
            repeat = randint(1, 3)
            a += [i] * repeat
        new_head = deleteDuplicates(mklist(*a))
        assert convert_array(new_head) == list(range(no_dup))
Exemplo n.º 5
0
def test_random(xs_n):
    xs, n = xs_n

    head1 = mklist(*xs)
    head2 = mklist(*xs)
    head3 = mklist(*xs)

    r1 = rm_nth_from_end_v1(head1, n)
    r2 = rm_nth_from_end_v2(head2, n)
    r3 = rm_nth_from_end_v3(head3, n)

    xs_dup = xs[:]
    del xs[-n]
    assert convert_array(r1) == xs

    del xs_dup[-n]
    assert r1 == mklist(*xs_dup)

    assert r1 == r2
    assert r1 == r3
Exemplo n.º 6
0
def test_multi(check_itr=1000):
    for _ in range(check_itr):
        in_a = []
        expect_a = []
        last_num = randint(2, 100)
        for i in range(last_num):  # no dup array length
            repeat = randint(1, 3)
            if repeat == 1:
                expect_a += [i]
            in_a += [i] * repeat
        new_head = deleteDuplicates(mklist(*in_a))
        assert convert_array(new_head) == expect_a
Exemplo n.º 7
0
def test_ones():
    assert [42] == convert_array(deleteDuplicates(mklist(42, 42, 42)))