-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathminOfTwoLists.py
More file actions
64 lines (44 loc) · 1.64 KB
/
Copy pathminOfTwoLists.py
File metadata and controls
64 lines (44 loc) · 1.64 KB
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
import pytest
def minOfTwoLists(alist, blist):
'''
Returns a list with each element being the smallest element at each index, comparing elements in alist and blist.
If both elements are the same size in alist and blist, the element from alist is chosen.
'''
if type(alist) != list or type(blist) != list:
return False
if len(alist) != len(blist):
return False
for item in alist:
if type(item) != str:
return False
for item in blist:
if type(item) != str:
return False
combList = alist
for i in range(len(blist)):
if len(blist[i]) < len(combList[i]):
combList[i] = blist[i]
return combList
def test_minOfTwoLists_0():
assert(minOfTwoLists(42, [1])==False)
def test_minOfTwoLists_1():
assert(minOfTwoLists(['ox'],['cat'])==['ox'])
def test_minOfTwoLists_2():
assert(minOfTwoLists(['ox','bear'],['cat', 'cow'])==['ox', 'cow'])
def test_minOfTwoLists_3():
assert(minOfTwoLists(['bear','cow'],['ox','cat'])==['ox', 'cow'])
def test_minOfTwoLists_4():
assert(minOfTwoLists(['bear','cow','crow','sparrow'],\
['ox','cat','mouse','ox'])==\
['ox', 'cow','crow','ox'])
def test_minOfTwoLists_5():
assert(minOfTwoLists(['bear','cow','crow'],['ox','cat','mouse'])==\
['ox', 'cow','crow'])
def test_minOfTwoLists_6():
assert(minOfTwoLists(['ox'],42)==False)
def test_minOfTwoLists_7():
assert(minOfTwoLists(42,['ox'])==False)
def test_minOfTwoLists_8():
assert(minOfTwoLists(['ox', 'fox'],['ox',17])==False)
def test_minOfTwoLists_9():
assert(minOfTwoLists(['cow','bear'],['ox'])==False)