Sha256: 1e8c79e7e5c9b5c33a3fd1955bbd4b4348e4f5b06612b296167d1019e768c23c
Contents?: true
Size: 345 Bytes
Versions: 396
Compression:
Stored size: 345 Bytes
Contents
def saddle_points(m): if not m: return set() if any(len(r) != len(m[0]) for r in m): raise ValueError('irregular matrix') mmax = [max(r) for r in m] mmin = [min(c) for c in zip(*m)] points = [(i, j) for i in range(len(m)) for j in range(len(m[0])) if mmax[i] == mmin[j]] return set(points)
Version data entries
396 entries across 396 versions & 1 rubygems