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