Sha256: d4353cbd72d084d009fbc30320385ccc15d793f82546b5fa0ba3ca09b09a0888

Contents?: true

Size: 314 Bytes

Versions: 78

Compression:

Stored size: 314 Bytes

Contents

def spiral(size):
    sm = [[0]*size for k in range(size)]
    i, j, el = 0, -1, 1
    di, dj = [0, 1, 0, -1], [1, 0, -1, 0]
    for x in range(2*size - 1):
        for y in range((2*size - x) // 2):
            i += di[x % 4]
            j += dj[x % 4]
            sm[i][j] = el
            el += 1
    return sm

Version data entries

78 entries across 78 versions & 1 rubygems

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