-
Notifications
You must be signed in to change notification settings - Fork 183
/
11 - Alphabet Rangoli.py
45 lines (39 loc) · 1.15 KB
/
11 - Alphabet 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
# ========================
# Information
# ========================
# Direct Link: https://www.hackerrank.com/challenges/alphabet-rangoli/problem
# Difficulty: Easy
# Max Score: 20
# Language: Python
# ========================
# Solution
# ========================
def print_rangoli(size):
'''Prints Rangoli Design'''
width = size*4-3
string = ''
for i in range(1, size+1):
for j in range(0, i):
string += chr(96+size-j)
if len(string) < width:
string += '-'
for k in range(i-1, 0, -1):
string += chr(97+size-k)
if len(string) < width:
string += '-'
print(string.center(width, '-'))
string = ''
for i in range(size-1, 0, -1):
string = ''
for j in range(0, i):
string += chr(96+size-j)
if len(string) < width:
string += '-'
for k in range(i-1, 0, -1):
string += chr(97+size-k)
if len(string) < width:
string += '-'
print(string.center(width, '-'))
if __name__ == '__main__':
n = int(input())
print_rangoli(n)