Skip to content

Commit 07cd40d

Browse files
committed
changes
1 parent ebbb05b commit 07cd40d

File tree

2 files changed

+38
-1
lines changed

2 files changed

+38
-1
lines changed

local/Mindstix/patternInOneLoop.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ def printPatternStair(ln):
44

55
printPatternStair(6)
66

7-
def printPatternDiamond(ln):
7+
def printPatternDiamond(ln): # LOL
88
for i in range(1, (ln+1)*2):
99
print( ' ' * (ln-i) + "* " * i)
1010

local/Mindstix/spiralMatrix.py

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
def printdata(arr, i, j, m, n):
2+
3+
# If i or j lies outside the matrix
4+
if (i >= m or j >= n):
5+
return
6+
7+
# Print First Row
8+
for p in range(i, n):
9+
print(arr[i][p], end=" ")
10+
11+
# Print Last Column
12+
for p in range(i + 1, m):
13+
print(arr[p][n - 1], end=" ")
14+
15+
# Print Last Row, if Last and
16+
# First Row are not same
17+
if ((m - 1) != i):
18+
for p in range(n - 2, j - 1, -1):
19+
print(arr[m - 1][p], end=" ")
20+
21+
# Print First Column, if Last and
22+
# First Column are not same
23+
if ((n - 1) != j):
24+
for p in range(m - 2, i, -1):
25+
print(arr[p][j], end=" ")
26+
27+
printdata(arr, i + 1, j + 1, m - 1, n - 1)
28+
29+
R = 4
30+
C = 4
31+
arr = [[1, 2, 3, 4],
32+
[5, 6, 7, 8],
33+
[9, 10, 11, 12],
34+
[13, 14, 15, 16]]
35+
36+
printdata(arr, 0, 0, R, C)
37+

0 commit comments

Comments
 (0)