1 00:00:00,640 --> 00:00:08,560 Now, let us move on to the next function, which we have created now, before that, let us understand 2 00:00:08,560 --> 00:00:11,580 the concept of finding the most likely killing. 3 00:00:12,490 --> 00:00:17,270 So over here, we have done or understood till we get most common factors function. 4 00:00:17,470 --> 00:00:23,290 Now, before we can figure out what the possible Saki's are for the ciphertext, we need to know how 5 00:00:23,290 --> 00:00:24,580 many CEP's there are. 6 00:00:24,940 --> 00:00:27,200 That is, we need to know the length of the key. 7 00:00:27,500 --> 00:00:34,960 So the Kazansky examination function returns the list of most likely Gilenya for a given ciphertext 8 00:00:34,960 --> 00:00:35,530 argument. 9 00:00:36,160 --> 00:00:38,470 Look, Elance are the integer in the list. 10 00:00:38,470 --> 00:00:44,890 Forced integer in the list is most likely the Chelin second integer is the second most likely and so 11 00:00:44,890 --> 00:00:45,190 on. 12 00:00:45,610 --> 00:00:51,040 For step in finding the key is to find the spacing between the repeated sequence and ciphertext. 13 00:00:51,350 --> 00:00:53,640 Hence we are doing the fourth thing that is fine. 14 00:00:53,650 --> 00:01:00,160 Repeat sequence spacing function has been found is been called over here, which is returning a particular 15 00:01:00,160 --> 00:01:06,520 value as dictionary with the sequence of string as its key and the list with the spaces as integer and 16 00:01:06,520 --> 00:01:07,170 its values. 17 00:01:07,840 --> 00:01:14,410 Now this function loss, we have already seen this in the earlier session and before continuing with 18 00:01:14,410 --> 00:01:21,220 the next line, we will need to learn about the extend method which we are using now before we proceed 19 00:01:21,220 --> 00:01:21,760 further. 20 00:01:22,030 --> 00:01:28,990 Let us understand something about the extend list when you need to add multiple values to the end of 21 00:01:28,990 --> 00:01:32,740 a list, that is an easier way than calling the append inside a loop. 22 00:01:33,070 --> 00:01:39,760 To extend the list, Matau can add values to the end of the list, similar to the append when past a 23 00:01:39,760 --> 00:01:45,850 list, the open method at the entire list as one item to the end of the another list. 24 00:01:46,120 --> 00:01:56,350 Like if we just try on something in the interactive shell here we see span is equal to C catch bitin. 25 00:01:57,830 --> 00:02:04,040 Miles, something like that, then we have said one that is equal to say one, two, three, four, 26 00:02:04,040 --> 00:02:11,170 something like that, then we c span got up and one. 27 00:02:11,570 --> 00:02:14,800 And now if we try to print, we get all the things appended. 28 00:02:15,260 --> 00:02:21,330 Now, in contrast, the extender method adds each item in the list argument to the end of the list. 29 00:02:21,650 --> 00:02:24,170 For example, if we do the same thing again. 30 00:02:25,420 --> 00:02:31,010 Have the same values here, which will make it more meaningful for us to understand. 31 00:02:31,420 --> 00:02:34,680 And one is equal to again, say one, two, three, four. 32 00:02:35,110 --> 00:02:42,600 And then we are seeing standard not open, but using extend and one here, another footprint. 33 00:02:42,900 --> 00:02:48,510 See it as a simple list, which is showing that individual items have been added. 34 00:02:49,090 --> 00:02:52,840 So these are appended to your span as all discrete items. 35 00:02:53,110 --> 00:03:00,760 So now if you move to our code here now, although your repeated sequence spacing is a dictionary that 36 00:03:00,760 --> 00:03:07,240 we have which on which map sequence string to the list of integer spacing, we actually need a dictionary 37 00:03:07,240 --> 00:03:11,650 that map the sequence string to list of factors of those integer spacing. 38 00:03:12,100 --> 00:03:18,370 So over here we are starting with the next thing as creating an empty dictionary in the sequence factor. 39 00:03:18,400 --> 00:03:24,970 The for loop iterates over each key, which is a sequence string in a dictionary, repeated sequence 40 00:03:24,970 --> 00:03:30,460 spacing, and for each key it sets a blank list with a value in the sequence vector. 41 00:03:31,060 --> 00:03:41,200 Then after this default iterates over all the spacing integers by passing each to the get useful factors 42 00:03:41,320 --> 00:03:44,950 call and each of the items in the list return from that. 43 00:03:44,960 --> 00:03:49,570 Useful factors which we are calling over here is added to your sequence fact. 44 00:03:49,570 --> 00:03:52,520 Those are the index of sequence using the extended material. 45 00:03:52,960 --> 00:03:59,470 Now when all the four loops are complete or finished, executing the sequence facto should be a dictionary. 46 00:03:59,470 --> 00:04:03,060 That maps sequence string to the list of factors of detail spacing. 47 00:04:03,430 --> 00:04:08,700 And this allows us to have de facto spacing by not just the spacing in this case. 48 00:04:09,100 --> 00:04:16,420 So we pass the sequence factors, which is our dictionary, to get the most common factors function 49 00:04:16,630 --> 00:04:23,140 and returns a list of doing dijo over there, which is known as the integer tuples whose first integer 50 00:04:23,140 --> 00:04:28,570 represents the factor and whose second integer shows how often the fact that appears in the sequence 51 00:04:28,900 --> 00:04:30,280 that you get stored. 52 00:04:30,280 --> 00:04:38,080 In fact, those count and but we want the kazatsky examination function to return a list of the integer 53 00:04:38,080 --> 00:04:44,740 factors, not a list of people with factors and the count of how often they appear, not because these 54 00:04:44,740 --> 00:04:49,660 factors are stored in the first item of the 22 people in the list of factors. 55 00:04:49,660 --> 00:04:54,640 By count, we need to pull this fact factors from the tuple and put them in a separate list. 56 00:04:54,890 --> 00:05:01,750 Hence we are seeing, creating or iterating over the four of the two person factors by counting upending 57 00:05:01,750 --> 00:05:03,520 the tuples index zero item. 58 00:05:03,520 --> 00:05:10,570 At the end of all, likely killens, which we're creating here after this fall, completes the all likely 59 00:05:10,570 --> 00:05:13,570 Killens variable should contain all the integer factors. 60 00:05:13,570 --> 00:05:19,810 In fact, those by count, which gets written as a list form of viscose ASCII examination function. 61 00:05:20,320 --> 00:05:25,990 Now, although we now have the ability to find the likely guyland, the message wasn't repeated. 62 00:05:25,990 --> 00:05:32,020 What we need to be able to separate the letters from the message that were encrypted with the same subcu. 63 00:05:32,380 --> 00:05:38,680 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 64 00:05:38,680 --> 00:05:44,200 and give the message that those are the index zero three six nine and 12, because these letters from 65 00:05:44,200 --> 00:05:48,460 the original English message are encrypted with the same Safdie that is X. 66 00:05:48,610 --> 00:05:52,690 The decrypted text should have that the frequency count similar to English. 67 00:05:52,960 --> 00:05:57,130 Hence we use this information to figure out the subcu for moving ahead. 68 00:05:57,130 --> 00:06:02,920 We come to getting that those encrypted with the same subcu to pull out the letters from a ciphertext 69 00:06:02,920 --> 00:06:04,450 that are encrypted with the same stuff. 70 00:06:04,640 --> 00:06:11,320 We need to write the function that can create a string using the first, second or the end letter of 71 00:06:11,320 --> 00:06:17,050 a message after the function has this stopping in the length and the message to it. 72 00:06:17,260 --> 00:06:23,380 First step is to remove the non letter characters from message using a regular expression and it's submental. 73 00:06:23,710 --> 00:06:29,070 And these letters only a string is then stored as a new value in the message. 74 00:06:29,380 --> 00:06:36,100 So if you look at over here to get and the subcu letters which takes and the garland and the message, 75 00:06:36,400 --> 00:06:43,600 we built a string by appending over here the little string to a list and then use the joint matter. 76 00:06:45,190 --> 00:06:51,910 If you just look at this particular function here, then we use the joint method here to merge the list 77 00:06:51,910 --> 00:06:53,180 into a single string. 78 00:06:53,410 --> 00:06:59,980 So here, if you just look at the first thing that is the variable which is pointing to over here is 79 00:06:59,980 --> 00:07:06,400 equal to the index of the letter in the message that you want to open to the string mailing list and 80 00:07:06,430 --> 00:07:12,790 which is stored in the variable named letters, the variable starts with the value end minus one and 81 00:07:12,790 --> 00:07:19,210 the letters are variable, starts with the blank list, which is over here in this open close bracket 82 00:07:19,510 --> 00:07:21,250 by loop continues to run. 83 00:07:21,250 --> 00:07:24,730 As long as I use this, then the length of message that is. 84 00:07:24,920 --> 00:07:31,610 What we have described it on on each iteration, the letter that the message is appended to the list 85 00:07:31,610 --> 00:07:38,260 in a letter this year, then I is updated to point to the next letter in this up by adding the key length 86 00:07:38,270 --> 00:07:40,310 to I on the next step. 87 00:07:40,550 --> 00:07:47,090 And after the loop finishes, we join the single letter string values in the letters list into one string 88 00:07:47,090 --> 00:07:51,800 and the string is written from the get and key subcu letters.