Now, let us move on to the next function, which we have created now, before that, let us understand
the concept of finding the most likely killing.
So over here, we have done or understood till we get most common factors function.
Now, before we can figure out what the possible Saki's are for the ciphertext, we need to know how
many CEP's there are.
That is, we need to know the length of the key.
So the Kazansky examination function returns the list of most likely Gilenya for a given ciphertext
argument.
Look, Elance are the integer in the list.
Forced integer in the list is most likely the Chelin second integer is the second most likely and so
on.
For step in finding the key is to find the spacing between the repeated sequence and ciphertext.
Hence we are doing the fourth thing that is fine.
Repeat sequence spacing function has been found is been called over here, which is returning a particular
value as dictionary with the sequence of string as its key and the list with the spaces as integer and
its values.
Now this function loss, we have already seen this in the earlier session and before continuing with
the next line, we will need to learn about the extend method which we are using now before we proceed
further.
Let us understand something about the extend list when you need to add multiple values to the end of
a list, that is an easier way than calling the append inside a loop.
To extend the list, Matau can add values to the end of the list, similar to the append when past a
list, the open method at the entire list as one item to the end of the another list.
Like if we just try on something in the interactive shell here we see span is equal to C catch bitin.
Miles, something like that, then we have said one that is equal to say one, two, three, four,
something like that, then we c span got up and one.
And now if we try to print, we get all the things appended.
Now, in contrast, the extender method adds each item in the list argument to the end of the list.
For example, if we do the same thing again.
Have the same values here, which will make it more meaningful for us to understand.
And one is equal to again, say one, two, three, four.
And then we are seeing standard not open, but using extend and one here, another footprint.
See it as a simple list, which is showing that individual items have been added.
So these are appended to your span as all discrete items.
So now if you move to our code here now, although your repeated sequence spacing is a dictionary that
we have which on which map sequence string to the list of integer spacing, we actually need a dictionary
that map the sequence string to list of factors of those integer spacing.
So over here we are starting with the next thing as creating an empty dictionary in the sequence factor.
The for loop iterates over each key, which is a sequence string in a dictionary, repeated sequence
spacing, and for each key it sets a blank list with a value in the sequence vector.
Then after this default iterates over all the spacing integers by passing each to the get useful factors
call and each of the items in the list return from that.
Useful factors which we are calling over here is added to your sequence fact.
Those are the index of sequence using the extended material.
Now when all the four loops are complete or finished, executing the sequence facto should be a dictionary.
That maps sequence string to the list of factors of detail spacing.
And this allows us to have de facto spacing by not just the spacing in this case.
So we pass the sequence factors, which is our dictionary, to get the most common factors function
and returns a list of doing dijo over there, which is known as the integer tuples whose first integer
represents the factor and whose second integer shows how often the fact that appears in the sequence
that you get stored.
In fact, those count and but we want the kazatsky examination function to return a list of the integer
factors, not a list of people with factors and the count of how often they appear, not because these
factors are stored in the first item of the 22 people in the list of factors.
By count, we need to pull this fact factors from the tuple and put them in a separate list.
Hence we are seeing, creating or iterating over the four of the two person factors by counting upending
the tuples index zero item.
At the end of all, likely killens, which we're creating here after this fall, completes the all likely
Killens variable should contain all the integer factors.
In fact, those by count, which gets written as a list form of viscose ASCII examination function.
Now, although we now have the ability to find the likely guyland, the message wasn't repeated.
What we need to be able to separate the letters from the message that were encrypted with the same subcu.
So we call the entry that the dog and the cat with the key of X, Y, Z ends up using it from the Ketel
and give the message that those are the index zero three six nine and 12, because these letters from
the original English message are encrypted with the same Safdie that is X.
The decrypted text should have that the frequency count similar to English.
Hence we use this information to figure out the subcu for moving ahead.
We come to getting that those encrypted with the same subcu to pull out the letters from a ciphertext
that are encrypted with the same stuff.
We need to write the function that can create a string using the first, second or the end letter of
a message after the function has this stopping in the length and the message to it.
First step is to remove the non letter characters from message using a regular expression and it's submental.
And these letters only a string is then stored as a new value in the message.
So if you look at over here to get and the subcu letters which takes and the garland and the message,
we built a string by appending over here the little string to a list and then use the joint matter.
If you just look at this particular function here, then we use the joint method here to merge the list
into a single string.
So here, if you just look at the first thing that is the variable which is pointing to over here is
equal to the index of the letter in the message that you want to open to the string mailing list and
which is stored in the variable named letters, the variable starts with the value end minus one and
the letters are variable, starts with the blank list, which is over here in this open close bracket
by loop continues to run.
As long as I use this, then the length of message that is.
What we have described it on on each iteration, the letter that the message is appended to the list
in a letter this year, then I is updated to point to the next letter in this up by adding the key length
to I on the next step.
And after the loop finishes, we join the single letter string values in the letters list into one string
and the string is written from the get and key subcu letters.