Created
May 10, 2017 07:36
-
-
Save DennisdeBest/ea1fe29218f8109ca0cc82a31f5b7944 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): | |
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