Created
May 25, 2018 18:54
-
-
Save reynoldscem/01adcdfcec00ed9daa4e15f1319da8aa to your computer and use it in GitHub Desktop.
This file contains hidden or 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
from math import ceil, floor | |
tree_section_length = 16 | |
COLS = 100 | |
ROWS = 63 | |
def gridrow(): | |
return ['_' for _ in range(COLS)] | |
def main(): | |
start_arr = [COLS // 2 - 1] | |
idx = 0 | |
current_sec_length = tree_section_length | |
grid = [gridrow() for _ in range(ROWS)] | |
for n in range(0, 5): | |
current_sec_length = tree_section_length / (2**n) | |
# print(current_sec_length) | |
# column_phase | |
for i in range(int(ceil(current_sec_length))): | |
# print(idx, start_arr) | |
# print(start_arr) | |
for entry in start_arr: | |
grid[idx][entry] = '1' | |
idx += 1 | |
# branch_phase | |
start_arr = sorted(start_arr + start_arr) | |
for i in range(int(floor(current_sec_length))): | |
#print(idx, start_arr) | |
#idx += 1 | |
offset = -1 | |
for j in range(len(start_arr)): | |
start_arr[j] = start_arr[j] + offset | |
offset *= -1 | |
# print(start_arr) | |
for entry in start_arr: | |
grid[idx][entry] = '1' | |
idx += 1 | |
grid = list(reversed(grid)) | |
for row in grid: | |
print(''.join(row)) | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment