Skip to main content
saved 10 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

JavaScript (ES8),  266  262252 bytes

s=>` _2
 13
 -2
 7\\5\\ 3^__^1^__^
 8\\10\\  (oo)\\_7\\_5
 119(__)\\ 75)${q=`\\\\/\\
 15||<>`}13||-4w6w |
 15||13|| 5||`7||`.replace(/.(>|\d+\d+)/g,(s,n)=>n^1=>n^3?s[i=0].repeat(n^2?n:wn^2||w):a.map(s=>q[j='7019'[s=>'|\\/<'[j=!i++*2|!a[i]]]+sa[i]]+s.padEnd(w)+q[-~j]+'|/\\>'[j]).join`
`,a=s.split`
`.map(w=s=>` ${w>(v=s.length+2)?0:w=v,s} `))

Try it online!Try it online!

How?

We first split the input string into lines surrounded with 2 spaces and compute the width w of the biggest line (including said spaces):

a = s.split`\n`.map(w = s => ` ${w > (v = s.length + 2) ? 0 : w = v, s} `)

We define q as:

"\/\[LF] 15||<>"
 ^^        ^ ^
 01        7 9

This string is used simultaneously as a substring of our template (except the <> part which is removed) and as a lookup string for the surrounding characters of the text bubble, using the marked positions above.

Each number n in the template string is interpreted as follows:

  • 2: repeat the preceding character w times (for the top and bottom borders of the text bubble)

  • 13: insert the text bubble:

    a.map(s =>
      q[j'|\\/<'[j = '7019'[!i++ * 2 | !a[i]]]a[i]] +
      s.padEnd(w) +
      q[-~j]'|/\\>'[j]
    )
    .join`\n`
    
  • anything else: repeat the preceding character n XOR 2 times

We actually match /.(>|\d+)/g, which means that the substring <> is interpreted as '<'.repeat('>'), resulting in an empty string.

JavaScript (ES8),  266  262 bytes

s=>` _2
 1
 -2
 7\\ 3^__^
 8\\  (oo)\\_7
 11(__)\\ 7)${q=`\\/\\
 15||<>`}-4w |
 15|| 5||`.replace(/.(>|\d+)/g,(s,n)=>n^1?s[i=0].repeat(n^2?n:w):a.map(s=>q[j='7019'[!i++*2|!a[i]]]+s.padEnd(w)+q[-~j]).join`
`,a=s.split`
`.map(w=s=>` ${w>(v=s.length+2)?0:w=v,s} `))

Try it online!

How?

We first split the input string into lines surrounded with 2 spaces and compute the width w of the biggest line (including said spaces):

a = s.split`\n`.map(w = s => ` ${w > (v = s.length + 2) ? 0 : w = v, s} `)

We define q as:

"\/\[LF] 15||<>"
 ^^        ^ ^
 01        7 9

This string is used simultaneously as a substring of our template (except the <> part which is removed) and as a lookup string for the surrounding characters of the text bubble, using the marked positions above.

Each number n in the template string is interpreted as follows:

  • 2: repeat the preceding character w times

  • 1: insert the text bubble:

    a.map(s =>
      q[j = '7019'[!i++ * 2 | !a[i]]] +
      s.padEnd(w) +
      q[-~j]
    )
    .join`\n`
    
  • anything else: repeat the preceding character n times

We actually match /.(>|\d+)/g, which means that the substring <> is interpreted as '<'.repeat('>'), resulting in an empty string.

JavaScript (ES8),  266  252 bytes

s=>` _2
 3
 -2
 5\\ 1^__^
 10\\  (oo)\\_5
 9(__)\\ 5)\\/\\
 13||-6w |
 13|| 7||`.replace(/.(\d+)/g,(s,n)=>n^3?s[i=0].repeat(n^2||w):a.map(s=>'|\\/<'[j=!i++*2|!a[i]]+s.padEnd(w)+'|/\\>'[j]).join`
