Skip to content

Instantly share code, notes, and snippets.

@chrishoffman
Last active December 16, 2015 15:09
Show Gist options
  • Save chrishoffman/5453822 to your computer and use it in GitHub Desktop.
Save chrishoffman/5453822 to your computer and use it in GitHub Desktop.
Diamonds and stars
def draw_line(number_of_stars, width):
spaces = (width - number_of_stars) / 2
print ' ' * spaces + '*' * number_of_stars
def diamond(number):
for i in xrange(1, number, 2):
draw_line(i, number)
for i in xrange(number, 0, -2):
draw_line(i, number)
diamond(5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment