#C7925. Letter Frequency
Letter Frequency
Letter Frequency
You are given a text input and you need to compute the frequency of each alphabet letter in that text. Only letters (a-z or A-Z) are considered; other characters must be ignored. Letter case is not significant (i.e., 'A' and 'a' should be counted as the same letter).
The result should be output as a JSON object with keys sorted in alphabetical order. For example, if the input is "Hello, World!", the correct output is:
{"d":1,"e":1,"h":1,"l":3,"o":2,"r":1,"w":1}
In mathematical terms, if we denote the frequency dictionary as (result = { key: count, \ldots }), then each key is a letter in lowercase and count is the number of its appearances in the input.
inputFormat
The input is provided via standard input (stdin) as a single string (which may contain spaces and punctuation) possibly spanning multiple lines.
outputFormat
Output a single line containing a JSON object. The object represents the frequency of each alphabet letter found in the text, with keys sorted in alphabetical order. There should be no extra spaces in the JSON output.## sample
abcdefghijklmnopqrstuvwxyz
{"a":1,"b":1,"c":1,"d":1,"e":1,"f":1,"g":1,"h":1,"i":1,"j":1,"k":1,"l":1,"m":1,"n":1,"o":1,"p":1,"q":1,"r":1,"s":1,"t":1,"u":1,"v":1,"w":1,"x":1,"y":1,"z":1}