Skip to main content
2 of 2
Add MathJax trace in a Markup comment.
humn
  • 22k
  • 4
  • 60
  • 161

Partial

We could build upon the reflection solution by doing something like:

 \require{begingroup}\begingroup
 \def\C#1#2|{\D#1|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\T}
 \def\stars#1{\G|#1|}
 \def\G#1|#2|{\R :#2|\R|\S}
 \def\R#1:#2#3|#4{#4 #2#1:#3|#4}
 \def\S|#1:#2\S{\C#1|}
 \def\T#1{terminate}
 \stars{123}
 \endgroup

For \stars{123}:

$$\require{begingroup}\begingroup\def\C#1#2|{\D#1|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\M#2|\T}\def\stars#1{\G|#1|}\def\G#1|#2|{\R :#2|\R|\S}\def\R#1:#2#3|#4{#4 #2#1:#3|#4}\def\S|#1:#2\S{\C#1|}\def\T#1{terminate}\stars{123}\endgroup$$

But I'm not quite sure how to:

  1. recurse to \C with \M by implementing \T correctly (like \S); or
  2. make \D3| produce *\D2| and similar for all the digits such that \D| and \D0| yield empty strings.
Jonathan Allan
  • 21.3k
  • 2
  • 59
  • 109