Advertisement
jamestha3d

flatland.py

Apr 15th, 2020
286
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.70 KB | None | 0 0
  1. #number of countries(#1 indexed)
  2. n = 99998
  3.  
  4. #array of spacestations location (0-indexed)
  5. c = [28000, 58701, 43043, 24909, 28572]
  6.  
  7.  
  8. c.sort()
  9.  
  10. end, start = 0,0
  11.  
  12. #edge cases.
  13. #if there is no space station at the end
  14. if c[len(c)-1] != n:
  15.     end = 1
  16.     c.append(n - 1)
  17.     #print(c)
  18.  
  19. #if there is no space spation at the beginning
  20. if c[0] != 0:
  21.     beginning = 1
  22.     c.insert(0, 0)
  23.     #print(c)
  24.        
  25.  
  26. #array of differences
  27. c_diff = []
  28.  
  29. #find the difference of each value in c
  30. for i in range(len(c) - 1):
  31.     c_diff.append(c[i+1] - c[i])
  32. #print(c_diff)
  33.  
  34. if end == 1:
  35.     c_diff[len(c_diff) - 1] *= 2
  36. if start == 1:
  37.     c_diff[0] *= 2
  38.  
  39. answer = max(c_diff)//2
  40. print(answer)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement