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 Revisions

4 of 5
added 15 characters in body
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 19 bytes

Assuming that we must handle uppercase S and H too and that we must/may return the leftmost distinct "s-words"

ḣ2ŒliⱮ=Ø.
ḲçƇ)hsQḣ7

A monadic Link that accepts a list of characters and yields a list of the words.

Try it online!

How?

ḣ2ŒliⱮ=Ø. - Helper Link, valid word?: list of characters, Word; identifiers ("hs")
ḣ2 - head Word to index two - e.g. "Child" -> "Ch"
 Œl - lower-case -> X -> X = "ch"
 Ɱ - map across C in identifiers with:
 i - first (1-indexed) index of C in X -> [2,0]
 ('h' at index 2, no 's' exists)
 Ø. - [0,1]
 = - equal?
ḲçƇ)hsQḣ7 - Link get s-words: list of characters, T
Ḳ - split T at space characters -> Words
 )hs - set the right argument to "hs"
 Ƈ - filter keep those Words for which:
 ç - call the helper Link as a dyad - f(Word, "hs")
 Q - deduplicate
 ḣ7 - head to index seven
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

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