Skip to content

Instantly share code, notes, and snippets.

@anemochore
Last active January 28, 2022 13:25
Show Gist options
  • Save anemochore/41ebb2653c9e933a9403679c689ae599 to your computer and use it in GitHub Desktop.
Save anemochore/41ebb2653c9e933a9403679c689ae599 to your computer and use it in GitHub Desktop.
SPACE = 0.3 # em
[START, END] = [1, 7] # assuming positive integers
MID = round((END - START + 1)/2)
STR = ''.join(list(str(i) for i in range(START, END + 1)))
html = '<html><head><style>p {margin: 0;}</style></head><body>'
padding = 0
for i in range(START, END + 1):
html += '<p style="padding-left: ' + str(padding * SPACE) + 'em;">' + STR[padding:len(STR) - padding]
padding += (1 if i < MID else -1)
with open('result.html', 'w') as f:
f.write(html + '</html>')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment