-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathascii-rangoli.py
54 lines (47 loc) · 2.06 KB
/
ascii-rangoli.py
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
'''
* This is a Hackerrank problem.
* Usage of "string" modul.
'''
import string
def print_rangoli(size):
alpha = string.ascii_uppercase
L = []
for i in range(size):
s = "-".join(alpha[i:size])
L.append((s[::-1]+s[1:]).center(4*size-3, "-"))
print('\n'.join(L[:0:-1]+L))
if __name__ == '__main__':
n = int(input("Enter range: "))
print_rangoli(n)
''' Output:
Enter range: 15
----------------------------O----------------------------
--------------------------O-N-O--------------------------
------------------------O-N-M-N-O------------------------
----------------------O-N-M-L-M-N-O----------------------
--------------------O-N-M-L-K-L-M-N-O--------------------
------------------O-N-M-L-K-J-K-L-M-N-O------------------
----------------O-N-M-L-K-J-I-J-K-L-M-N-O----------------
--------------O-N-M-L-K-J-I-H-I-J-K-L-M-N-O--------------
------------O-N-M-L-K-J-I-H-G-H-I-J-K-L-M-N-O------------
----------O-N-M-L-K-J-I-H-G-F-G-H-I-J-K-L-M-N-O----------
--------O-N-M-L-K-J-I-H-G-F-E-F-G-H-I-J-K-L-M-N-O--------
------O-N-M-L-K-J-I-H-G-F-E-D-E-F-G-H-I-J-K-L-M-N-O------
----O-N-M-L-K-J-I-H-G-F-E-D-C-D-E-F-G-H-I-J-K-L-M-N-O----
--O-N-M-L-K-J-I-H-G-F-E-D-C-B-C-D-E-F-G-H-I-J-K-L-M-N-O--
O-N-M-L-K-J-I-H-G-F-E-D-C-B-A-B-C-D-E-F-G-H-I-J-K-L-M-N-O
--O-N-M-L-K-J-I-H-G-F-E-D-C-B-C-D-E-F-G-H-I-J-K-L-M-N-O--
----O-N-M-L-K-J-I-H-G-F-E-D-C-D-E-F-G-H-I-J-K-L-M-N-O----
------O-N-M-L-K-J-I-H-G-F-E-D-E-F-G-H-I-J-K-L-M-N-O------
--------O-N-M-L-K-J-I-H-G-F-E-F-G-H-I-J-K-L-M-N-O--------
----------O-N-M-L-K-J-I-H-G-F-G-H-I-J-K-L-M-N-O----------
------------O-N-M-L-K-J-I-H-G-H-I-J-K-L-M-N-O------------
--------------O-N-M-L-K-J-I-H-I-J-K-L-M-N-O--------------
----------------O-N-M-L-K-J-I-J-K-L-M-N-O----------------
------------------O-N-M-L-K-J-K-L-M-N-O------------------
--------------------O-N-M-L-K-L-M-N-O--------------------
----------------------O-N-M-L-M-N-O----------------------
------------------------O-N-M-N-O------------------------
--------------------------O-N-O--------------------------
----------------------------O----------------------------
'''