Created
April 30, 2021 13:23
-
-
Save nuriyevn/094a9ab4d03c0a625d2debc1d5ccb81e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def print_rangoli(size): | |
central = '' | |
for i in range(size-1, 0, -1): | |
central = central + chr(int(ord('a') + i)) + '-' | |
central = central + chr(int(ord('a') + 0)) + central[::-1] | |
width = len(central) | |
p = '' | |
for j in range(size-1, -1, -1): | |
s = '' | |
for i in range(size-1, j, -1): | |
s = s + chr(int(ord('a') + i)) + '-' | |
line = s + chr(int(ord('a') + j)) + s[::-1] | |
line = line.center(width, '-') | |
if j != 0: | |
p = p + line + '\n' | |
print (p + central + p[::-1]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment