import glob, re
import numpy as np
for f in sorted(glob.glob("npy/identity_N*.npy"), key=lambda p: int(re.search(r"N(\d+)", p).group(1))):
    e = np.load(f); n = e.shape[0]; c = n // 2; best = 0
    for half in range(1, n // 2 + 1):
        lo, hi = c - half, c + half if n % 2 == 0 else c + half + 1
        if lo < 0 or hi > n or not (e[lo:hi, lo:hi] == 2).all(): break
        best = hi - lo
    print("N=%d centre_square_side=%d fraction=%.4f share_of_area=%.4f" % (n, best, best / n, (best / n) ** 2))
