Jelly, 24 bytes
Assuming that we must handle uppercase S and H too and that we must/may return the leftmost distinct "s-words"
ḣ2ŒliⱮ=Ø.
ḲQçƇ)hsḣJf7ḢƊ$
A monadic Link that accepts a list of characters and yields a list of the words.
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?
ḲQçƇ)hsḣJf7ḢƊ$ - Link get s-words: list of characters, T
Ḳ - split T at space characters -> Words
Q - deduplicate
)hs - set the right argument to "hs"
Ƈ - filter keep those Words for which:
ç - call the helper Link as a dyad - f(Word, "hs")
$ - last two links as a monad - f(ValidWords):
Ɗ - last three links as a monad - g(ValidWords):
J - range of length -> [1,2,...,number of valid words]
7 - seven
f - filter-keep -> [7] or [] if less than seven valid words
Ḣ - head -> 7 or 0
ḣ - head of ValidWords to that index
Jonathan Allan
- 115.4k
- 8
- 68
- 293