Skip to content

Instantly share code, notes, and snippets.

@Nnwww
Created June 16, 2016 11:24
Show Gist options
  • Save Nnwww/22e3ff399f0f78e8d6a1bfd9573aea7b to your computer and use it in GitHub Desktop.
Save Nnwww/22e3ff399f0f78e8d6a1bfd9573aea7b to your computer and use it in GitHub Desktop.
def padding(char, num, padc='_'):
padcs = padc * num
return padcs + char + padcs
def draw(stack, n, i):
if n < 1:
return stack
num = 2 ** (n - 1)
char = str(num)
pad_num = 2 ** i - 1
unit = padding(char, pad_num)
line = '_'.join([unit] * num)
stack.append(line)
return draw(stack, n-1, i+1)
for x in reversed(draw([], 4, 0)):
print(x)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment