-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Hakan
authored and
Hakan
committed
Jul 16, 2020
1 parent
ab58893
commit 42abf0e
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
array = [[1,2,3], | ||
[4,5,6], | ||
[7,8,9]] | ||
|
||
def snail(array): | ||
a = [] | ||
while array: | ||
a.extend(list(array.pop(0))) | ||
array = list(zip(*array)) | ||
array.reverse() | ||
return a | ||
|
||
print(snail(array)) | ||
|
||
# def snail(array): | ||
# dizi= [] | ||
# n = len(array) | ||
# while n>0: | ||
# if array==[[]]: break | ||
# for i in range(len(array)-1): | ||
# if i == 0: | ||
# dizi.extend(array[i]) | ||
# array.pop(i) | ||
# n -= 1 | ||
# dizi.append(array[i][-1]) | ||
# else: | ||
# dizi.append(array[i][-1]) | ||
# for i in range(len(array)-1,-1,-1): | ||
# dizi.append(array[-1][i]) | ||
# array.pop(-1) | ||
# n -= 1 | ||
# for i in range(len(array)-1,-1,-1): | ||
# dizi.append(array[i][0]) | ||
# array2=[] | ||
# for i in array: | ||
# array2.append(i[1:-1]) | ||
# array = array2 | ||
# return dizi |