Skip to content

Instantly share code, notes, and snippets.

@nuriyevn
Created April 30, 2021 13:23
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save nuriyevn/094a9ab4d03c0a625d2debc1d5ccb81e to your computer and use it in GitHub Desktop.
Save nuriyevn/094a9ab4d03c0a625d2debc1d5ccb81e to your computer and use it in GitHub Desktop.
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