-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathtriangle.py
More file actions
35 lines (33 loc) · 1.32 KB
/
triangle.py
File metadata and controls
35 lines (33 loc) · 1.32 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#!/usr/bin/env python
print "\n".join(x.rstrip() for x in (lambda y: y(y,3,3))\
(lambda x,n,w: ["%s/%s\\%s"%(" "*j, " "*(2*i)," "*j)\
for (i,j) in zip(xrange(0,w),xrange(w-1,0,-1))]+\
["%s"%("-"*w*2)] if n == 0 else ["%s%s%s"%(" "*(w*2**\
(n-1)), l, " "*(w*2**(n-1))) for l in x(x,n-1,w)]+\
["%s%s"%(l,l) for l in x(x,n-1,w)]))
"""
/\
/ \
------
/\ /\
/ \ / \
------------
/\ /\
/ \ / \
------ ------
/\ /\ /\ /\
/ \ / \ / \ / \
------------------------
/\ /\
/ \ / \
------ ------
/\ /\ /\ /\
/ \ / \ / \ / \
------------ ------------
/\ /\ /\ /\
/ \ / \ / \ / \
------ ------ ------ ------
/\ /\ /\ /\ /\ /\ /\ /\
/ \ / \ / \ / \ / \ / \ / \ / \
------------------------------------------------
"""