Skip to content

Instantly share code, notes, and snippets.

@leotrs
Last active August 14, 2016 23:22
Show Gist options
  • Save leotrs/40fd5fca2955d68ca5e11fa4a3c3cf04 to your computer and use it in GitHub Desktop.
Save leotrs/40fd5fca2955d68ca5e11fa4a3c3cf04 to your computer and use it in GitHub Desktop.
"""
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