Skip to main content
2 of 3
added 1359 characters in body
naffetS
  • 12.8k
  • 2
  • 20
  • 53

Knight, 124 bytes

;=o"";=pP;=d 0;=i~1;W<=i+1iLp;=cGp i 1I>c"9";=d-d-1*2<c"]"=o+o cI<"/"c;=n c;W&<=tGp+1i 1"["<"/"t;=i+1i=n+n t=o+o*d n=o+o cOo

Try it online!

Nice, big ole fat Knight program. Parses it as a string lol

Ungolfed and commented:

; = o ""                                         # o = ""
; = p PROMPT                                     # p = input()
; = d 0                                          # d = 0
; = i ~1                                         # i = -1
; W < = i + 1 i LENGTH p                         # while (i = i + 1) < len(p):
  ; = c GET p i 1                                #   c = p[i]
  : IF > c "9"                                   #   if c > "9":
    ; = d - d - 1 * 2 < c "]"                    #     d = d - (1 - 2 * (c < "["))
    : = o + o c                                  #     o = o + c
  # ELSE                                         #   else:
    : IF < "/" c                                 #     if "/" < c:
      ; = n c                                    #       n = c
      ; WHILE & < = t GET p + 1 i 1 "[" < "/" t  #       while ((t = p[i + 1]) < "[") and ("/" < t):
        ; = i + 1 i                              #         i = i + 1
        : = n + n t                              #         n = n + t
      : = o + o * d n                            #       o = o + d * n
    # ELSE                                       #     else:
      : = o + o c                                #       o = o + c
: OUTPUT o                                       # print(o)
naffetS
  • 12.8k
  • 2
  • 20
  • 53