Skip to content

Instantly share code, notes, and snippets.

@likewinter
Last active May 6, 2020 14:45
Show Gist options
  • Save likewinter/7a7e49012235e81765fc569215389367 to your computer and use it in GitHub Desktop.
Save likewinter/7a7e49012235e81765fc569215389367 to your computer and use it in GitHub Desktop.
count = 9
for i in range(count * 2 - 1):
line = ''
maxNum = i + 1 if i < count else count * 2 - i - 1
for c in range(1, maxNum * 2): line += str(c) if c < maxNum else str(maxNum * 2 - c)
print((count - maxNum) * ' ' + line)
@likewinter
Copy link
Author

Animated version from 2 to 9

import time

for count in range(2, 10):
	print(chr(27) + "[2J")
	for i in range(count * 2 - 1):
		line = ''
		maxNum = i + 1 if i < count else count * 2 - i - 1
		for c in range(1, maxNum * 2): line += str(c) if c < maxNum else str(maxNum * 2 - c)
		print((count - maxNum) * ' ' + line)
	time.sleep(.1)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment