Created
June 16, 2016 11:24
-
-
Save Nnwww/22e3ff399f0f78e8d6a1bfd9573aea7b to your computer and use it in GitHub Desktop.
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 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