Skip to main content
added 79 characters in body
Source Link
user100690
user100690

JavaScript, 342 299299 307 bytes

n=>[' '+'_'.repeat(e=Math.max(...(s=n.split` `).map(l=>l.length))+2),...s.map((i,l,_,x=i.padEnd(e-1))=>s[1]=>1 in s?l?s[ll>s.length-2]2?`\\ ${x}/`:`| ${x}|`:`/ ${x}\\`:`< ${x}>`),' '+'-'.repeat(e),''].join` `+[(n=' ')+"\\ ^__^"," \\ (oo)_______",` (__)${n})\\/\\`,n+` ||----w |`,n+" || ||"].join(` `+n) 

Try it onlineTry it online.

Explanation

This builds an array of strings which are joined with a newline.

What each element does

  • element 1: underscore string
  • next few elements: each line of the inputted string with the added limiters
  • next element: hyphen string
  • then, add the cow string.

-43 bytes thanks to A username

+8 bytes due to empty line bug

JavaScript, 342 299 bytes

n=>[' '+'_'.repeat(e=Math.max(...(s=n.split` `).map(l=>l.length))+2),...s.map((i,l,_,x=i.padEnd(e-1))=>s[1]?l?s[l-2]?`\\ ${x}/`:`| ${x}|`:`/ ${x}\\`:`< ${x}>`),' '+'-'.repeat(e),''].join` `+[(n=' ')+"\\ ^__^"," \\ (oo)_______",` (__)${n})\\/\\`,n+` ||----w |`,n+" || ||"].join(` `+n) 

Try it online.

Explanation

This builds an array of strings which are joined with a newline.

What each element does

  • element 1: underscore string
  • next few elements: each line of the inputted string with the added limiters
  • next element: hyphen string
  • then, add the cow string.

-43 bytes thanks to A username

JavaScript, 342 299 307 bytes

n=>[' '+'_'.repeat(e=Math.max(...(s=n.split` `).map(l=>l.length))+2),...s.map((i,l,_,x=i.padEnd(e-1))=>1 in s?l?l>s.length-2?`\\ ${x}/`:`| ${x}|`:`/ ${x}\\`:`< ${x}>`),' '+'-'.repeat(e),''].join` `+[(n=' ')+"\\ ^__^"," \\ (oo)_______",` (__)${n})\\/\\`,n+` ||----w |`,n+" || ||"].join(` `+n) 

Try it online.

Explanation

This builds an array of strings which are joined with a newline.

What each element does

  • element 1: underscore string
  • next few elements: each line of the inputted string with the added limiters
  • next element: hyphen string
  • then, add the cow string.

-43 bytes thanks to A username

+8 bytes due to empty line bug

deleted 39 characters in body
Source Link
user100690
user100690

JavaScript, 342342 299 bytes

n=>[' '+'_'.repeat(e=Math.max(...(s=n.split`\n`split` `).map(l=>l.length))+2),...s.map((i,l,_,x=i+' 'x=i.repeatpadEnd(e-2-i.length1))=>s[1]?l<1l?`/ ${x} \\`:l>s.lengths[l-22]?`\\ ${x} /`:`| ${x} |`:`<`/ ${x}\\`:`< ${x}>`),' '+'-'.repeat(e),"''].join` `+[(n=' \\')+"\\ ^__^","  \\ (oo)_______"," ` (__) ${n})\\/\\"\\`," n+` ||----w |"|`," n+" || ||"].join` join(` `+n) 

Try it onlineTry it online.

Explanation

This builds an array of strings which are joined with a newline.

What each element does

  • element 1: underscore string
  • next few elements: each line of the inputted string with the added limiters
  • next element: hyphen string
  • next few elements:then, add the cow string.

-43 bytes thanks to A username

JavaScript, 342 bytes

n=>[' '+'_'.repeat(e=Math.max(...(s=n.split`\n`).map(l=>l.length))+2),...s.map((i,l,_,x=i+' '.repeat(e-2-i.length))=>s[1]?l<1?`/ ${x} \\`:l>s.length-2?`\\ ${x} /`:`| ${x} |`:`< ${x} >`),' '+'-'.repeat(e)," \\ ^__^","  \\ (oo)_______","  (__) )\\/\\","  ||----w |","  || ||"].join` ` 

Try it online.

Explanation

This builds an array of strings which are joined with a newline.

What each element does

  • element 1: underscore string
  • next few elements: each line of the inputted string with the added limiters
  • next element: hyphen string
  • next few elements: the cow

JavaScript, 342 299 bytes

n=>[' '+'_'.repeat(e=Math.max(...(s=n.split` `).map(l=>l.length))+2),...s.map((i,l,_,x=i.padEnd(e-1))=>s[1]?l?s[l-2]?`\\ ${x}/`:`| ${x}|`:`/ ${x}\\`:`< ${x}>`),' '+'-'.repeat(e),''].join` `+[(n=' ')+"\\ ^__^"," \\ (oo)_______",` (__)${n})\\/\\`,n+` ||----w |`,n+" || ||"].join(` `+n) 

Try it online.

Explanation

This builds an array of strings which are joined with a newline.

What each element does

  • element 1: underscore string
  • next few elements: each line of the inputted string with the added limiters
  • next element: hyphen string
  • then, add the cow string.

-43 bytes thanks to A username

Source Link
user100690
user100690

JavaScript, 342 bytes

n=>[' '+'_'.repeat(e=Math.max(...(s=n.split`\n`).map(l=>l.length))+2),...s.map((i,l,_,x=i+' '.repeat(e-2-i.length))=>s[1]?l<1?`/ ${x} \\`:l>s.length-2?`\\ ${x} /`:`| ${x} |`:`< ${x} >`),' '+'-'.repeat(e)," \\ ^__^"," \\ (oo)_______"," (__) )\\/\\"," ||----w |"," || ||"].join` ` 

Try it online.

Explanation

This builds an array of strings which are joined with a newline.

What each element does

  • element 1: underscore string
  • next few elements: each line of the inputted string with the added limiters
  • next element: hyphen string
  • next few elements: the cow