fork download
  1. '''
  2. Robogame
  3. https://w...content-available-to-author-only...f.com/problems/ROBOGAME
  4.  
  5. '''
  6. from time import time
  7. import re
  8.  
  9. start_time = time()
  10. fin = open("robots-big.txt", "r")
  11. fout = open("robots-big-solved-function.txt", "a")
  12. counter = 1
  13.  
  14. def check_robots(string):
  15. p = re.compile("[0-9]")
  16. c = ()
  17. for m in p.finditer(string):
  18. c += (m.start(), m.group())
  19. if len(c) <= 2 or c[1] == str(0) and c[3] == str(0):
  20. return (" safe: " + line)
  21. d = (c[2]-c[0])-1
  22. if d <= int(c[1]) or int(c[3]):
  23. return (" unsafe: " + line)
  24. else:
  25. return (" safe: " + line)
  26.  
  27. for line in fin:
  28. fout.write(str(counter))
  29. fout.write(check_robots(line))
  30. counter += 1
  31.  
  32. end_time = time()
  33. elapsed = end_time - start_time
  34.  
  35. print(elapsed)
  36.  
  37. fout.write(str(elapsed))
  38. fin.close()
  39. fout.close()
  40.  
Runtime error #stdin #stdout #stderr 0.02s 27968KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Traceback (most recent call last):
  File "./prog.py", line 10, in <module>
    fin = open("robots-big.txt", "r")
FileNotFoundError: [Errno 2] No such file or directory: 'robots-big.txt'