Created
August 8, 2018 18:43
-
-
Save TomColBee/a9d86d97f606eae5b1026547fd58a401 to your computer and use it in GitHub Desktop.
Diamond Shaped Kata Stars
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
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