Challenge 8a done, 8b not attempted
[cipher-training.git] / 2014-challenge1.ipynb
1 {
2 "metadata": {
3 "name": "",
4 "signature": "sha256:238ee41cd65ee30b21b8e31cf8256253cda5ffb52bd978fe39c5c022b8eaa509"
5 },
6 "nbformat": 3,
7 "nbformat_minor": 0,
8 "worksheets": [
9 {
10 "cells": [
11 {
12 "cell_type": "code",
13 "collapsed": false,
14 "input": [
15 "import matplotlib.pyplot as plt\n",
16 "%matplotlib inline\n",
17 "\n",
18 "from cipherbreak import *\n",
19 "\n",
20 "c1a = open('2014/1a.ciphertext').read()\n",
21 "c1b = open('2014/1b.ciphertext').read()"
22 ],
23 "language": "python",
24 "metadata": {},
25 "outputs": [],
26 "prompt_number": 1
27 },
28 {
29 "cell_type": "code",
30 "collapsed": false,
31 "input": [
32 "key_a, score = caesar_break(c1a)\n",
33 "key_a, score"
34 ],
35 "language": "python",
36 "metadata": {},
37 "outputs": [
38 {
39 "metadata": {},
40 "output_type": "pyout",
41 "prompt_number": 15,
42 "text": [
43 "(4, -728.156672407534)"
44 ]
45 }
46 ],
47 "prompt_number": 15
48 },
49 {
50 "cell_type": "code",
51 "collapsed": false,
52 "input": [
53 "print(caesar_decipher(c1a, key_a))"
54 ],
55 "language": "python",
56 "metadata": {},
57 "outputs": [
58 {
59 "output_type": "stream",
60 "stream": "stdout",
61 "text": [
62 "MARK, \n",
63 "\n",
64 "THANKS FOR BRINGING ME IN ON THIS ONE, SEEMS LIKE A FASCINATING CASE. \n",
65 "\n",
66 "I HAVE THREE QUESTIONS: \n",
67 "WHY WOULD THE FLAG DAY ASSOCIATES WANT A SHIP? \n",
68 "WHY WOULD THEY WANT THIS SHIP? \n",
69 "WHY WOULD THEY WANT THIS SHIP NOW? \n",
70 "\n",
71 "HAVING READ THE ATTACHED DOCUMENT I SUSPECT THAT THE ANSWERS ARE ALL RELATED TO THE QUESTION OF WHAT EXACTLY SHE AND HER FLAG DAY ASSOCIATE CREW WERE TRYING TO SURVEY. \n",
72 "\n",
73 "I AM GUESSING THAT YOU ALREADY CHECKED OUT THE ONBOARD GPS SYSTEM FOR INFORMATION ABOUT HER MOVEMENTS, BUT IF YOU DID FIND ANYTHING I WOULD BE FASCINATED TO HEAR ABOUT IT. IN THE MEANTIME I AM PRETTY SURE THAT YOU KNOW MORE ABOUT THE FLAG DAY ASSOCIATES THAN YOU HAVE TOLD ME, SO A BRIEFING WOULD BE MUCH APPRECIATED. \n",
74 "\n",
75 "ALL THE BEST, \n",
76 "\n",
77 "HARRY \n",
78 "\n"
79 ]
80 }
81 ],
82 "prompt_number": 9
83 },
84 {
85 "cell_type": "code",
86 "collapsed": false,
87 "input": [
88 "key_b, score = caesar_break(c1b)\n",
89 "key_b, score"
90 ],
91 "language": "python",
92 "metadata": {},
93 "outputs": [
94 {
95 "metadata": {},
96 "output_type": "pyout",
97 "prompt_number": 10,
98 "text": [
99 "(22, -637.7038880633795)"
100 ]
101 }
102 ],
103 "prompt_number": 10
104 },
105 {
106 "cell_type": "code",
107 "collapsed": false,
108 "input": [
109 "print(' '.join(segment(sanitise(caesar_decipher(c1b, key_b)))))"
110 ],
111 "language": "python",
112 "metadata": {},
113 "outputs": [
114 {
115 "output_type": "stream",
116 "stream": "stdout",
117 "text": [
118 "report on the trojan project having drugged the crew we were able to take the ship with essentially no resistance the crew were handed to the somali pirates at the deepwater rendezvous as planned and we began the survey just after midnight the radar showed an approaching vessel which our database identified as a coastguard cutter we headed south to avoid detection with all ship lights off we then completed the survey in the new location afterdawn with the listening post installed we began assembling the equipment for phase two of the operation keeping a watch for further patrols in the sky and on the water\n"
119 ]
120 }
121 ],
122 "prompt_number": 14
123 },
124 {
125 "cell_type": "code",
126 "collapsed": false,
127 "input": [],
128 "language": "python",
129 "metadata": {},
130 "outputs": []
131 }
132 ],
133 "metadata": {}
134 }
135 ]
136 }