In this challenge, you will remove duplicate words from each sentence.
Examples
Hello Hello, World!
Hello, World!
Code Code! Golf Code
Code! Golf Code
Hello hello World
Hello World
Programming Golf Programming!
Programming Golf!
Specification
- Input will be a string of ASCII characters.
- A sentence is defined as anything until the end of the string, a linefeed (
\n
), or punctuation (.!?
). - A word is defined as a sequence of
A-Za-z
. - Words are case insensitive (
Hello
==heLlO
).
- Only the first occurrence of a word in a sentence is kept.
- If a word is removed, the spaces before the removed word should be removed. (e.g.
A A B
->A B
).
- As always standard loopholes are disallowed.
This is code-golf so shortest code in bytes wins!
a b a.
goes to what? \$\endgroup\$a b.
because the ` a` is removed. \$\endgroup\$a__b_b_a
, do you geta_b_a
(firstb
removed) ora__b_a
(secondb
removed)? \$\endgroup\$a__b__
because the repeatedb
is removed and the repeateda
is removed \$\endgroup\$