It's Nowruz and you want to set up a Haft-Sin table by words. This means finding seven words that start with letter s.
The Challenge
Write a program which its input is a list of words separated by space, and output at most first 7 words which starts by letter s. If the s is before letter h it doesn't count because it would not pronounce /s/.
Input
An arbitrary length string containing words separated by space.
Words must not contain anything other than letters (uppercase or lowercase) and numbers and _
.
These inputs are valid:
hello Puzzle code_golf 12
Start say_hello separating_by_space_is_right
I am a valid word list
And these inputs are invalid:
code-golf, #invalid_word, separating_by_comma_is_wrong
I'm an invalid word list
Output
The first 7 words which starts by letter S-s and not followed by letter H-h, in every acceptable way (comma separated, space separated, new-line etc) and in any order.
- If two words are duplicate don't count them twice. Every single word is count once.
- If the input contains less that 7 word starting with s output nothing. Don't output the words.
- The output must contain the exact word which is in the input. So if the input contains
SuPER
, output should beSuPER
and notSUPER
orsuper
or any other form of lower and upper case. - Words pronunciation matter. The word
Speed
andSPEED
both count the same. You may want to lowercase all the input and unique the words and then check for words.
test-cases
input:
speed speed new car book seven sad sum power fun super sister silver silly start
output:
speed seven sad sum super sister silver
input:
speed SpEEd new book seven sad sum power fun super sister silver silly start
output:
speed seven sad sum super sister silver
input:
sheep speed new car book seven sad sum power fun super sister silver silly start
output:
speed seven sad sum super sister silver
input:
first second third
output:
Edited
This was my first question and I missed many special cases. I try to clarify them.
s
or must we handle uppercaseS
too? What about theh
/H
? \$\endgroup\$Super
if its at the start? and should we excludesHould
? \$\endgroup\$