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

Version Path
trackler-2.2.1.180 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.179 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.178 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.177 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.176 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.175 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.174 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.173 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.172 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.171 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.170 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.169 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.167 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.166 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.165 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.164 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.163 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.162 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.161 tracks/python/exercises/saddle-points/example.py
trackler-2.2.1.160 tracks/python/exercises/saddle-points/example.py