Zainspirowany tym skromnym pytaniem StackOverflow .
Pomysł jest prosty; biorąc pod uwagę Ciąg i tablicę Ciągów, usuń wszelkie wystąpienia słów w tablicy (ignorując wielkość liter) z wejściowego Ciągu innego niż pierwszy, a także wszelkie dodatkowe białe znaki, które może zostawić. Słowa muszą pasować do całych słów w ciągu wejściowym, a nie do części słów.
na przykład "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"] powinien generować"A cat called matt sat on a mat and wore a hat A called matt sat on a and wore a hat"
Wejście
- Dane wejściowe można traktować jako ciąg znaków oraz tablicę ciągów lub tablicę ciągów, w których ciąg wejściowy jest pierwszym elementem. Parametry te mogą być w dowolnej kolejności.
- Ciąg wejściowy nie może być traktowany jako lista ciągów rozdzielanych spacjami.
- Łańcuch wejściowy nie będzie zawierał spacji wiodących, końcowych ani kolejnych.
- Wszystkie dane wejściowe będą zawierać tylko znaki [A-Za-z0-9], z wyjątkiem ciągu wejściowego również ze spacjami.
- Tablica wejściowa może być pusta lub zawierać słowa spoza wejściowego ciągu znaków.
Wynik
- Dane wyjściowe mogą być albo wartością zwracaną z funkcji, albo drukowane do STDOUT
- Dane wyjściowe muszą być w tym samym przypadku, co oryginalny ciąg
Przypadki testowe
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
Ponieważ jest to kod golfowy, wygrywa najmniejsza liczba bajtów!
This is a test Will this be correct Both will be removed+this will. Drugie dwa słowa zostały poprawnie usunięte, ale z jakiegoś powodu również usunęłybepo drugimwill.