`,a=s.split`
`.map(w=s=>` ${w>(v=s.length+2)?0:w=v,s} `))

Try it online!

How?

We first split the input string into lines surrounded with 2 spaces and compute the width w of the biggest line (including said spaces):

a = s.split`\n`.map(w = s => ` ${w > (v = s.length + 2) ? 0 : w = v, s} `)

Each number n in the template string is interpreted as follows:

  • 2: repeat the preceding character w times (for the top and bottom borders of the text bubble)

  • 3: insert the text bubble:

    a.map(s =>
      '|\\/<'[j = !i++ * 2 | !a[i]] +
      s.padEnd(w) +
      '|/\\>'[j]
    )
    .join`\n`
    
  • anything else: repeat the preceding character n XOR 2 times

saved 1 byte
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

JavaScript (ES8),  266  263262 bytes

s=>` _2
 1
 -2
 7\\ 3^__^
 8\\  (oo)\\_7
 11(__)\\ 7)${q=`\\/\\
 15||<>`}-4w |
 15|| 5||`.replace(/.(>|\d+)/g,(s,n)=>n^1?s[i=0].repeat(n^2?n:w):a.map(s=>q[j=i++?a[i]?7:0:a[1]?1:9]+ss=>q[j='7019'[!i++*2|!a[i]]]+s.padEnd(w)+q[j+1]+q[-~j]).join`
`,a=s.split`
`.map(w=s=>` ${w>(v=s.length+2)?0:w=v,s} `))

Try it online!Try it online!

How?

We first split the input string into lines surrounded with 2 spaces and compute the width w of the biggest line (including said spaces):

a = s.split`\n`.map(w = s => ` ${w > (v = s.length + 2) ? 0 : w = v, s} `)

We define q as:

"\/\[LF] 15||<>"
 ^^        ^ ^
 01        7 9

This string is used simultaneously as a substring of our template (except the <> part which is removed) and as a lookup string for the surrounding characters of the text bubble, using the marked positions above.

Each number n in the template string is interpreted as follows:

  • 2: repeat the preceding character w times

  • 1: insert the text bubble:

    a.map(s =>
      q[j = '7019'[!i++ ? a[i] ? 7 : 0 : a[1] ?* 12 :| 9]!a[i]]] +
      s.padEnd(w) +
      q[j + 1]q[-~j]
    )
    .join`\n`
    
  • anything else: repeat the preceding character n times

We actually match /.(>|\d+)/g, which means that the substring <> is interpreted as '<'.repeat('>'), resulting in an empty string.

JavaScript (ES8),  266  263 bytes

s=>` _2
 1
 -2
 7\\ 3^__^
 8\\  (oo)\\_7
 11(__)\\ 7)${q=`\\/\\
 15||<>`}-4w |
 15|| 5||`.replace(/.(>|\d+)/g,(s,n)=>n^1?s[i=0].repeat(n^2?n:w):a.map(s=>q[j=i++?a[i]?7:0:a[1]?1:9]+s.padEnd(w)+q[j+1]).join`
`,a=s.split`
`.map(w=s=>` ${w>(v=s.length+2)?0:w=v,s} `))

Try it online!

How?

We first split the input string into lines surrounded with 2 spaces and compute the width w of the biggest line (including said spaces):

a = s.split`\n`.map(w = s => ` ${w > (v = s.length + 2) ? 0 : w = v, s} `)

We define q as:

"\/\[LF] 15||<>"
 ^^        ^ ^
 01        7 9

This string is used simultaneously as a substring of our template (except the <> part which is removed) and as a lookup string for the surrounding characters of the text bubble, using the marked positions above.

Each number n in the template string is interpreted as follows:

  • 2: repeat the preceding character w times

  • 1: insert the text bubble:

    a.map(s =>
      q[j = i++ ? a[i] ? 7 : 0 : a[1] ? 1 : 9] +
      s.padEnd(w) +
      q[j + 1]
    )
    .join`\n`
    
  • anything else: repeat the preceding character n times

We actually match /.(>|\d+)/g, which means that the substring <> is interpreted as '<'.repeat('>'), resulting in an empty string.

JavaScript (ES8),  266  262 bytes

s=>` _2
 1
 -2
 7\\ 3^__^
 8\\  (oo)\\_7
 11(__)\\ 7)${q=`\\/\\
 15||<>`}-4w |
 15|| 5||`.replace(/.(>|\d+)/g,(s,n)=>n^1?s[i=0].repeat(n^2?n:w):a.map(s=>q[j='7019'[!i++*2|!a[i]]]+s.padEnd(w)+q[-~j]).join`
