-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathleetcoder.py
More file actions
30 lines (26 loc) · 974 Bytes
/
leetcoder.py
File metadata and controls
30 lines (26 loc) · 974 Bytes
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
from problem_menu import ProblemMenu
from problem_runner import ProblemRunner
def main():
try:
while True:
problems = ProblemMenu.list_problems()
ProblemMenu.display_menu(problems)
try:
choice = int(input("\nEnter your choice: "))
except ValueError:
print("Invalid input. Please enter a number.")
continue
if choice == 0:
print("Exiting...")
break
elif 1 <= choice <= len(problems):
difficulty, problem_name = problems[choice - 1]
runner = ProblemRunner(difficulty, problem_name)
runner.run()
input("\nPress Enter to return to the menu...")
else:
print("Invalid choice. Please try again.")
except KeyboardInterrupt:
print("\nBye 🥺...")
if __name__ == "__main__":
main()