Guest User

Untitled

a guest
Oct 21st, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.61 KB | None | 0 0
  1. #!/usr/bin/env python3
  2. import sys
  3. import importlib
  4. import time
  5.  
  6. OUTPUT = '\033[95m'
  7. ERROR = '\033[91m'
  8. RESULT = '\033[92m'
  9. ENDC = '\033[0m'
  10.  
  11. def output(colorc, text):
  12. print(colorc + text + ENDC)
  13.  
  14. def main():
  15. name = 'p%03d' % int(sys.argv[1])
  16. output(OUTPUT, 'Running %s.main() ...' % name)
  17. module = importlib.import_module(name)
  18. starttime = time.time()
  19. result = module.main()
  20. endtime = time.time()
  21. output(RESULT, 'Result: %s' % str(result))
  22. output(RESULT, 'Time: %.3f s' % (endtime - starttime))
  23.  
  24.  
  25. if __name__ == '__main__':
  26. if len(sys.argv) != 2:
  27. output(ERROR, 'Missing argument: problem number!')
  28. else:
  29. main()
Add Comment
Please, Sign In to add comment