Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
Code Golf

Return to Answer

added 492 characters in body
Source Link
l4m2
  • 32.4k
  • 2
  • 26
  • 115

JavaScript (Node.js), 43 bytes

x=>~(g=s=>~s.indexOf(x,1)||g(s+i++))(x,i=1)

Try it online!

Using range, fail 11 (expect 13, get 1)

JavaScript (Node.js) , 49 bytes

x=>~(g=s=>~s.search(x)||g(s+ ++i))(i='')+x.length

Try it online!

-4 from Arnauld

Not using the 10

JavaScript (Node.js), 49 bytes

x=>~(g=s=>~s.search(x)||g(s+ ++i))(i='')+x.length

Try it online!

-4 from Arnauld

Not using the 10

JavaScript (Node.js), 43 bytes

x=>~(g=s=>~s.indexOf(x,1)||g(s+i++))(x,i=1)

Try it online!

Using range, fail 11 (expect 13, get 1)

JavaScript (Node.js) , 49 bytes

x=>~(g=s=>~s.search(x)||g(s+ ++i))(i='')+x.length

Try it online!

-4 from Arnauld

Not using the 10

added 11 characters in body
Source Link
l4m2
  • 32.4k
  • 2
  • 26
  • 115

JavaScript (Node.js), 5749 bytes

x=>(g=s=>x=>~(k=sg=s=>~s.matchsearch(x))?k.index+x.length:g||g(s+ ++i))(i='')+x.length

Try it online! Try it online!

-4 from Arnauld

Not using the 10

JavaScript (Node.js), 57 bytes

x=>(g=s=>(k=s.match(x))?k.index+x.length:g(s+ ++i))(i='')

Try it online!

Not using the 10

JavaScript (Node.js), 49 bytes

x=>~(g=s=>~s.search(x)||g(s+ ++i))(i='')+x.length

Try it online!

-4 from Arnauld

Not using the 10

Source Link
l4m2
  • 32.4k
  • 2
  • 26
  • 115

JavaScript (Node.js), 57 bytes

x=>(g=s=>(k=s.match(x))?k.index+x.length:g(s+ ++i))(i='')

Try it online!

Not using the 10

AltStyle によって変換されたページ (->オリジナル) /