Skip to main content
Saved 10B
Source Link
Luke
  • 4.8k
  • 16
  • 23

#JavaScript (ES6), 124124 114 bytes Thanks to Neil for saving a few bytes

a=>eval("for(c=0,d=a;(A=$=>[A=$=>Math.min([...'cowbel'].map(_=>($.split(_).length-1)>>(_=='l')).sort(($,_)=>$-_)[0])(a)==A(d+=a[c++]););d")

Since this is quite different from the already existing JavaScript answer, and I put quite some time into this, I decided to create an answer myself.

##Usage

f=a=>eval("for(c=0,d=a;(A=$=>[A=$=>Math.min([...'cowbel'].map(_=>($.split(_).length-1)>>(_=='l')).sort(($,_)=>$-_)[0])(a)==A(d+=a[c++]););d")
f("cowbell")

###Output

"cowbellcowbell"

#JavaScript (ES6), 124 bytes

a=>eval("for(c=0,d=a;(A=$=>[...'cowbel'].map(_=>($.split(_).length-1)>>(_=='l')).sort(($,_)=>$-_)[0])(a)==A(d+=a[c++]););d")

Since this is quite different from the already existing JavaScript answer, and I put quite some time into this, I decided to create an answer myself.

##Usage

f=a=>eval("for(c=0,d=a;(A=$=>[...'cowbel'].map(_=>($.split(_).length-1)>>(_=='l')).sort(($,_)=>$-_)[0])(a)==A(d+=a[c++]););d")
f("cowbell")

###Output

"cowbellcowbell"

#JavaScript (ES6), 124 114 bytes Thanks to Neil for saving a few bytes

a=>eval("for(c=0,d=a;(A=$=>Math.min([...'cowbel'].map(_=>($.split(_).length-1)>>(_=='l'))))(a)==A(d+=a[c++]););d")

Since this is quite different from the already existing JavaScript answer, and I put quite some time into this, I decided to create an answer myself.

##Usage

f=a=>eval("for(c=0,d=a;(A=$=>Math.min([...'cowbel'].map(_=>($.split(_).length-1)>>(_=='l'))))(a)==A(d+=a[c++]););d")
f("cowbell")

###Output

"cowbellcowbell"
Source Link
Luke
  • 4.8k
  • 16
  • 23

#JavaScript (ES6), 124 bytes

a=>eval("for(c=0,d=a;(A=$=>[...'cowbel'].map(_=>($.split(_).length-1)>>(_=='l')).sort(($,_)=>$-_)[0])(a)==A(d+=a[c++]););d")

Since this is quite different from the already existing JavaScript answer, and I put quite some time into this, I decided to create an answer myself.

##Usage

f=a=>eval("for(c=0,d=a;(A=$=>[...'cowbel'].map(_=>($.split(_).length-1)>>(_=='l')).sort(($,_)=>$-_)[0])(a)==A(d+=a[c++]););d")
f("cowbell")

###Output

"cowbellcowbell"