Skip to content

Instantly share code, notes, and snippets.

@ctralie
Created August 9, 2025 14:34
Show Gist options
  • Save ctralie/7d5ab371a27a96d4218798a580519ea9 to your computer and use it in GitHub Desktop.
Save ctralie/7d5ab371a27a96d4218798a580519ea9 to your computer and use it in GitHub Desktop.
# Find two points that achieve the diameter
i1, j1 = np.unravel_index(np.argmax(D), (N, N))
# Find the closest pair of points are at least 5 apart from the diagonal
I, J = np.meshgrid(np.arange(N), np.arange(N), indexing='ij')
i2, j2 = np.unravel_index(np.argmin(D + np.max(D)*(J - I < 5)), (N, N))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment