-
Notifications
You must be signed in to change notification settings - Fork 289
/
Copy pathhas_more.py
76 lines (58 loc) · 2.08 KB
/
has_more.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
def has_more(lst1, lst2, target):
"""
Determine which list contains more of the target value
Inputs:
lst1 (list): first list
lst2 (list): second list
target: the target value
Returns: True if lst1 contains more of target, False otherwise
"""
### Replace pass with your code
pass
#############################################################
### ###
### Testing code. ###
### !!! DO NOT MODIFY ANY CODE BELOW THIS POINT !!! ###
### ###
#############################################################
import sys
sys.path.append('../')
import test_utils as utils
def do_test_has_more(lst1, lst2, target, expected):
recreate_msg = utils.gen_recreate_msg("has_more", *(lst1, lst2, target))
actual = has_more(lst1, lst2, target)
utils.check_none(actual, recreate_msg)
utils.check_type(actual, expected, recreate_msg)
utils.check_equals(actual, expected, recreate_msg)
def test_has_more_1():
lst1 = []
lst2 = []
do_test_has_more(lst1=lst1, lst2=lst2, target=1, expected=False)
def test_has_more_2():
lst1 = []
lst2 = [1]
do_test_has_more(lst1=lst1, lst2=lst2, target=1, expected=False)
def test_has_more_3():
lst1 = [1]
lst2 = [1]
do_test_has_more(lst1=lst1, lst2=lst2, target=1, expected=False)
def test_has_more_4():
lst1 = [1]
lst2 = []
do_test_has_more(lst1=lst1, lst2=lst2, target=1, expected=True)
def test_has_more_5():
lst1 = [1, 2, 1]
lst2 = [1, 2, 2]
do_test_has_more(lst1=lst1, lst2=lst2, target=1, expected=True)
def test_has_more_6():
lst1 = [1, 2, 2]
lst2 = [2, 1, 1]
do_test_has_more(lst1=lst1, lst2=lst2, target=1, expected=False)
def test_has_more_7():
lst1 = [1, 2, 2, 1]
lst2 = [2, 1, 1]
do_test_has_more(lst1=lst1, lst2=lst2, target=1, expected=False)
def test_has_more_8():
lst1 = [1, 1, 2, 2]
lst2 = [2, 1, 1, 1, 1]
do_test_has_more(lst1=lst1, lst2=lst2, target=2, expected=True)