Исанбеков Дамир 414 КФ FarGalaxy 8416
Жан-Юль-Ян Азель, 414 группа (КФ) FarGalaxy 8414
f1import mathf1import math
22
n3def calculate_distance(galaxy_a, galaxy_b):n3def distance(galaxy1, galaxy2):
4    return math.sqrt((galaxy_a[0] - galaxy_b[0]) ** 2 + (galaxy_a[1] - g4    return math.sqrt((galaxy1[0] - galaxy2[0]) ** 2 + (galaxy1[1] - gala
>alaxy_b[1]) ** 2 + (galaxy_a[2] - galaxy_b[2]) ** 2)>xy2[1]) ** 2 + (galaxy1[2] - galaxy2[2]) ** 2)
5galaxy_list = []5galaxies = []
6while True:6while True:
n7    input_line = input().strip()n7    line = input().strip()
8    if ' ' not in input_line:8    if ' ' not in line:
9        break9        break
t10    coord_x, coord_y, coord_z, galaxy_name = input_line.split()t10    x, y, z, name = line.split()
11    galaxy_list.append((float(coord_x), float(coord_y), float(coord_z), 11    galaxies.append((float(x), float(y), float(z), name))
>galaxy_name)) 
12max_distance_found = 012max_distance = 0
13most_distant_galaxies = ('', '')13farthest_galaxies = ('', '')
14for first_galaxy_index in range(len(galaxy_list)):14for i in range(len(galaxies)):
15    for second_galaxy_index in range(first_galaxy_index + 1, len(galaxy_15    for j in range(i + 1, len(galaxies)):
>list)): 
16        distance_between = calculate_distance(galaxy_list[first_galaxy_i16        d = distance(galaxies[i], galaxies[j])
>ndex], galaxy_list[second_galaxy_index]) 
17        if distance_between > max_distance_found:17        if d > max_distance:
18            max_distance_found = distance_between18            max_distance = d
19            most_distant_galaxies = tuple(sorted([galaxy_list[first_gala19            farthest_galaxies = tuple(sorted([galaxies[i][3], galaxies[j
>xy_index][3], galaxy_list[second_galaxy_index][3]]))>][3]]))
20print(most_distant_galaxies[0], most_distant_galaxies[1])20print(farthest_galaxies[0], farthest_galaxies[1])
Legends
Colors
 Added 
Changed
Deleted
Links
(f)irst change
(n)ext change
(t)op