Skip to main content
deleted 223 characters in body
Source Link
naffetS
  • 12.8k
  • 2
  • 20
  • 53

Knight, 124124 118 bytes

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

Try it online!Try it online!

; = o ""                                      p + + #= o = ""
; = p PROMPT                 i = d 0 PROMPT                # p = input()
;o = d 0                                       "") + (i #= d = 0
; = i ~1                                         # i) =+ -1input()
; W < = i + 1 i LENGTH p                         # while (i = i + 1) < len(p):
  ; = n = c GET p i 1                              #  # n = 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)

-6 bytes thanks to Adam.

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!

; = 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)

Knight, 124 118 bytes

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

Try it online!

; = p + + = o "" = i = d 0 PROMPT                # p = (o = "") + (i = d = 0) + input()
; W < = i + 1 i LENGTH p                         # while (i = i + 1) < len(p):
  ; = n = c GET p i 1                            #   n = 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:
      ; 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)

-6 bytes thanks to Adam.

added 1359 characters in body
Source Link
naffetS
  • 12.8k
  • 2
  • 20
  • 53

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)

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)
Source Link
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