Натхненний цим невимогливим питанням StackOverflow .
Ідея проста; задавши String і масив Strings, видаліть будь-які екземпляри слів з масиву (ігноруючи регістр) з вхідного рядка, відмінного від першого, разом з будь-яким додатковим пробілом, який це може залишити. Слова повинні відповідати цілим словам у вхідному рядку, а не частинам слів.
наприклад, "A cat called matt sat on a mat and wore a hat A cat called matt sat on a mat and wore a hat", ["cat", "mat"]слід виводити"A cat called matt sat on a mat and wore a hat A called matt sat on a and wore a hat"
Вхідні дані
- Введення можна сприймати як String, так і масив Strings або масив Strings, де вхідний String є першим елементом. Ці параметри можуть бути в будь-якому порядку.
- Рядок введення може не сприйматися як список рядків з обмеженим пробілом.
- У рядку введення не буде провідної, кінцевої чи послідовної пробілів.
- Весь вхід буде містити символи [A-Za-z0-9] за винятком рядка введення, що включає також пробіли.
- Вхідний масив може бути порожнім або містити слова, які не є в ряді введення.
Вихідні дані
- Вихід може бути або поверненим значенням функції, або надрукованим в STDOUT
- Вихід повинен бути в тому ж випадку, що і вихідний рядок
Тестові справи
the blue frog lived in a blue house, [blue] -> the blue frog lived in a house
he liked to read but was filled with dread wherever he would tread while he read, [read] -> he liked to read but was filled with dread wherever he would tread while he
this sentence has no matches, [ten, cheese] -> this sentence has no matches
this one will also stay intact, [] -> this one will also stay intact
All the faith he had had had had no effect on the outcome of his life, [had] -> All the faith he had no effect on the outcome of his life
5 times 5 is 25, [5, 6] -> 5 times is 25
Case for different case, [case] -> Case for different
the letters in the array are in a different case, [In] -> the letters in the array are a different case
This is a test Will this be correct Both will be removed, [this,will] -> This is a test Will be correct Both be removed
Оскільки це код гольфу, виграє найменший байт!
This is a test Will this be correct Both will be removed+this will. Другі два слова правильно видалено, алеbeпісля другого він такожwillчомусь видалено .