Skip to content

Instantly share code, notes, and snippets.

@tebriel
Created April 12, 2015 03:18
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 tebriel/a5af3361f1d302f43ac8 to your computer and use it in GitHub Desktop.
Save tebriel/a5af3361f1d302f43ac8 to your computer and use it in GitHub Desktop.
Code Golf Diamond
#!/usr/bin/env python3
output = ["%s%s" % (" "*(9-i), "".join(str(num) for num in list(range(1, i+1)) + list(range(1, i+1))[-2::-1])) for i in range(1, 10)]
print("\n".join(output + output[-2::-1]))
cmoultrie@Sauron ~/Desktop> ./diamond.py
1
121
12321
1234321
123454321
12345654321
1234567654321
123456787654321
12345678987654321
123456787654321
1234567654321
12345654321
123454321
1234321
12321
121
1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment