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 53 characters in body
Source Link
nimi
  • 36k
  • 4
  • 35
  • 100

Haskell, (削除) 41 (削除ここまで) 47(削除) 47 (削除ここまで) 43 bytes

f l|w<l|w@"hello"<-take 5 l,w=="hello"=w|a5l=w|a:b<-l=a:f b|1<2=l

Haskell's laziness handles the infinite input/output quit well.

Try it online! Try it online!

Edit: didn't handle finite input - fixed. Thanks @Leo for pointing out.

Edit II: @Ørjan Johansen saved 4 bytes. Thanks!

Haskell, (削除) 41 (削除ここまで) 47 bytes

f l|w<-take 5 l,w=="hello"=w|a:b<-l=a:f b|1<2=l

Haskell's laziness handles the infinite input/output quit well.

Try it online!

Edit: didn't handle finite input - fixed. Thanks @Leo for pointing out.

Haskell, (削除) 41 (削除ここまで) (削除) 47 (削除ここまで) 43 bytes

f l|w@"hello"<-take 5l=w|a:b<-l=a:f b|1<2=l

Haskell's laziness handles the infinite input/output quit well.

Try it online!

Edit: didn't handle finite input - fixed. Thanks @Leo for pointing out.

Edit II: @Ørjan Johansen saved 4 bytes. Thanks!

added 99 characters in body
Source Link
nimi
  • 36k
  • 4
  • 35
  • 100

Haskell, 41(削除) 41 (削除ここまで) 47 bytes

f l|w<-take 5 l,w=="hello"=w|a:b<-l=a:f bb|1<2=l

Haskell's laziness handles the infinite input/output quit well.

Try it online! Try it online!

Edit: didn't handle finite input - fixed. Thanks @Leo for pointing out.

Haskell, 41 bytes

f l|w<-take 5 l,w=="hello"=w|a:b<-l=a:f b

Haskell's laziness handles the infinite input/output quit well.

Try it online!

Haskell, (削除) 41 (削除ここまで) 47 bytes

f l|w<-take 5 l,w=="hello"=w|a:b<-l=a:f b|1<2=l

Haskell's laziness handles the infinite input/output quit well.

Try it online!

Edit: didn't handle finite input - fixed. Thanks @Leo for pointing out.

added 22 characters in body
Source Link
nimi
  • 36k
  • 4
  • 35
  • 100

Haskell, 41 bytes

f l|w<-take 5 l,w=="hello"=w|a:b<-l=a:f b

Haskell's laziness handles the infinite input/output quit well.

Try it online! Try it online!

Haskell, 41 bytes

f l|w<-take 5 l,w=="hello"=w|a:b<-l=a:f b

Haskell's laziness handles the infinite input/output quit well.

Try it online!

Haskell, 41 bytes

f l|w<-take 5 l,w=="hello"=w|a:b<-l=a:f b

Haskell's laziness handles the infinite input/output quit well.

Try it online!

Source Link
nimi
  • 36k
  • 4
  • 35
  • 100
Loading

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