def count_points(ship_coords, R, pegasus_coords, N, commands):
def distance(coord1, coord2):
return sum((x1 - x2) ** 2 for x1, x2 in zip(coord1, coord2)) ** 0.5
def is_within_range(coords):
return distance(coords, ship_coords) <= R
visited_points = set()
current_coords = ship_coords
for _ in range(N):
command = commands[_]
current_coords = (current_coords[0] + command[0], current_coords[1] + command[1], current_coords[2] + command[2])
visited_points.add(current_coords)
if is_within_range(current_coords):
visited_points.add(pegasus_coords)
break
return len(visited_points)
input_data1 = (0, 0, 0, 400)
input_data2 = (0, 0, 0, 4)
input_data3 = (0, 0, 0, 400)
ship_coords = (0, 0, 100)
pegasus_coords = (4, 0, 0)
N = 3
commands1 = [(3, 3, 3), (2, -3, -3), (-6, 0, 0)]
commands2 = [(3, 3, 3), (2, -3, -3), (-6, 0, 0)]
commands3 = [(3, 3, 3), (2, -3, -3), (-6, 0, 0)]
result1 = count_points(input_data1, ship_coords, pegasus_coords, N, commands1)
result2 = count_points(input_data2, ship_coords, pegasus_coords, N, commands2)
result3 = count_points(input_data3, ship_coords, pegasus_coords, N, commands3)
print(result1)
print(result2)
print(result3)