Python, 650 612 594594 574 characters
n='\n'
S='_a/cEeG\F i\n'I\n'
A=dict(zip(S,('iii''III',' ','__/',' c'G','E'\ ','e__''F__',' ','iii''III','')))
B=dict(zip(S,('iii''III',' ','E'\ ',' ae'aF','/a ',' c'G',' ','iii''III','')))
C=dict(zip(S,('___','aaa','/ ','cii''GII','iiE''II\\',' e'F',' ','iii''III','')))
def T(s):
a=b=c=d=r=''a=b=c=d=r=u''
for k in s:
a+=A[k];b+=B[k];c+=C[k]
if k=='i'k=='I':a=a[:-3]+('iiE'if'a'II\\'if'a '==d[1:3]else'cii'if'3]else'GII'if' a'==d[:2]else 3*k)
d=d[3:]
if k==n:d=c.replace('____','__/e'F').replace('aaaa','aa ').replace('/ a','/a ').replace('a e'F',' ae'aF');r+=a+n+b+n+d+n;a=b=c=''
return r
import string
print T(T(T('__\nEc\n''__\n\G\n'))).translate(string.maketrans('acEei'{97:95,r'_/\\ ')71:47,73:32,70:92})
This works by expanding the triangle by a factor of 3 each time. To do that, we need to keep track of whether each symbol is a left or right boundary (e.g. how /
is expanded depends on which side of the /
is the inside). We use different symbols for the two possible cases, as follows:
_: _, outside on the top
a: _, outside on the bottom
/: /, outside on the left
cG: /, outside on the right
E\: \, outside on the left
eF: \, outside on the right
<space>: inside
iI: outside
The d
variable handles the special case where the expansion of an a
needs to extend into the 3x3 in the next row.