Skip to content

Instantly share code, notes, and snippets.

@TomColBee
Created August 8, 2018 18:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TomColBee/a9d86d97f606eae5b1026547fd58a401 to your computer and use it in GitHub Desktop.
Save TomColBee/a9d86d97f606eae5b1026547fd58a401 to your computer and use it in GitHub Desktop.
Diamond Shaped Kata Stars
def diamond(n):
orig_n = int(n)
orig_n_2 = int(n)
# first line of star
spaces = int(n-1)
print(" " * spaces + "*")
# middle section
for i in range(1,n):
spaces = int(n - 2)
middle_spaces = int((i*2)-1)
print(" " * spaces + "*" + " " * middle_spaces + "*")
n -= 1
# end section
for i in range(orig_n, 2,-1):
spaces = int(orig_n - (orig_n_2-1))
middle_spaces = int((i*2)-5)
print(" " * spaces + "*" + " " * middle_spaces + "*")
orig_n += 1
# last line of star
spaces = int(orig_n_2-1)
print(" " * spaces + "*")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment