Updated notebooks for new library organisation
[cipher-tools.git] / 2016 / 2016-challenge4.ipynb
index c8bb5a481608166fdd8b28869cd3227f2142720f..26cdb083b3405e52a8cbfc25a8d06edd70e938b0 100644 (file)
@@ -3,9 +3,7 @@
   {
    "cell_type": "code",
    "execution_count": 1,
-   "metadata": {
-    "collapsed": true
-   },
+   "metadata": {},
    "outputs": [],
    "source": [
     "import os,sys,inspect\n",
     "import matplotlib.pyplot as plt\n",
     "%matplotlib inline\n",
     "\n",
-    "from cipherbreak import *\n",
+    "from cipher.keyword_cipher import *\n",
+    "from cipher.column_transposition import *\n",
+    "from support.utilities import *\n",
+    "from support.text_prettify import *\n",
     "\n",
     "c4a = open('4a.ciphertext').read()\n",
     "c4b = open('4b.ciphertext').read()"
@@ -25,9 +26,7 @@
   {
    "cell_type": "code",
    "execution_count": 2,
-   "metadata": {
-    "collapsed": false
-   },
+   "metadata": {},
    "outputs": [
     {
      "data": {
@@ -47,9 +46,7 @@
   {
    "cell_type": "code",
    "execution_count": 3,
-   "metadata": {
-    "collapsed": false
-   },
+   "metadata": {},
    "outputs": [
     {
      "data": {
@@ -70,9 +67,7 @@
   {
    "cell_type": "code",
    "execution_count": 4,
-   "metadata": {
-    "collapsed": false
-   },
+   "metadata": {},
    "outputs": [
     {
      "name": "stdout",
   },
   {
    "cell_type": "code",
-   "execution_count": 2,
-   "metadata": {
-    "collapsed": false
-   },
+   "execution_count": 5,
+   "metadata": {},
    "outputs": [
     {
      "data": {
@@ -99,7 +92,7 @@
        "'tetheabmpnpskirytetfalulnhtdiiewnkhaeavrcleahecanoiufblgndiatssyeahmttlucodutacapyllrneevtemsooehftacattkehstksieytraohvtteshgierhtntiegilleaenctrethittghinamedgaflirotfaoictnofberiteislotoatitehwkinerncaeylalhtpelhegeansecicdloubawesmwdpeiafthllaseessrtofrouireltilanggtiorhsamhtreobeylalstrmabhtuteahntthwisaaetwrooegdiratghthtetstedpaatdorspvdeidiamsazlginyatdeiadlenkadmemtsiuaechstrieotesehtaeptsneritndokhwnooehwtylucodevhagosotmihucnmrfoanotiatuboplpeoetearhtseyognrieyrvetgnhiplpeoenodolieinnreevtguhohehtwnteisonoutaidphnhtmaeitmachpalyscsitithatlucoddaletmoosenithghtwisihucmidmeamitepitacslltilceovolosmoubgytretheraiseubalzppzalgnyiwwthaeralenuoedterheanytdaaxminacdinletbiheevocuwlkmayitvaohesithoroppttiunytemeiiwngtmohsefeonricomtleadlihetsetafrnonoillwityleloroumeetlarkoloiofngrdrwateeosioynguiaagnnosomitarn'"
       ]
      },
-     "execution_count": 2,
+     "execution_count": 5,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
-   "metadata": {
-    "collapsed": false
-   },
+   "execution_count": 6,
+   "metadata": {},
    "outputs": [],
    "source": [
     "transpositions[transpositions_of('edgarallenpoe')] += ['edgarallenpoe']"
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
-   "metadata": {
-    "collapsed": false
-   },
+   "execution_count": 7,
+   "metadata": {},
    "outputs": [
     {
      "data": {
        "(((3, 2, 0, 1, 4), False, False), -1959.882702003483)"
       ]
      },
-     "execution_count": 4,
+     "execution_count": 7,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
-   "metadata": {
-    "collapsed": false
-   },
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "'the temp bank is pretty full and i think we have a real chance of building a system that could actually prevent some of the attacks the key is to harvest the right intelligence at the right time and flag it for action before it is too late i think we can really help the agencies could be swamped with false alerts so our filtering algorithm has to be really smart but then that is what we are good at right the test data pds provided is amazingly detailed and makes it much easier to see the patterns i dont know how they could have got so much information about people are they storing everything people do online in ever thought when i set out on a phd in mathematical physics that it could lead to something with such immediate impact i still love cosmology but there is a real buzz applying what we learned out here at dynamix and icant believe how lucky i am to have this opportunity meeting with someone from citadelle this afternoon i will tell you more later looking forward to seeing you again soon martin'"
-      ]
-     },
-     "execution_count": 6,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "wcat(segment(column_transposition_decipher(c4br, (3, 2, 0, 1, 4), False, False)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 7,
-   "metadata": {
-    "collapsed": false
-   },
+   "execution_count": 9,
+   "metadata": {},
    "outputs": [
     {
      "data": {
        " 'indianans']"
       ]
      },
-     "execution_count": 7,
+     "execution_count": 9,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
-   "metadata": {
-    "collapsed": false
-   },
+   "execution_count": 10,
+   "metadata": {},
    "outputs": [
     {
      "data": {
        "(3, 1, 0, 2, 4)"
       ]
      },
-     "execution_count": 8,
+     "execution_count": 10,
      "metadata": {},
      "output_type": "execute_result"
     }
     "transpositions_of('edgar')"
    ]
   },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "(0, 3, 4, 2, 1)"
+      ]
+     },
+     "execution_count": 16,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "transpositions_of('dupin')"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 17,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'the temp bank is pretty full and i think we have a real chance of building a system that could actually prevent some of the attacks the key is to harvest the right intelligence at the right time and flag it for action before it is too late i think we can really help the agencies could be swamped with false alerts so our filtering algorithm has to be really smart but then that is what we are good at right the test data pds provided is amazingly detailed and makes it much easier to see the patterns i dont know how they could have got so much information about people are they storing everything people do online in ever thought when i set out on a phd in mathematical physics that it could lead to something with such immediate impact i still love cosmology but there is a real buzz applying what we learned out here at dynamix and icant believe how lucky i am to have this opportunity meeting with someone from citadelle this afternoon i will tell you more later looking forward to seeing you again soon martin'"
+      ]
+     },
+     "execution_count": 17,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "wcat(segment(column_transposition_decipher(c4br, 'debar', False, False)))"
+   ]
+  },
   {
    "cell_type": "code",
    "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
+   "metadata": {},
    "outputs": [],
    "source": []
   }
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.5.2"
+   "version": "3.6.3"
   }
  },
  "nbformat": 4,