|
|
|
| | | | | | | | | | | | | | | | | | | | | | | | | | |
|
|
|
|
The two lists are identical. |
|
|
|
| |
|
|
|
|
Position 3: 76 != 176 Position 4: 22 != 12 |
|
|
|
|
|
|
|
|
|
|
Problem-Solving Case Study Frequency of Certain Characters |
|
|
|
|
|
|
|
|
Problem: You've found a secret message, written in some sort of code. After doing some research, you decide to see if it is a simple substitution cypher-a code in which each letter is replaced by a different letter. Your research tells you that the way to break this type of code is to count the occurrences of each letter in the text and compare them to the average occurrence of letters in any English text. For example, the most common letter is probably a substitute for e. You decide to write a program to count the occurrences of certain characters in a text file. Rather than count every character in the message, you decide to look just at certain characters that appear to be the most common. The characters you are interested in are input from the keyboard. |
|
|
|
|
|
|
|
|
Input: A list of the characters to be counted, as read from the keyboard (the character '#' ends the list); and text to be processed character by character (in file dataFile). |
|
|
|
|
|
|
|
|
Output: The characters to be counted and their frequency. |
|
|
|
|
|