Created
January 6, 2025 15:19
-
-
Save l1x/e15d770fd58940442081b78db636e53b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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