-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
48 lines (40 loc) · 1.28 KB
/
main.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
from typing import Tuple, List, Callable
import binary_tree
import linked_list
import queue
import search
import sort
import stack
import oct_nov_2021_9618_41
import may_jun_2022_9618_43
import may_jun_2022_9618_42
import may_jun_2022_9618_41
from util import menu
# test a function that accepts a length as input
def length_input(test: Callable[[int], None]) -> None:
length = int(input("enter length to test: "))
test(length)
# all tests that can be performed with their names
tests: List[Tuple[str, Callable[[], None]]] = list(map(
lambda test: (test[0], lambda: length_input(test[1].test)), # type: ignore
[
("searches", search),
("sorts", sort),
("stack", stack),
("queue", queue),
("linked list", linked_list),
("binary tree", binary_tree)
]
))
past_papers: List[Tuple[str, Callable[[], None]]] = [
("oct_nov_2021_9618_41", oct_nov_2021_9618_41.q_3),
("may_jun_2022_9618_41", may_jun_2022_9618_41.questions),
("may_jun_2022_9618_42", may_jun_2022_9618_42.questions),
("may_jun_2022_9618_43", may_jun_2022_9618_43.questions)
]
# print all tests and let the user choose one or all
if __name__ == "__main__":
menu([
("tests", lambda: menu(tests)),
("past papers", lambda: menu(past_papers))
])