Skip to main content
use unicode translate
Source Link
Keith Randall
  • 21k
  • 2
  • 44
  • 105

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.

Python, 650 612 594 characters

n='\n'
S='_a/cEe i\n'
A=dict(zip(S,('iii','   ','__/','  c','E  ','e__','   ','iii','')))
B=dict(zip(S,('iii','   ','E  ',' ae','/a ','  c','   ','iii','')))
C=dict(zip(S,('___','aaa','/  ','cii','iiE','  e','   ','iii','')))
def T(s):
 a=b=c=d=r=''
 for k in s:
    a+=A[k];b+=B[k];c+=C[k]
    if k=='i':a=a[:-3]+('iiE'if'a '==d[1:3]else'cii'if' a'==d[:2]else 3*k)
    d=d[3:]
    if k==n:d=c.replace('____','__/e').replace('aaaa','aa  ').replace('/  a','/a  ').replace('a  e','  ae');r+=a+n+b+n+d+n;a=b=c=''
 return r
import string
print T(T(T('__\nEc\n'))).translate(string.maketrans('acEei',r'_/\\ '))

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
c: /, outside on the right
E: \, outside on the left
e: \, outside on the right
<space>: inside
i: outside

The d variable handles the special case where the expansion of an a needs to extend into the 3x3 in the next row.

Python, 650 612 594 574 characters

n='\n'
S='_a/G\F I\n'
A=dict(zip(S,('III','   ','__/','  G','\  ','F__','   ','III','')))
B=dict(zip(S,('III','   ','\  ',' aF','/a ','  G','   ','III','')))
C=dict(zip(S,('___','aaa','/  ','GII','II\\','  F','   ','III','')))
def T(s):
 a=b=c=d=r=u''
 for k in s:
    a+=A[k];b+=B[k];c+=C[k]
    if k=='I':a=a[:-3]+('II\\'if'a '==d[1:3]else'GII'if' a'==d[:2]else 3*k)
    d=d[3:]
    if k==n:d=c.replace('____','__/F').replace('aaaa','aa  ').replace('/  a','/a  ').replace('a  F','  aF');r+=a+n+b+n+d+n;a=b=c=''
 return r
