Skip to main content
We’ve updated our Terms of Service. A new AI Addendum clarifies how Stack Overflow utilizes AI interactions.
added 52 characters in body
Source Link
Wheat Wizard
  • 102.8k
  • 23
  • 299
  • 697

Haskell, 6666 64 bytes

(a:x)!y|(s,_:_t)<-span(/=a)y=x!([e|e<-a:s++a:y)|1>0=x!(as,t>[]]++a:y)
_!y=reverse y

Attempt This Online!Attempt This Online!

I'm a bit rusty with the Haskell golf.

Haskell, 66 bytes

(a:x)!y|(s,_:_)<-span(/=a)y=x!(a:s++a:y)|1>0=x!(a:y)
_!y=reverse y

Attempt This Online!

Haskell, 66 64 bytes

(a:x)!y|(s,t)<-span(/=a)y=x!([e|e<-a:s,t>[]]++a:y)
_!y=reverse y

Attempt This Online!

I'm a bit rusty with the Haskell golf.

Source Link
Wheat Wizard
  • 102.8k
  • 23
  • 299
  • 697

Haskell, 66 bytes

(a:x)!y|(s,_:_)<-span(/=a)y=x!(a:s++a:y)|1>0=x!(a:y)
_!y=reverse y

Attempt This Online!