Created
August 3, 2018 03:02
-
-
Save adityabhushan/b8e628709bb27d85d331df60d4a99afc to your computer and use it in GitHub Desktop.
Revisions
-
adityabhushan created this gist
Aug 3, 2018 .There are no files selected for viewing
This file contains hidden or 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 charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,49 @@ # N = "hello hello_world" # print(N.split()[1]) # arr = [[1,2,3,4],[5,6,7,8],[9,10,11,12],[13,14,15,16]] arr = [[1,2,3],[4,5,6],[7,8,9],[10,11,12]] top = 0 bottom = len(arr)-1 left = 0 right = len(arr[0])-1 # print(top) # print(bottom) # print(left) # print(right) newarr = [] r,c = 0,0 while (1): while(c <= right): newarr.append(arr[r][c]) print('---->') print(newarr) c += 1 print('c is ',c) if(c==right): right = right - 1 while(r <= bottom): newarr.append(arr[r][c]) print("down") print(newarr) r += 1 if(r == bottom): bottom = bottom - 1 while(c >= left): newarr.append(arr[r][c]) print('<------') print(newarr) c -= 1 if(c == left): left = left + 1 while(r >= top): newarr.append(arr[r][c]) print("up") print(newarr) r -= 1 if(r == top): top = top + 1 if(top == bottom and left == right): break print(newarr)