#C8981. Count Distinct Words

    ID: 53023 Type: Default 1000ms 256MiB

Count Distinct Words

Count Distinct Words

You are given a single line of text. Your task is to count the number of distinct words in this text.

A word is defined as any sequence of alphanumeric characters (a-z, A-Z, 0-9). The comparison is case-insensitive, i.e. the words Hello and hello are considered the same.

For example, given the input "Hello, world! Hello, Python.", the distinct words are: hello, world, and python – so the answer is 3.

This problem will typically test your ability to work with strings and regular expressions or character analysis.

inputFormat

A single line of text which may include punctuation and varying spaces. The line can also be empty.

outputFormat

A single integer representing the number of distinct words in the input, treating words case-insensitively.## sample

Hello, world! Hello, Python.
3