Resigned
[cipher-training.git] / 2015-challenge1.ipynb
1 {
2 "cells": [
3 {
4 "cell_type": "code",
5 "execution_count": 1,
6 "metadata": {
7 "collapsed": false
8 },
9 "outputs": [],
10 "source": [
11 "import matplotlib.pyplot as plt\n",
12 "%matplotlib inline\n",
13 "\n",
14 "from cipherbreak import *\n",
15 "\n",
16 "c1a = open('2015/1a.ciphertext').read()\n",
17 "c1b = open('2015/1b.ciphertext').read()"
18 ]
19 },
20 {
21 "cell_type": "code",
22 "execution_count": 2,
23 "metadata": {
24 "collapsed": false
25 },
26 "outputs": [
27 {
28 "data": {
29 "text/plain": [
30 "(12, -883.4816832492597)"
31 ]
32 },
33 "execution_count": 2,
34 "metadata": {},
35 "output_type": "execute_result"
36 }
37 ],
38 "source": [
39 "key_a, score = caesar_break(c1a)\n",
40 "key_a, score"
41 ]
42 },
43 {
44 "cell_type": "code",
45 "execution_count": 7,
46 "metadata": {
47 "collapsed": false
48 },
49 "outputs": [
50 {
51 "name": "stdout",
52 "output_type": "stream",
53 "text": [
54 "HARRY, SORRY TO DRAG YOU BACK IN , WE WERE HOPING TO GIVE YOU SOME TIME OFF AFTER THE LAST CASE, BUT SOMETHING CAME UP AND WE NEED YOUR HELP. \n",
55 "\n",
56 "AT A MEETING OF THE FOUR POWERS ALLIED CONTROL COUNCIL TWO WEEKS AGO THE FRENCH ACCUSED THE RUSSIANS OF SHELTERING A NAZI MEDIC KNOWN AS THE REICHSDOKTOR. APPARENTLY THEY INTERCEPTED A MORSE CODE RADIO BROADCAST FROM THE RUSSIAN SECTOR OF BERLIN IN WHICH THE DOCTOR WAS OFFERING INTELLIGENCE ABOUT THE RATLINES IN EXCHANGE FOR ASYLUM. THE RUSSIANS CLAIMED NOT TO KNOW ANYTHING ABOUT IT, AND MAYBE THEY ARE TELLING THE TRUTH, BUT THINGS HAVE BEEN A LITTLE FROSTY SINCE TRUMAN'S SPEECH ON MARCH TWELFTH AND WE REALLY DON'T NEED MORE CONFLICT RIGHT NOW. WE FIGURE WITH YOUR CONTACTS OVER HERE YOU MIGHT BE ABLE TO FIND OUT IF THE RUSSIANS ARE TELLING THE TRUTH. I HAVE ATTACHED THE ENCRYPTED TRANSCRIPT OF THE BROADCAST. \n",
57 "CHARLIE\n"
58 ]
59 }
60 ],
61 "source": [
62 "print(caesar_decipher(c1a, key_a))"
63 ]
64 },
65 {
66 "cell_type": "code",
67 "execution_count": 8,
68 "metadata": {
69 "collapsed": false
70 },
71 "outputs": [
72 {
73 "data": {
74 "text/plain": [
75 "(14, -403.53308240183975)"
76 ]
77 },
78 "execution_count": 8,
79 "metadata": {},
80 "output_type": "execute_result"
81 }
82 ],
83 "source": [
84 "key_b, score = caesar_break(c1b)\n",
85 "key_b, score"
86 ]
87 },
88 {
89 "cell_type": "code",
90 "execution_count": 9,
91 "metadata": {
92 "collapsed": false
93 },
94 "outputs": [
95 {
96 "name": "stdout",
97 "output_type": "stream",
98 "text": [
99 "if you want to know the secret of the rat lines i maybe able to help but the price will be high and is not negotiable life herein berlin has lost its lustre and i want sanctuary in a more congenial climate with security for my future i can provide details of personnel policy security and routes and can furnish you with documentary evidence of the reach of the organization the reichs doktor\n"
100 ]
101 }
102 ],
103 "source": [
104 "print(' '.join(segment(sanitise(caesar_decipher(c1b, key_b)))))"
105 ]
106 },
107 {
108 "cell_type": "code",
109 "execution_count": null,
110 "metadata": {
111 "collapsed": false
112 },
113 "outputs": [],
114 "source": []
115 }
116 ],
117 "metadata": {
118 "kernelspec": {
119 "display_name": "Python 3",
120 "language": "python",
121 "name": "python3"
122 },
123 "language_info": {
124 "codemirror_mode": {
125 "name": "ipython",
126 "version": 3
127 },
128 "file_extension": ".py",
129 "mimetype": "text/x-python",
130 "name": "python",
131 "nbconvert_exporter": "python",
132 "pygments_lexer": "ipython3",
133 "version": "3.4.3"
134 }
135 },
136 "nbformat": 4,
137 "nbformat_minor": 0
138 }