forked from uchicago-cs/python-practice-problems
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmake_star_strings.py
63 lines (42 loc) · 1.65 KB
/
make_star_strings.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
def make_star_strings(lst):
"""
Create a list of star strings
Input:
lst (list of nonnegative integers): the list
Returns: A list of strings of stars (*)
"""
### 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_make_star_strings(lst, expected):
recreate_msg = utils.gen_recreate_msg("make_star_strings", *(lst,))
actual = make_star_strings(lst)
utils.check_none(actual, recreate_msg)
utils.check_type(actual, expected, recreate_msg)
utils.check_equals(actual, expected, recreate_msg)
def test_make_star_strings_1():
lst = []
do_test_make_star_strings(lst=lst, expected=[])
def test_make_star_strings_2():
lst = [1]
do_test_make_star_strings(lst=lst, expected=["*"])
def test_make_star_strings_3():
lst = [3]
do_test_make_star_strings(lst=lst, expected=["***"])
def test_make_star_strings_4():
lst = [1, 2, 3]
do_test_make_star_strings(lst=lst, expected=["*", "**", "***"])
def test_make_star_strings_5():
lst = [1, 2, 3, 2, 0]
do_test_make_star_strings(lst=lst, expected=["*", "**", "***", "**", ""])
def test_make_star_strings_6():
lst = [2, 1, 5, 3, 3]
do_test_make_star_strings(lst=lst, expected=["**", "*", "*****", "***", "***"])