Last active
August 14, 2016 23:22
-
-
Save leotrs/40fd5fca2955d68ca5e11fa4a3c3cf04 to your computer and use it in GitHub Desktop.
This file contains 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
""" | |
https://github.com/reeddunkle/Codjo/tree/master/Problem3_Rangoli | |
""" | |
from string import ascii_lowercase | |
from itertools import chain | |
def reflect(iterable): | |
return chain(reversed(iterable), iterable[1:]) | |
def make_rangoli(alphabet=ascii_lowercase, delimiter='-', padding='-'): | |
"""Prints a Rangoli with the first length letters of alphabet.""" | |
length = len(alphabet) | |
for i in reflect(range(length, 0, -1)): | |
letters = ''.join(reflect(delimiter.join(alphabet[:i]))) | |
print('{:{}^{}}'.format(letters, padding, 4*length - 3)) | |
if __name__ == '__main__': | |
message = 'r even lived' | |
make_rangoli(message, '*', '-') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment