Worked on Enigma, mainly changing how the notch positions are handled
[cipher-training.git] / 2014 / 2014-challenge2.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 3,
6 "metadata": {
7 "collapsed": false
8 },
9 "outputs": [],
10 "source": [
11 "import os,sys,inspect\n",
12 "currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n",
13 "parentdir = os.path.dirname(currentdir)\n",
14 "sys.path.insert(0,parentdir) \n",
15 "\n",
16 "import matplotlib.pyplot as plt\n",
17 "import pandas as pd\n",
18 "import collections\n",
19 "import string\n",
20 "%matplotlib inline\n",
21 "\n",
22 "from cipherbreak import *\n",
23 "\n",
24 "c2a = open('2a.ciphertext').read()\n",
25 "c2b = open('2b.ciphertext').read()"
26 ]
27 },
28 {
29 "cell_type": "code",
30 "execution_count": 4,
31 "metadata": {
32 "collapsed": false
33 },
34 "outputs": [
35 {
36 "data": {
37 "text/plain": [
38 "<matplotlib.axes._subplots.AxesSubplot at 0x7f8012c71eb8>"
39 ]
40 },
41 "execution_count": 4,
42 "metadata": {},
43 "output_type": "execute_result"
44 },
45 {
46 "data": {
47 "image/png": "iVBORw0KGgoAAAANSUhEUgAAAYYAAAD+CAYAAAA+hqL9AAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAHrNJREFUeJzt3X+cXXV95/HXG7KJESJhkIYAAVJ3EOLqQ40muv7YcZGQ\n7iqwWwphtzC1sz4qUdF9dPswcVcyU7oW3G0pdhdqLUISlSYVhdjFMGPira4aBhE0JaZJVsdNBjK4\ngwna+iMpn/3jfIc553J/Z37cTN7Px+M+7vd8z/f7Pd9z58z93PP9nnuuIgIzM7MxJ013B8zMrL04\nMJiZWYEDg5mZFTgwmJlZgQODmZkVODCYmVlB3cAgaa2kJyTtlPRZSXMkdUgakLRHUr+k+WXl90ra\nLWlFLn9pamOvpNtz+XMkbUr5OySdn1vXnbaxR9L1E7njZmZWWc3AIOkC4N3AayPilcDJwC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bDnm\ndVQ4ntNrVG17rRyfl9VZX244DWdcCtyS5lyqfTD9LNlQ1S2Mf8IG+ElEjNbaSNmxcBJZgGt0fuFp\n4CAwSvaBqdZ2tpEFnW+SnWm8LiKertP+UeBnZKMaLwK+HxF1g31EPCfpIDBCFmBPBz4n6csR8XtV\n6hwFVkv6LbIzwuaGo9JpxoyTxu5eAmyNiF9WWH9BjeoRET+s0fYryCJyANsjYle1srk6SxmfRPxq\nRDzWQJ2Lyb7DAbAtJulS3TSZ+qbUt69HRMWzjDqvGRExNNF9a8RU90vS3wEXRRP/PNX6WK9v6bh5\nfiK53nHT6mvRyvHZjPRBYyXw3YjYK2kh8MqI6J/g7VyQWzwKjER2n7VadVYDV5MFkb8CNtX7n5Z0\nG1kQ/jnwDbK5zW+OjVhUqfMdYAtZoHop8AngFxHxGzXqfAC4nixY/QXZ0PgRZRen7I2IF5w5SPqd\niPhEbnkp8N6I+O1a+1RoY6YGBrPJIulu4L9HxBPT3Rc7dpL+kCwYVLwKr07deWRDPP+J7KrBOTXK\nvj4iHinLuz4iNtSo0wd8qtIHVUlLGvlQ2goHBrMmSdoNvIxskm/ah9Js6kl6P9kZ1lKy4+BrZGd0\n26e1YxNkps0xmE2FldPdAZt2LyKbb/x2vaGq45HPGMzMrGCmXa5qZmbHyIHBzMwKHBjMzKzAgcHM\nzAocGMzMrOD/A5ZV4vqjDJn1AAAAAElFTkSuQmCC\n",
48 "text/plain": [
49 "<matplotlib.figure.Figure at 0x7f8012c71898>"
50 ]
51 },
52 "metadata": {},
53 "output_type": "display_data"
54 }
55 ],
56 "source": [
57 "freqs = pd.Series(english_counts)\n",
58 "freqs.plot(kind='bar')"
59 ]
60 },
61 {
62 "cell_type": "code",
63 "execution_count": 5,
64 "metadata": {
65 "collapsed": false
66 },
67 "outputs": [
68 {
69 "data": {
70 "text/plain": [
71 "((5, 25, True), -761.8388033231918)"
72 ]
73 },
74 "execution_count": 5,
75 "metadata": {},
76 "output_type": "execute_result"
77 }
78 ],
79 "source": [
80 "key_a, score = affine_break(c2a)\n",
81 "key_a, score"
82 ]
83 },
84 {
85 "cell_type": "code",
86 "execution_count": 6,
87 "metadata": {
88 "collapsed": false
89 },
90 "outputs": [
91 {
92 "name": "stdout",
93 "output_type": "stream",
94 "text": [
95 "DEAR MARK, \n",
96 "\n",
97 "THANKS FOR THE LATEST REPORT FROM THE ON-SITE TEAM. IT SHOWS THAT THE SHIPBOARD GPS SYSTEM WAS COMPLETELY SCRAMBLED SO WE ARE NOT GOING TO BE ABLE TO TRACE HER MOVEMENTS FROM THAT. DO WE HAVE ANY ODD TRACES FROM ONSHORE RADAR THAT GIVE A HINT OF WHERE SHE MIGHT HAVE BEEN? \n",
98 "\n",
99 "THE COMMENT IN THE LAST MESSAGE THAT THE PIRATES COMPLETED THE SURVEY EVEN THOUGH THEY HAD MOVED SOUTH TO AVOID DETECTION SHOULD HAVE TOLD ME THAT THE SURVEY WAS NOT GEOGRAPHIC. AT FIRST I THOUGHT IT MIGHT HAVE BEEN REFERRING TO A TELECOMS SURVEY SINCE YOU MENTIONED THE LONG AERIAL, BUT ACTUALLY THE ATTACHED MESSAGE IS VERY REVEALING. STILL NOT SURE WHAT THE SURVEY WAS FOR THOUGH, AND HOW THAT IS CONNECTED TO THE MISSING SUPERSTRUCTURE. CAN YOU GET ME ANY PICTURES? \n",
100 "\n",
101 "HARRY \n",
102 "\n"
103 ]
104 }
105 ],
106 "source": [
107 "print(affine_decipher(c2a, key_a[0], key_a[1]))"
108 ]
109 },
110 {
111 "cell_type": "code",
112 "execution_count": 7,
113 "metadata": {
114 "collapsed": false
115 },
116 "outputs": [
117 {
118 "data": {
119 "text/plain": [
120 "(('flag', <KeywordWrapAlphabet.from_largest: 3>), -367.81492429457404)"
121 ]
122 },
123 "execution_count": 7,
124 "metadata": {},
125 "output_type": "execute_result"
126 }
127 ],
128 "source": [
129 "key_b, score = keyword_break_mp(c2b)\n",
130 "key_b, score"
131 ]
132 },
133 {
134 "cell_type": "code",
135 "execution_count": 8,
136 "metadata": {
137 "collapsed": false
138 },
139 "outputs": [
140 {
141 "name": "stdout",
142 "output_type": "stream",
143 "text": [
144 "calm weather allowed us to complete the hull survey and establish its integrity no major remedial works were required and the pumps and extra bulkheads were installed out in deep waters over the next five days we are now testing the system for reliability and safety before moving on to phase three of the operation operation trojan remains on target\n"
145 ]
146 }
147 ],
148 "source": [
149 "print(' '.join(segment(sanitise(keyword_decipher(c2b, key_b[0], key_b[1])))))"
150 ]
151 },
152 {
153 "cell_type": "code",
154 "execution_count": 9,
155 "metadata": {
156 "collapsed": false
157 },
158 "outputs": [
159 {
160 "data": {
161 "text/plain": [
162 "<matplotlib.axes._subplots.AxesSubplot at 0x7f800850a358>"
163 ]
164 },
165 "execution_count": 9,
166 "metadata": {},
167 "output_type": "execute_result"
168 },
169 {
170 "data": {
171 "image/png": "iVBORw0KGgoAAAANSUhEUgAAAWwAAAD+CAYAAAAeRj9FAAAABHNCSVQICAgIfAhkiAAAAAlwSFlz\nAAALEgAACxIB0t1+/AAAFNBJREFUeJzt3X+wbWV93/H3B4giv4KMerlRnMtkqqhDiyVYU8101wzt\nbWIoNo0T01GSWodEA8SJjsTWuUcz9VcDzpi2JFFgLmjS2qhUOlPlBjgB0WBjLnAFCWYCHWjgMjWk\ngaAR5Ns/9rqXzbn719lnnx/Pvu/XzJ6z1jrr2c9z1l7ns9d+1lr7SVUhSdr6jtjsBkiSpmNgS1Ij\nDGxJaoSBLUmNMLAlqREGtiQ1YqrATnJkkr1Jru3ml5I80C3bm2Tn+jZTknTUlOtdBNwFHN/NF3Bp\nVV26Lq2SJB1i4hF2khcBPwF8EsiBxQPTkqQNME2XyMeAdwNPDSwr4IIktye5PMmJ69I6SdJBYwM7\nyeuBh6tqL888or4MOBU4A3gQuGTdWihJAiDjvkskyQeBNwNPAkcDJwCfraq3DKyzA7i2qk4fUt4v\nKpGkGVTVId3OY4+wq+q9VXVKVZ0K/CxwQ1W9Jcn2gdXeAOwb8xyHPHbt2jV0+aTH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ytwO\nfIH+m8jzgN8G/raqfmZMmYuAt9B/I/kk/e7dJ9K/COFbVTX0SDvJ+VX12wPzZwLvqKp/PelvO1hm\nowNbWqskVwK/UVV3bnZbNH9JPkQ/pIde/TRF+ePpd1W8i/5VW88es+5ZVfW/Vix7S1VdNabM+4Er\nhh04Jnn5tAeIszCw1ZwkdwM/TP8kziJ19WgNklxA/xPKmfT3jZvpfyK6YVMbNkcbPAivNBc7N7sB\n2pKOpn8O608mdbu0yiNsSWqEYzpKUiMMbElqhIEtSY0wsCWpEQa2JDXi/wNK7p7wknBykwAAAABJ\nRU5ErkJggg==\n",
172 "text/plain": [
173 "<matplotlib.figure.Figure at 0x7f800b778a58>"
174 ]
175 },
176 "metadata": {},
177 "output_type": "display_data"
178 }
179 ],
180 "source": [
181 "freqs_2b = pd.Series(collections.Counter([l.lower() for l in c2b if l in string.ascii_letters]))\n",
182 "freqs_2b.plot(kind='bar')"
183 ]
184 },
185 {
186 "cell_type": "code",
187 "execution_count": null,
188 "metadata": {
189 "collapsed": false
190 },
191 "outputs": [],
192 "source": []
193 }
194 ],
195 "metadata": {
196 "kernelspec": {
197 "display_name": "Python 3",
198 "language": "python",
199 "name": "python3"
200 },
201 "language_info": {
202 "codemirror_mode": {
203 "name": "ipython",
204 "version": 3
205 },
206 "file_extension": ".py",
207 "mimetype": "text/x-python",
208 "name": "python",
209 "nbconvert_exporter": "python",
210 "pygments_lexer": "ipython3",
211 "version": "3.4.3"
212 }
213 },
214 "nbformat": 4,
215 "nbformat_minor": 0
216 }