Question
IndexofCoincidence If two strings of equal length are superimposed on one another, then some letters may match. For example consider the strings w onderwhowrot e
-
IndexofCoincidence If two strings of equal length are superimposed on one another, then some letters may match. For example consider the strings
wonderwhowrotethebookonlove and weallliveinayellowsubmarine
Notice that there are three positions that contain the same letter: the 1st (w) , 14th (e), and 27th (e). Of 27 possible positions, matches occur in three positions (11.1%). This percentage is called the index of coincidence for two strings, and it is used to decrypt ciphers like those used by the Germans in World War II.
Write a program that accepts two strings of the same length and determines their index of coincidence. For normal written English, the index of coincidence averages about 6.6%, while for random strings it is 1/26, or around 3.8%.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started