-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathrun.py
34 lines (27 loc) · 1005 Bytes
/
run.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
import sys
from rosalind import *
problems = {k: v for k, v in [(item[len('problem_'):], item)
for item in dir()
if item.startswith('problem_')]}
def help():
print "Type 'help' to display this text at any time."
print "Type 'prob' to display a list of problems."
print "Type 'exit' to exit."
if __name__ == "__main__":
help()
while True:
problem_code = raw_input('Please choose a problem to solve: ').strip()
try:
problem = problems[problem_code]
eval('{}()'.format(problem))
except:
if problem_code == 'help':
help()
elif problem_code in ('prob', 'problems'):
print "Here is a list of problems."
for i in problems:
print i
elif problem_code == 'exit':
eval('exit()')
else:
print "I'm sorry, that's not a valid problem."