def distance_to_edge(coordinate, grid_size):
    """Calculate the maximum distance to the edge for this coordinate."""
    half_point = (grid_size + 1) / 2
    return int(round(abs(coordinate - half_point + 1) + half_point, 0))