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.159 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.158 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.157 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.156 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.155 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.154 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.153 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.152 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.151 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.150 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.149 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.148 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.147 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.146 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.145 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.144 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.143 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.142 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.141 tracks/python/exercises/spiral-matrix/example.py
trackler-2.2.1.140 tracks/python/exercises/spiral-matrix/example.py