-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpattern_19.py
More file actions
54 lines (45 loc) · 727 Bytes
/
pattern_19.py
File metadata and controls
54 lines (45 loc) · 727 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
"""
n = 3
******
** **
* *
* *
** **
******
n = 5
********** 5 0 5
**** **** 4 2 4
*** *** 3 4 3
** ** 2 6 2
* * 1 8 1
* * 1 8
** ** 2 6
*** *** 3 4
**** ***** 4 2
********** 5 0
upper rhombus (n)
stars: n - i
spaces: 2 * i
stars: n - i
lower rhombus (n)
stars: i + 1
spaces: 2 (n - 1 - i)
stars: i + 1
"""
"""
Time Complexity: O(n^2)
Space Complexity: O(1)
"""
n = int(input())
for i in range(n):
# stars
print(f'{"*" * (n - i)}{" " * 2 * i}{"*" * (n - i)}')
# spaces
# print(end=' ' * 2 * i)
# stars
# print('*' * (n - i))
# lower rhombus
for i in range(n):
print(end='*' * (i + 1))
print(end=' ' * (2 * n - 2 - 2 * i))
print('*' * (i + 1))