Group Abstract Group Abstract

Message Boards Message Boards

[GOLF] Compact WL for lengthy TeX fractal Sierpinski Triangle

POSTED BY: Vitaliy Kaurov
5 Replies

Well, it really wasn't meant for golf originally ... if we're going to do that, I propose ...

51 characters

Last@SubstitutionSystem[{"x"->"{x}_{x}^{x}"},"x",5]

48 characters

Nest[StringReplace[#,"x"->"{x}^{x}_{x}"]&,"x",5]

45 characters

Nest[StringReplace["x"->"{x}^{x}_{x}"],"x",5]

P.S. It's a pity that TeXForm does not support Subsuperscript.

POSTED BY: Szabolcs Horvát

58 characters

I change a bit TeX code, but it still produces the properly rendered fractal Sierpinski Triangle. I built a bit bigger one for fun.

s = ToString;Nest["{"<>s[#]<>"_"<>s[#]<>"^"<>s[#]<>"}"&,x,6]
POSTED BY: Vitaliy Kaurov

40 characters

Nest["{"<>#<>"_"<>#<>"^"<>#<>"}"&,"x",5]

Didn't know about SubstitutionSystem!

POSTED BY: Sander Huisman

I posed this question on Code Golf at stackexchange. Feel free to respond there if you are into it, no Wolfram Language answers yet ;-) Seems to be popular. Answer in Jelly is just 12 bytes ;-)

POSTED BY: Vitaliy Kaurov

40 characters

Reformulating {}-bracketing in last Szabolcs solution cuts 5 characters from it:

Nest[StringReplace["x"->"{x^x_x}"],"x",5]
POSTED BY: Vitaliy Kaurov
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard