You are given an English text. Count the number of unique words used in the text (case insensitive, punctuation ignored).
You may assume the text is well-formed:
- A word consists of a nonzero number of uppercase or lowercase English letters.
- A punctuation mark is one of
,.!?;:
. - Words are separated by a single space or newline.
- A sentence consists of a nonzero number of words, where the last word is immediately followed by a punctuation mark.
- The text consists of a nonzero number of sentences separated by a single space or newline.
- Each line does not contain leading/trailing spaces.
Input
The input is an English text (at most $5000$ characters). The number of lines won't be specified.
Output
Output the number of unique words used.
Sample Test Cases
Input | Output | |
---|---|---|
To be, or not to be, that is the question: Whether tis nobler in the mind to suffer The slings and arrows of outrageous fortune, Or to take arms against a sea of troubles And by opposing end them. |
30 | |
The unique words are: "to", "whether", "them", "end", "is", "nobler", "a", "against", "of", "troubles", "arrows", "take", "fortune", "the", "outrageous", "and", "suffer", "question", "sea", "not", "that", "in", "by", "opposing", "be", "or", "mind", "slings", "tis", and "arms". | ||
A, a. A, a. Aa, aA. AAA! A; A: a, a, aaaaa? |
4 | |
The unique words are: "aaa", "aa", "a", and "aaaaa". Note that the capitalisation need not to be sentence case. |
Scoring: Per Subtask
Authored by s16f22 and s17r28
Appeared in 2023 Mini Contest 4