Skip to content

Instantly share code, notes, and snippets.

@DennisdeBest
Created May 10, 2017 07:36
Show Gist options
  • Save DennisdeBest/ea1fe29218f8109ca0cc82a31f5b7944 to your computer and use it in GitHub Desktop.
Save DennisdeBest/ea1fe29218f8109ca0cc82a31f5b7944 to your computer and use it in GitHub Desktop.
def print_rangoli(size):
lineWidth = 3 + (4*(size-1)) - 2
chars = []
for i in range(0, size):
chars.append(chr(96+size-i))
counter = 0
s = ""
sarr = []
for val in chars:
if counter == 0 :
S = val.center(lineWidth, "-")
sarr.append(S)
print(S)
counter += 1
else :
s = val
for i in range (counter, 0, -1):
s = chars[i-1] + "-" + s + "-" + chars[i-1]
S = s.center(lineWidth, "-")
sarr.append(S)
print (S)
counter += 1
sarr.pop()
for val in reversed(sarr):
print(val)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment