-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
156 lines (143 loc) · 4.12 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
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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
from InquirerPy import inquirer
from InquirerPy.base.control import Choice
from InquirerPy.separator import Separator
import pyfiglet
def main():
welcome = pyfiglet.figlet_format("Algo CLI", font="basic", width=100)
print(welcome)
print("Welcome to Algo CLI - A Data Structures and Algorithms CLI reference.")
print("Use the arrow keys to choose a menu option, Press Enter to select.")
while True:
select_item = select()
if select_item == "Search":
search()
if select_item == "Algorithms":
algorithms()
if select_item == "Data Structures":
data_structures()
if select_item == None:
break
quit()
def select():
select = inquirer.select(
message = "Please select an option: \n",
choices=[
"Search",
"Algorithms",
"Data Structures",
Choice(value=None, name="Exit")
],
default = "Algorithms",
).execute()
return select
def search():
search_name = inquirer.text(message = "Enter Algorithm or Data Structure name: ",).execute()
search_input = input()
if input == None:
print("Not found, Please try again")
else:
select = inquirer.select(
message = "Not found, Do you want to try again?",
choices = [
"Search Again\n",
"Go Back",
"Quit",
],
default = "Search Again",
).execute()
if select == "Search Again":
search()
if select == "Go Back":
main()
if select == "Quit":
quit()
def algorithms():
select = inquirer.select(
message = "Please choose a Algorithm type: \n",
choices = [
"Searching",
"Sorting",
"Graphs",
"Trees",
"Other\n",
"Go Back",
"Quit",
],
default = "Searching",
).execute()
if select == "Searching":
searching()
if select == "Sorting":
sorting()
if select == "Graphs":
graphs()
if select == "Trees":
trees()
if select == "Other":
other()
if select == "Go Back":
main()
if select == "Quit":
quit()
def sorting():
select = inquirer.select(
message = "Please choose a sorting Algorithm: \n",
choices = [
"Insertion Sort",
"Heap Sort",
"Selection Sort",
"Merge Sort",
"Quick Sort",
"Couting Sort",
"Bubble Sort",
"Radix Sort",
"Shell Sort",
"Comb Sort",
"Pigeonhole Sort",
"Cycle Sort\n",
"Go Back",
"Quit",
],
default = "Searching",
).execute()
if select == "Bubble Sort":
print(
"def bubbleSort(arr):\n n = len(arr)\n for i in range(n):\n for j in range(0, n-i-1):\n if arr[j] > arr[j+1]:\n arr[j], arr[j+1] = arr[j+1], arr[j]")
print("\n Source: https://www.geeksforgeeks.org/bubble-sort/ \n")
if select == "Go Back":
main()
if select == "Quit":
quit()
def data_structures():
select = inquirer.select(
message = "Please choose a Data Structure: \n",
choices = [
"Arrays",
"Queues",
"Stacks",
"Linked Lists",
"Trees",
"Graphs\n",
"Go Back",
"Quit",
],
default = "Array",
).execute()
if select == "Arrays":
arrays()
if select == "Queues":
queues()
if select == "Stacks":
stacks()
if select == "Linked Lists":
linked_lists()
if select == "Trees":
trees()
if select == "Graphs":
Graphs()
if select == "Go Back":
main()
if select == "Quit":
quit()
if __name__ == "__main__":
main()