Skip to content

Commit 7845ac0

Browse files
authored
Merge pull request openAOD#911 from Mahak008/main
Numeric Patterns
2 parents b572ab1 + 5a9d071 commit 7845ac0

40 files changed

+959
-0
lines changed

Numeric Patterns/numericpattern223.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, height + 1):
6+
7+
if(j == 1):
8+
print(height - i,end=" ")
9+
10+
elif(j <= height - i + 1):
11+
print("*",end=" ")
12+
13+
else:
14+
print(end=" ")
15+
16+
print()
17+
18+
# Sample Input :- 6
19+
# Output :-
20+
# 5 * * * * *
21+
# 4 * * * *
22+
# 3 * * *
23+
# 2 * *
24+
# 1 *
25+
# 0

Numeric Patterns/numericpattern224.py

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, i + 1):
6+
7+
if(i == j):
8+
print(i - 1,end=" ")
9+
10+
else:
11+
print("*",end=" ")
12+
13+
print()
14+
15+
# Sample Input :- 5
16+
# Output :-
17+
# 0
18+
# * 1
19+
# * * 2
20+
# * * * 3
21+
# * * * * 4
22+
# * * * * * 5

Numeric Patterns/numericpattern225.py

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, height + 1):
6+
7+
if(j == height - i + 1):
8+
num = height - i
9+
print(num,end=" ")
10+
11+
elif(j < height - i + 1):
12+
print("*",end=" ")
13+
14+
else:
15+
print(end=" ")
16+
17+
print()
18+
19+
# Sample Input :- 6
20+
# Output :-
21+
# * * * * * 5
22+
# * * * * 4
23+
# * * * 3
24+
# * * 2
25+
# * 1
26+
# 0

Numeric Patterns/numericpattern226.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, height + 1):
6+
7+
if(i == j or i == height - j + 1):
8+
print(i,end=" ")
9+
10+
else:
11+
print(end=" ")
12+
13+
print()
14+
15+
# Sample Input :- 5
16+
# Output :-
17+
# 1 1
18+
# 2 2
19+
# 3
20+
# 4 4
21+
# 5 5

Numeric Patterns/numericpattern227.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, height + 1):
6+
7+
if(i == j or i == height - j + 1):
8+
print(height - i + 1,end=" ")
9+
10+
else:
11+
print(end=" ")
12+
13+
print()
14+
15+
# Sample Input :- 5
16+
# Output :-
17+
# 5 5
18+
# 4 4
19+
# 3
20+
# 2 2
21+
# 1 1

Numeric Patterns/numericpattern228.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, height + 1):
6+
7+
if(i == j or i == height - j + 1):
8+
print(j,end=" ")
9+
10+
else:
11+
print(end=" ")
12+
13+
print()
14+
15+
# Sample Input :- 5
16+
# Output :-
17+
# 1 5
18+
# 2 4
19+
# 3
20+
# 2 4
21+
# 1 5

Numeric Patterns/numericpattern229.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, height + 1):
6+
7+
if(i == j):
8+
print(height - i + 1,end=" ")
9+
10+
elif(i == height - j + 1):
11+
print(height - j + 1,end=" ")
12+
13+
else:
14+
print(end=" ")
15+
16+
print()
17+
18+
# Sample Input :- 5
19+
# Output :-
20+
# 5 1
21+
# 4 2
22+
# 3
23+
# 4 2
24+
# 5 1

Numeric Patterns/numericpattern230.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, height + 1):
6+
7+
if(i == height//2 + 1):
8+
print(j,end=" ")
9+
10+
elif(j == height//2 + 1):
11+
print(i,end=" ")
12+
13+
else:
14+
print(end=" ")
15+
16+
print()
17+
18+
# Sample Input :- 5
19+
# Output :-
20+
# 1
21+
# 2
22+
# 1 2 3 4 5
23+
# 4
24+
# 5

Numeric Patterns/numericpattern231.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, height + 1):
6+
7+
if(i == height//2 + 1):
8+
print(j,end=" ")
9+
10+
elif(j == height//2 + 1):
11+
print(height - i + 1,end=" ")
12+
13+
else:
14+
print(end=" ")
15+
16+
print()
17+
18+
# Sample Input :- 5
19+
# Output :-
20+
# 5
21+
# 4
22+
# 1 2 3 4 5
23+
# 2
24+
# 1

Numeric Patterns/numericpattern234.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
height = int(input())
2+
3+
for i in range(1, height + 1):
4+
5+
for j in range(1, height + 1):
6+
7+
if(i == j):
8+
print(1,end=" ")
9+
10+
else:
11+
print(0,end=" ")
12+
13+
print()
14+
15+
# Sample Input :- 5
16+
# Output :-
17+
# 1 0 0 0 0
18+
# 0 1 0 0 0
19+
# 0 0 1 0 0
20+
# 0 0 0 1 0
21+
# 0 0 0 0 1

0 commit comments

Comments
 (0)