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

Post Undeleted by Jonathan Allan
added 430 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293

Jelly, 1924 bytes

ḣ2ŒliⱮ=Ø.
ḲçƇ)hsQḣ7ḲQçƇ)hsḣJf7ḢƊ$

Try it online! Try it online!

ḣ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Ḳ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")
 Q $ - deduplicatelast two links as a monad - f(ValidWords):
 ḣ7 Ɗ - 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 indexthat sevenindex

Jelly, 19 bytes

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

Try it online!

ḣ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

Jelly, 24 bytes

ḣ2ŒliⱮ=Ø.
ḲQçƇ)hsḣJf7ḢƊ$

Try it online!

ḣ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
Post Deleted by Jonathan Allan
added 15 characters in body
Source Link
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

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!

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
added 15 characters in body
Source Link
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"

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

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

Try it online! Try it online!

Jelly, 19 bytes

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

Œlḣ2nTS=2
ḲçƇ)shQḣ7

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

Try it online!

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!

Post Undeleted by Jonathan Allan
added 21 characters in body
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading
Post Deleted by Jonathan Allan
Source Link
Jonathan Allan
  • 115.4k
  • 8
  • 68
  • 293
Loading

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