Skip to content

Instantly share code, notes, and snippets.

@l1x
Created January 6, 2025 15:19
Show Gist options
  • Save l1x/e15d770fd58940442081b78db636e53b to your computer and use it in GitHub Desktop.
Save l1x/e15d770fd58940442081b78db636e53b to your computer and use it in GitHub Desktop.
sp = [
[1, 2, 3],
[8, 9, 4],
[7, 6, 5]
]
def rot90(m):
return list(zip(*m))[::-1]
def spiral_print(m, acc):
if len(m) == 0:
acc = list(map(list, acc))
print(sum(acc, []))
return 'ok'
else:
acc.append(m[0])
mn = list(zip(*m[1:]))[::-1]
return spiral_print(mn, acc)
spiral_print(sp, [])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment