11 "import matplotlib.pyplot as plt\n",
12 "%matplotlib inline\n",
14 "from cipherbreak import *\n",
16 "c4a = open('2015/4a.ciphertext').read()\n",
17 "c4b = open('2015/4b.ciphertext').read()"
30 "(('reanimates', <KeywordWrapAlphabet.from_last: 2>), -911.6411317751041)"
35 "output_type": "execute_result"
39 "(key_a_word, key_a_wrap), score = keyword_break_mp(c4a)\n",
40 "(key_a_word, key_a_wrap), score"
52 "output_type": "stream",
54 "gharlie, the attaghew note fas ledt in one od my weaw wrops last nibht anw appears to ce drom our mysterious sourge. it gontains tfo really sibnidigant pieges od intellibenge. the dirst is that the rieghswoktor mibht not reder to an inwiviwual adter all. it seems to ce the gowename dor the orbanization runninb the ratlines. aggorwinb to my other sourges this is a gollegtion od routes, abents anw sade houses usew to transport nazi sympathisers anw far griminals out od bermany anw on to south ameriga. fe have knofn that sugh an orbanisation exists singe the enw od the far, cut this is the dirst time i have seen it namew. the other piege od indormation is mugh more suctle. i am cebinninb to fonwer id our sourge is gloser to home than fe haw realisew. anw i am not rederrinb to drangois! see id you gan spot the tfo thinbs i notigew. cy the fay, fho transgricew the rawio intergept you sent me last feek? harry\n",
60 "print(keyword_decipher(c4a, key_a_word, wrap_alphabet=key_a_wrap))"
101 "execution_count": 3,
103 "output_type": "execute_result"
107 "trans = ''.maketrans(keyword_cipher_alphabet_of(key_a_word, wrap_alphabet=key_a_wrap), string.ascii_lowercase)\n",
108 "t2 = {chr(c): chr(trans[c]) for c in trans}\n",
114 "execution_count": 4,
150 "execution_count": 4,
152 "output_type": "execute_result"
164 "sorted(((c, t2[c]) for c in t2), key=lambda p: p[1])"
169 "execution_count": 5,
176 "output_type": "stream",
178 "charlie, the attached note was left in one of my dead drops last night and appears to be from our mysterious source. it contains two really significant pieces of intelligence. the first is that the riechsdoktor might not refer to an individual after all. it seems to be the codename for the organization running the ratlines. according to my other sources this is a collection of routes, agents and safe houses used to transport nazi sympathisers and war criminals out of germany and on to south america. we have known that such an organisation exists since the end of the war, but this is the first time i have seen it named. the other piece of information is much more subtle. i am beginning to wonder if our source is closer to home than we had realised. and i am not referring to francois! see if you can spot the two things i noticed. by the way, who transcribed the radio intercept you sent me last week? harry\n",
184 "print(keyword_decipher(c4a, 'ratlines', wrap_alphabet=key_a_wrap))"
189 "execution_count": 6,
197 "(('francois', <KeywordWrapAlphabet.from_last: 2>), -1082.7018217012803)"
200 "execution_count": 6,
202 "output_type": "execute_result"
206 "(key_b_word, key_b_wrap), score =keyword_break_mp(c4b)\n",
207 "(key_b_word, key_b_wrap), score"
212 "execution_count": 7,
219 "output_type": "stream",
221 "the french maybe your allies but they are not your friends they plan to infiltrate the rat i lines and to try to turn the high value targets for themselves they have a particular interest in nazi scientists from the die alchemist en project if you want to break the reichs doktor network before they can do so take care not to share any intelligence with them you have been warned i think it is time to begin negotiations i have a number in mind and i think once you know what i am offering you will find it very reasonable as a sign of good faith ioffer you the following information one of the local rat i line coordinators will be leaving the us sector tomorrow night in a black limousine under the backseat of his car you will find hidden a juniors s officer who is trying to escape and in the trunk you will find a number of papers relating to stolen artworks that he hopes to trade to the french for his freedom you might want to consider carefully whether you can trust your friend charlie with this information after all her husband francois is french\n"
226 "print(' '.join(segment(sanitise(keyword_decipher(c4b, key_b_word, wrap_alphabet=key_b_wrap)))))"
231 "execution_count": null,
241 "display_name": "Python 3",
242 "language": "python",
250 "file_extension": ".py",
251 "mimetype": "text/x-python",
253 "nbconvert_exporter": "python",
254 "pygments_lexer": "ipython3",