print T(T(T('__\n\G\n'))).translate({97:95,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
G: /, outside on the right
\: \, outside on the left
F: \, outside on the right
<space>: inside
I: outside

The d variable handles the special case where the expansion of an a needs to extend into the 3x3 in the next row.

used dictionaries instead of lots of if statements
Source Link
Keith Randall
  • 21k
  • 2
  • 44
  • 105

Python, 650 612612 594 characters

n='\n'
defS='_a/cEe T(s):i\n'
A=dict(zip(S,('iii',' a=b=c=d=r=''
 for k','__/',' in s:
c','E  ','e__','  if k=='_':a+='iii';b+='iii';c+=3*k','iii','')))
    if k=='a':a+='  B=dict(zip(S,('iii',' ';b+='  ','E ';c+=3*k
 ',' ae','/a ',' if k=='/c',':a+='__/';b+='E  ';c+='/  ','iii','')))
 C=dict(zip(S,('___','aaa','/  ','cii','iiE',' if k=='c':a+='e','  c';b+=' ae';c+='cii'','iii','')))
    ifdef k=='E'T(s):a+='E  ';b+='/a ';c+='iiE'
 a=b=c=d=r=''
 for k ifin k=='e's:a+='e__';b+='  c';c+='  e'
    if k==' ':a+=3*k;b+=3*k;c+=3*ka+=A[k];b+=B[k];c+=C[k]
    if k=='i':a+='iiE'if'aa=a[:-3]+('iiE'if'a '==d[1:3]else'cii'if' a'==d[:2]else 3*k;b+=3*k;c+=3*k3*k)
    d=d[3:]
    if k==n:d=c.replace('____','__/e').replace('aaaa','aa  ').replace('/  a','/a  ').replace('a  e','  ae');r+=a+n+b+n+d+n;a=b=c=''
 return r
import string
print T(T(T('__\nEc\n'))).translate(string.maketrans('acEei',r'_/\\ '))

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
c: /, outside on the right
E: \, outside on the left
e: \, outside on the right
<space>: inside
i: outside

The d variable handles the special case where the expansion of an a needs to extend into the 3x3 in the next row.

Python, 650 612 characters

n='\n'
def T(s):
 a=b=c=d=r=''
 for k in s:
    if k=='_':a+='iii';b+='iii';c+=3*k
    if k=='a':a+='   ';b+='   ';c+=3*k
    if k=='/':a+='__/';b+='E  ';c+='/  '
    if k=='c':a+='  c';b+=' ae';c+='cii'
    if k=='E':a+='E  ';b+='/a ';c+='iiE'
    if k=='e':a+='e__';b+='  c';c+='  e'
    if k==' ':a+=3*k;b+=3*k;c+=3*k
    if k=='i':a+='iiE'if'a '==d[1:3]else'cii'if' a'==d[:2]else 3*k;b+=3*k;c+=3*k
    d=d[3:]
    if k==n:d=c.replace('____','__/e').replace('aaaa','aa  ').replace('/  a','/a  ').replace('a  e','  ae');r+=a+n+b+n+d+n;a=b=c=''
 return r
import string
print T(T(T('__\nEc\n'))).translate(string.maketrans('acEei',r'_/\\ '))

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
c: /, outside on the right
E: \, outside on the left
e: \, outside on the right
<space>: inside
i: outside

The d variable handles the special case where the expansion of an a needs to extend into the 3x3 in the next row.

Python, 650 612 594 characters

n='\n'
S='_a/cEe i\n'
A=dict(zip(S,('iii','   ','__/','  c','E  ','e__','   ','iii','')))
B=dict(zip(S,('iii','   ','E  ',' ae','/a ','  c','   ','iii','')))
C=dict(zip(S,('___','aaa','/  ','cii','iiE','  e','   ','iii','')))
def T(s):
 a=b=c=d=r=''
 for k in s:
    a+=A[k];b+=B[k];c+=C[k]
    if k=='i':a=a[:-3]+('iiE'if'a '==d[1:3]else'cii'if' a'==d[:2]else 3*k)
    d=d[3:]
    if k==n:d=c.replace('____','__/e').replace('aaaa','aa  ').replace('/  a','/a  ').replace('a  e','  ae');r+=a+n+b+n+d+n;a=b=c=''
 return r
import string
print T(T(T('__\nEc\n'))).translate(string.maketrans('acEei',r'_/\\ '))

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
c: /, outside on the right
E: \, outside on the left
e: \, outside on the right
<space>: inside
i: outside

The d variable handles the special case where the expansion of an a needs to extend into the 3x3 in the next row.

Used d variable instead of QR, used translate to fix string at the end, use tabs for inner loop
Source Link
Keith Randall
  • 21k
  • 2
  • 44
  • 105

Python, 650650 612 characters

n='\n'
def T(m,s):
 a=b=c=r=''a=b=c=d=r=''
 for k in s:
  if k==n:r+=a+n+b+n+c+n;a=b=c=''   
  if k=='A'k=='_':a+='iii';b+='iii';c+=3*k
    if k=='a':a+='III';b+='III';c+=3*ka+='   ';b+='   ';c+=3*k
    if k=='C'k=='/':a+='AAC';b+='EII';c+='CII'a+='__/';b+='E  ';c+='/  '
    if k=='c':a+='IIc';b+='Iae';c+='cii'a+='  c';b+=' ae';c+='cii'
    if k=='E':a+='EII';b+='CaI';c+='iiE'a+='E  ';b+='/a ';c+='iiE'
    if k=='e':a+='eAA';b+='IIc';c+='IIe'a+='e__';b+='  c';c+='  e'
    if kk==' in'Ii'':a+=3*k;b+=3*k;c+=3*k
 r=r   if k=='i':a+='iiE'if'a '==d[1:3]else'cii'if' a'==d[:2]else 3*k;b+=3*k;c+=3*k
    d=d[3:]
    if k==n:d=c.replace('AAAA''____','AACe''__/e').replace('aaaa','aaQR').replace('CIIa','CaQR''aa  ').replace('aIIe','QRae')
'/ while 1:
a','/a  i=r').findreplace('QR')
 'a if i<0:break
e','  r=r[:i]+'II'+r[i+2:i+m]+'Ec'+r[i+m+2:]ae');r+=a+n+b+n+d+n;a=b=c=''
 return r
print ''.join(map(lambdaimport x:{'A':'_','C':'/','E':'\\','\n':'\n','I':'string
print '}[x],T(55,T(19,T(7,'AA\nEc\n''__\nEc\n'))).uppertranslate()string.maketrans('acEei',r'_/\\ '))

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:

A_: _, outside on the top
a: _, outside on the bottom
C/: /, outside on the left
c: /, outside on the right
E: \, outside on the left
e: \, outside on the right
I<space>: inside
i: outside

The QRd and the while loop handlevariable handles the special case where the expansion of somean a's needs to extend into the 3x3 in the next row.

Python, 650 characters

n='\n'
def T(m,s):
 a=b=c=r=''
 for k in s:
  if k==n:r+=a+n+b+n+c+n;a=b=c=''   
  if k=='A':a+='iii';b+='iii';c+=3*k
  if k=='a':a+='III';b+='III';c+=3*k
  if k=='C':a+='AAC';b+='EII';c+='CII'
  if k=='c':a+='IIc';b+='Iae';c+='cii'
  if k=='E':a+='EII';b+='CaI';c+='iiE'
  if k=='e':a+='eAA';b+='IIc';c+='IIe'
  if k in'Ii':a+=3*k;b+=3*k;c+=3*k
 r=r.replace('AAAA','AACe').replace('aaaa','aaQR').replace('CIIa','CaQR').replace('aIIe','QRae')
 while 1:
  i=r.find('QR')
  if i<0:break
  r=r[:i]+'II'+r[i+2:i+m]+'Ec'+r[i+m+2:]
 return r
print ''.join(map(lambda x:{'A':'_','C':'/','E':'\\','\n':'\n','I':' '}[x],T(55,T(19,T(7,'AA\nEc\n'))).upper()))

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:

A: _, outside on the top
a: _, outside on the bottom
C: /, outside on the left
c: /, outside on the right
E: \, outside on the left
e: \, outside on the right
I: inside
i: outside

QR and the while loop handle the special case where the expansion of some a's needs to extend into the 3x3 in the next row.

Python, 650 612 characters

n='\n'
def T(s):
 a=b=c=d=r=''
 for k in s:
    if k=='_':a+='iii';b+='iii';c+=3*k
    if k=='a':a+='   ';b+='   ';c+=3*k
    if k=='/':a+='__/';b+='E  ';c+='/  '
    if k=='c':a+='  c';b+=' ae';c+='cii'
    if k=='E':a+='E  ';b+='/a ';c+='iiE'
    if k=='e':a+='e__';b+='  c';c+='  e'
    if k==' ':a+=3*k;b+=3*k;c+=3*k
    if k=='i':a+='iiE'if'a '==d[1:3]else'cii'if' a'==d[:2]else 3*k;b+=3*k;c+=3*k
    d=d[3:]
    if k==n:d=c.replace('____','__/e').replace('aaaa','aa  ').replace('/  a','/a  ').replace('a  e','  ae');r+=a+n+b+n+d+n;a=b=c=''
 return r
import string
print T(T(T('__\nEc\n'))).translate(string.maketrans('acEei',r'_/\\ '))

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
c: /, outside on the right
E: \, outside on the left
e: \, outside on the right
<space>: inside
i: outside

The d variable handles the special case where the expansion of an a needs to extend into the 3x3 in the next row.

Source Link
Keith Randall
  • 21k
  • 2
  • 44
  • 105
Loading