algebraic pyramid python

Solutions on MaxInterview for algebraic pyramid python by the best coders in the world

showing results for - "algebraic pyramid python"
Vincent
02 Mar 2017
1def print_pyramid(pyramid):
2    lines = []
3    for layer in pyramid:
4        line = ""
5        for brick in layer:
6            line += str(brick)
7            line += " "
8        lines.append(line)
9    pyramid_len = max([len(layer) for layer in lines])
10    txt = ""
11    for line in lines:
12        diff = (pyramid_len - len(line)) / 2
13        txt += " " * int(diff + 0.5)
14        txt += line
15        txt += " " * int(diff - 0.5)
16        txt += "\n"
17    print(txt)
18