#C12868. Word Count Challenge

    ID: 42342 Type: Default 1000ms 256MiB

Word Count Challenge

Word Count Challenge

Given a string, count the occurrences of each unique word in a case-insensitive manner. Only alphanumeric characters are considered and punctuation should be ignored. Extra spaces (including leading and trailing) must be handled correctly.

You are not permitted to use built‐in methods for splitting the string. If the input is not a valid string, the program should raise an error (or exit with an appropriate error message in languages that do not support exceptions).

For example:

Input: Hello hello world
Output: {'hello': 2, 'world': 1}

inputFormat

A single line string provided via standard input. The string may include spaces, punctuation, and alphanumeric characters.

outputFormat

Print the word count dictionary in the Python dictionary format (with single quotes) to standard output, preserving the order of the first occurrence of each word.## sample

Hello hello world
{'hello': 2, 'world': 1}