Updated for challenge 9
[cipher-tools.git] / 2016 / 2016-challenge3.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 1,
6 "metadata": {},
7 "outputs": [],
8 "source": [
9 "import os,sys,inspect\n",
10 "currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n",
11 "parentdir = os.path.dirname(currentdir)\n",
12 "sys.path.insert(0,parentdir) \n",
13 "\n",
14 "import matplotlib.pyplot as plt\n",
15 "%matplotlib inline\n",
16 "\n",
17 "from cipher.keyword_cipher import *\n",
18 "from support.utilities import *\n",
19 "from support.text_prettify import *\n",
20 "\n",
21 "c3a = open('3a.ciphertext').read()\n",
22 "c3b = open('3b.ciphertext').read()"
23 ]
24 },
25 {
26 "cell_type": "code",
27 "execution_count": 2,
28 "metadata": {},
29 "outputs": [
30 {
31 "data": {
32 "text/plain": [
33 "(('weston', <KeywordWrapAlphabet.from_largest: 3>), -1706.5657011593255)"
34 ]
35 },
36 "execution_count": 2,
37 "metadata": {},
38 "output_type": "execute_result"
39 }
40 ],
41 "source": [
42 "key_a, score = keyword_break_mp(c3a)\n",
43 "key_a, score"
44 ]
45 },
46 {
47 "cell_type": "code",
48 "execution_count": 3,
49 "metadata": {},
50 "outputs": [
51 {
52 "name": "stdout",
53 "output_type": "stream",
54 "text": [
55 "harry,\n",
56 "\n",
57 "if jamelia was working on a scheme to weaponise earthquakes, then we need to know how far she had got. i have sent trinity in to work undercover in jamelia’s lab and tasked her to try to infiltrate dynamix from there. trinity isn’t too happy there, jamelia’s office isn’t much bigger than a broom closet, but we need to try to find the code base referred to in the hidden diary entry.\n",
58 "\n",
59 "in the meantime, i have been working on the list of questions you and jamelia were asking. first: why did martin leave? according to his flatmate he flew to geneva for talks with a company called citadelle. our local agents are making enquiries, but it seems that they are that rarest of things, an established arms manufacturer with money worries. second: where is martin now? no-one knows. citadelle deny any knowledge of him, and there is no record of him leaving the country. he has disappeared.\n",
60 "\n",
61 "the most intriguing thing from jamelia’s last message is the reference to the pds syndicate. i have heard rumours of this myself in whitehall. it is all very hush-hush and it is not even clear if it is an official initiative.\n",
62 "\n",
63 "the big news for now is a breakthrough on the so called suicide note. given how small jamelia’s office was, trinity wondered why she had kept a broken printer in there next to the working one. trinity opened it up and found a few modifications which pointed the laser straight at the paper instead of the drum. she got in touch with the lab and got them to take another look at the letter. they found the attached message burned into the paper fibres. it is impossible to see with the naked eye, but the charring shows up under high powered fluoroscopy. over to you for the decryption.\n",
64 "\n"
65 ]
66 }
67 ],
68 "source": [
69 "print(keyword_decipher(c3a, key_a[0], key_a[1]))"
70 ]
71 },
72 {
73 "cell_type": "code",
74 "execution_count": 4,
75 "metadata": {},
76 "outputs": [
77 {
78 "data": {
79 "text/plain": [
80 "(('neural', <KeywordWrapAlphabet.from_largest: 3>), -1476.8535205989874)"
81 ]
82 },
83 "execution_count": 4,
84 "metadata": {},
85 "output_type": "execute_result"
86 }
87 ],
88 "source": [
89 "key_b, score = keyword_break_mp(c3b)\n",
90 "key_b, score"
91 ]
92 },
93 {
94 "cell_type": "code",
95 "execution_count": 5,
96 "metadata": {},
97 "outputs": [
98 {
99 "name": "stdout",
100 "output_type": "stream",
101 "text": [
102 "notes on dynamix citadelle the pds syndicate dynamix area small company that relies on postgraduate interns for most of its good ideas the project we worked on for dynamix was signal recognition in a noisy environment citadelle is a major arms manufacturer that got left behind in the digital age and seems to be looking to buy it swayback into the market by taking over smaller more nimble competitors after we left dynamix we were both approached by someone claiming to work for citadelle saying they were impressed by the work we did there and that they would be interested in developing the code we wrote it old them where to go i thought martin was going to do the same but then he told me he wanted to talk with them he said that our code might be of interest to powerful people and i though the was trying to get me to join him and work with them now i think he was trying to warn me after martin disappeared i was approached by someone claiming to work for a government agency known as the pds syndicate they wouldnt tell me what they did or why they were interested but they wanted to know where martin had gone i have almost finished testing the latest version of the net it is better than any of the previous versions by several orders of magnitude and i havent tuned it yeti think it has real potential and i think that dynamix citadelle and the pds syndicate think that too i am afraid i think i need to hide i dont know where to run\n"
103 ]
104 }
105 ],
106 "source": [
107 "print(wcat(segment(sanitise(keyword_decipher(c3b, key_b[0], key_b[1])))))"
108 ]
109 },
110 {
111 "cell_type": "code",
112 "execution_count": null,
113 "metadata": {
114 "collapsed": true
115 },
116 "outputs": [],
117 "source": []
118 }
119 ],
120 "metadata": {
121 "kernelspec": {
122 "display_name": "Python 3",
123 "language": "python",
124 "name": "python3"
125 },
126 "language_info": {
127 "codemirror_mode": {
128 "name": "ipython",
129 "version": 3
130 },
131 "file_extension": ".py",
132 "mimetype": "text/x-python",
133 "name": "python",
134 "nbconvert_exporter": "python",
135 "pygments_lexer": "ipython3",
136 "version": "3.6.3"
137 }
138 },
139 "nbformat": 4,
140 "nbformat_minor": 1
141 }