Advertisement
Guest User

Untitled

a guest
Jul 28th, 2017
49
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.98 KB | None | 0 0
  1. import sys
  2.  
  3. a = [1,5,9,13,34,55]
  4. b = [3,4,6,15,40]
  5. c = [2,7,60,70]
  6.  
  7.  
  8. def get_distance(a_word, b_word, c_word):
  9. maxint = max(a_word, b_word, c_word)
  10. minint = min(a_word, b_word, c_word)
  11. return maxint - minint
  12.  
  13.  
  14. def find_shortest_bounds(a, b, c):
  15. a_dist = sys.maxint
  16. final_a = None
  17. final_b = None
  18. final_c = None
  19. for a_word in a:
  20. b_dist = sys.maxint
  21. distance = None
  22. for b_word in b:
  23. c_dist = sys.maxint
  24. for c_word in c:
  25. distance = get_distance(a_word, b_word, c_word)
  26. if distance > c_dist:
  27. distance = c_dist
  28. break
  29. else:
  30. c_dist = distance
  31. final_c = c_word
  32. if distance > b_dist:
  33. distance = b_dist
  34. break
  35. else:
  36. b_dist = distance
  37. final_b = b_word
  38. if distance > a_dist:
  39. break
  40. else:
  41. a_dist = distance
  42. final_a = a_word
  43. return a_dist, (final_a, final_b, final_c)
  44.  
  45.  
  46. print find_shortest_bounds(a,b,c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement