Frequency
Time limit1sMemory limit1024 MB
Count how often each Latin letter appears, ignoring case, in text that ends with @, and print a vertical bar chart with the letters A to Z along the bottom.
- Level
Easy2 of 10
- Topics
- String, Implementation
- Solved
- No attempts yet
Problem
Harry Potter's Defence Against the Dark Arts teacher, no wait, his Bulgarian language teacher, asked him to count how many times each letter of the Latin alphabet appears in one of the Harry Potter books. To show the result visually, he decided to draw a chart.
Write a program named frequency that reads a text ending with @ and prints a chart of how often each letter of the Latin alphabet appears.
Input
The program reads from standard input a sequence of characters ending with @. The sequence may span more than one line.
Output
The program prints to standard output a chart in the form shown below.
- The last line contains the uppercase letters of the Latin alphabet in alphabetical order.
- The second-to-last line contains 26
-characters that separate the column labels from the column values. - Each line above those two lines contains the uppercase letters placed so that the height of each column above its letter equals the number of times that letter appears in the text, counting both uppercase and lowercase occurrences.