Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- a = [1,5,9,13,34,55]
- b = [3,4,6,15,40]
- c = [2,7,60,70]
- def get_distance(a_word, b_word, c_word):
- maxint = max(a_word, b_word, c_word)
- minint = min(a_word, b_word, c_word)
- return maxint - minint
- def find_shortest_bounds(a, b, c):
- a_dist = sys.maxint
- final_a = None
- final_b = None
- final_c = None
- for a_word in a:
- b_dist = sys.maxint
- distance = None
- for b_word in b:
- c_dist = sys.maxint
- for c_word in c:
- distance = get_distance(a_word, b_word, c_word)
- if distance > c_dist:
- distance = c_dist
- break
- else:
- c_dist = distance
- final_c = c_word
- if distance > b_dist:
- distance = b_dist
- break
- else:
- b_dist = distance
- final_b = b_word
- if distance > a_dist:
- break
- else:
- a_dist = distance
- final_a = a_word
- return a_dist, (final_a, final_b, final_c)
- print find_shortest_bounds(a,b,c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement