-
Notifications
You must be signed in to change notification settings - Fork 9
/
list_utils.py
96 lines (69 loc) · 2.84 KB
/
list_utils.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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
from typing import List
from math import ceil
def get_item_at_position(list_in: List, pos: int) -> List:
"""
Returns the item at pos.
:param list_in: Input list
:param pos: Position of desired item in list_in
:return: Item in pos
"""
pass # remove pass statement and implement me
def print_list_items(list_in: List) -> None:
"""
Given a list, this function iterates through it and prints each element.
:param list_in: Input list
:return: None
"""
pass # remove pass statement and implement me
def sort_by_commit_count(list_in: List) -> List:
"""
Given a list of entries, return a new list sorted based on the commit count.
:param list_in: A list where each entry is a list containing a name and the commit count corresponding to a user
:return: The same list sorted in ascending order based on the commit count
"""
pass # remove pass statement and implement me
def gen_list_of_nums(n: int) -> List[int]:
"""
Given a number (N), this function returns a list of integers from 0 to N (exclusive).
:param n: The number of items the result should contain
:return: A list of integers
"""
pass # remove pass statement and implement me
def half_list(list_in: List, half: int) -> List:
"""
Given a list, this function will return a new list that contains half of the items in the list_in parameter.
:param list_in: The list which will be used to generate the return value
:param half: 1 will use the first half of the input list. 2 will use the second half of the input list.
If the length of list_in is an odd number, round the half value up (hint: math.ceil()).
:return: A list.
"""
pass # remove pass statement and implement me
def remove_odds(list_in: List[int]) -> None:
"""
Given a list of integers, this function removes the odd numbers from the same list.
:return: None
"""
pass # remove pass statement and implement me
def remove_evens(list_in: List[int]) -> None:
"""
Given a list of integers, this function removes the even numbers from the same list.
:return: None
"""
pass # remove pass statement and implement me
def concatenate_lists(list_a: List, list_b: List) -> List:
"""
Given two lists, this function combines them and returns the result as a new list.
:param list_a: A list
:param list_b: Another list
:return: A list containing all elements from list_a and list_b
"""
pass # remove pass statement and implement me
def multiply_list(list_in: List, scalar: int) -> List:
"""
Given a list and an integer, this function will return a new list which is the result of multiplying
the input list by the value of the scalar.
:param list_in: A list
:param scalar: An integer
:return: A list
"""
pass # remove pass statement and implement me