`,a=s.split`
`.map(w=s=>` ${w>(v=s.length+2)?0:w=v,s} `))

Try it online!

How?

We first split the input string into lines surrounded with 2 spaces and compute the width w of the biggest line (including said spaces):

a = s.split`\n`.map(w = s => ` ${w > (v = s.length + 2) ? 0 : w = v, s} `)

We define q as:

"\/\[LF] 15||<>"
 ^^        ^ ^
 01        7 9

This string is used simultaneously as a substring of our template (except the <> part which is removed) and as a lookup string for the surrounding characters of the text bubble, using the marked positions above.

Each number n in the template string is interpreted as follows:

  • 2: repeat the preceding character w times

  • 1: insert the text bubble:

    a.map(s =>
      q[j = '7019'[!i++ * 2 | !a[i]]] +
      s.padEnd(w) +
      q[-~j]
    )
    .join`\n`
    
  • anything else: repeat the preceding character n times

We actually match /.(>|\d+)/g, which means that the substring <> is interpreted as '<'.repeat('>'), resulting in an empty string.

added an explanation
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649

JavaScript (ES8),  266  263 bytes

  
s=>` _2
 1
 -2
 7\\ 3^__^
 8\\  (oo)\\_7
 11(__)\\ 7)${q=`\\/\\
 15||<>`}-4w |
 15|| 5||`.replace(/.(>|\d+)/g,(s,n)=>n^1?s[i=0].repeat(n^2?n:w):a.map(s=>q[j=i++?a[i]?7:0:a[1]?1:9]+s.padEnd(w)+q[j+1]).join`
`,a=s.split`
`.map(w=s=>` ${w>(v=s.length+2)?0:w=v,s} `))

Try it online!

How?

We first split the input string into lines surrounded with 2 spaces and compute the width w of the biggest line (including said spaces):

a = s.split`\n`.map(w = s => ` ${w > (v = s.length + 2) ? 0 : w = v, s} `)

We define q as:

"\/\[LF] 15||<>"
 ^^        ^ ^
 01        7 9

This string is used simultaneously as a substring of our template (except the <> part which is removed) and as a lookup string for the surrounding characters of the text bubble, using the marked positions above.

Each number n in the template string is interpreted as follows:

  • 2: repeat the preceding character w times

  • 1: insert the text bubble:

    a.map(s =>
      q[j = i++ ? a[i] ? 7 : 0 : a[1] ? 1 : 9] +
      s.padEnd(w) +
      q[j + 1]
    )
    .join`\n`
    
  • anything else: repeat the preceding character n times

We actually match /.(>|\d+)/g, which means that the substring <> is interpreted as '<'.repeat('>'), resulting in an empty string.

JavaScript (ES8),  266  263 bytes

 
s=>` _2
 1
 -2
 7\\ 3^__^
 8\\  (oo)\\_7
 11(__)\\ 7)${q=`\\/\\
 15||<>`}-4w |
 15|| 5||`.replace(/.(>|\d+)/g,(s,n)=>n^1?s[i=0].repeat(n^2?n:w):a.map(s=>q[j=i++?a[i]?7:0:a[1]?1:9]+s.padEnd(w)+q[j+1]).join`
`,a=s.split`
`.map(w=s=>` ${w>(v=s.length+2)?0:w=v,s} `))

Try it online!

JavaScript (ES8),  266  263 bytes

 
s=>` _2
 1
 -2
 7\\ 3^__^
 8\\  (oo)\\_7
 11(__)\\ 7)${q=`\\/\\
 15||<>`}-4w |
 15|| 5||`.replace(/.(>|\d+)/g,(s,n)=>n^1?s[i=0].repeat(n^2?n:w):a.map(s=>q[j=i++?a[i]?7:0:a[1]?1:9]+s.padEnd(w)+q[j+1]).join`
`,a=s.split`
`.map(w=s=>` ${w>(v=s.length+2)?0:w=v,s} `))

Try it online!

How?

We first split the input string into lines surrounded with 2 spaces and compute the width w of the biggest line (including said spaces):

a = s.split`\n`.map(w = s => ` ${w > (v = s.length + 2) ? 0 : w = v, s} `)

We define q as:

"\/\[LF] 15||<>"
 ^^        ^ ^
 01        7 9

This string is used simultaneously as a substring of our template (except the <> part which is removed) and as a lookup string for the surrounding characters of the text bubble, using the marked positions above.

Each number n in the template string is interpreted as follows:

  • 2: repeat the preceding character w times

  • 1: insert the text bubble:

    a.map(s =>
      q[j = i++ ? a[i] ? 7 : 0 : a[1] ? 1 : 9] +
      s.padEnd(w) +
      q[j + 1]
    )
    .join`\n`
    
  • anything else: repeat the preceding character n times

We actually match /.(>|\d+)/g, which means that the substring <> is interpreted as '<'.repeat('>'), resulting in an empty string.

saved 1 byte
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
saved 2 bytes
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading
Source Link
Arnauld
  • 197.6k
  • 20
  • 179
  • 649
Loading