Updated notebooks for new library organisation
[cipher-tools.git] / 2017 / 2017-challenge3.ipynb
index 715c7f2eb5aa66144bf450db4123ec21b8878c0f..29b37cf51fe75b8a6becfa5797c20998563a18f4 100644 (file)
@@ -2,7 +2,7 @@
  "cells": [
   {
    "cell_type": "code",
-   "execution_count": 116,
+   "execution_count": 2,
    "metadata": {},
    "outputs": [],
    "source": [
     "import matplotlib.pyplot as plt\n",
     "%matplotlib inline\n",
     "\n",
-    "from cipherbreak import *\n",
+    "from cipher.caesar import *\n",
+    "from cipher.affine import *\n",
+    "from cipher.polybius import *\n",
+    "from support.text_prettify import *\n",
+    "from support.language_models import *\n",
     "\n",
     "ca = open('3a.ciphertext').read()\n",
     "cb = open('3b.ciphertext').read()"
   },
   {
    "cell_type": "code",
-   "execution_count": 117,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "(24, -2521.8292883073464)"
+       "(24, -2521.8122372384537)"
       ]
      },
-     "execution_count": 117,
+     "execution_count": 3,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -43,7 +47,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 118,
+   "execution_count": 4,
    "metadata": {
     "scrolled": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 119,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "((7, 22, True), -2146.2748427553324)"
+       "((7, 22, True), -2146.240223193519)"
       ]
      },
-     "execution_count": 119,
+     "execution_count": 5,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 120,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 121,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [
     {
        "2163"
       ]
      },
-     "execution_count": 121,
+     "execution_count": 7,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 122,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
        "Counter({'c': 1064, 'd': 1368, 'l': 756, 'm': 566, 'x': 1092})"
       ]
      },
-     "execution_count": 122,
+     "execution_count": 8,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 123,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [
     {
        " ('ll', 45),\n",
        " ('lx', 41),\n",
        " ('md', 36),\n",
-       " ('mx', 27),\n",
        " ('xl', 27),\n",
+       " ('mx', 27),\n",
        " ('lm', 12),\n",
        " ('mc', 5),\n",
        " ('dx', 1)]"
       ]
      },
-     "execution_count": 123,
+     "execution_count": 9,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 183,
+   "execution_count": 10,
    "metadata": {
     "scrolled": true
    },
        "'etoainhsrdlumwycfgpbvkxqz'"
       ]
      },
-     "execution_count": 183,
+     "execution_count": 10,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 184,
+   "execution_count": 11,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "'etoanisrhdlufcmwgbypvkxqz'"
+       "'etoanisrhdlufcmwgybpvkxqz'"
       ]
      },
-     "execution_count": 184,
+     "execution_count": 11,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 185,
+   "execution_count": 12,
    "metadata": {},
    "outputs": [],
    "source": [
   },
   {
    "cell_type": "code",
-   "execution_count": 186,
+   "execution_count": 13,
    "metadata": {},
    "outputs": [
     {
        " 'll',\n",
        " 'lx',\n",
        " 'md',\n",
-       " 'mx',\n",
        " 'xl',\n",
+       " 'mx',\n",
        " 'lm',\n",
        " 'mc',\n",
        " 'dx']"
       ]
      },
-     "execution_count": 186,
+     "execution_count": 13,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 187,
+   "execution_count": 14,
    "metadata": {},
    "outputs": [
     {
        "24"
       ]
      },
-     "execution_count": 187,
+     "execution_count": 14,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 188,
+   "execution_count": 15,
    "metadata": {},
    "outputs": [
     {
        " 'mc': 'X',\n",
        " 'md': 'B',\n",
        " 'ml': 'M',\n",
-       " 'mx': 'P',\n",
+       " 'mx': 'V',\n",
        " 'xc': 'U',\n",
        " 'xd': 'D',\n",
-       " 'xl': 'V',\n",
+       " 'xl': 'P',\n",
        " 'xm': 'E',\n",
        " 'xx': 'O'}"
       ]
      },
-     "execution_count": 188,
+     "execution_count": 15,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 189,
+   "execution_count": 16,
    "metadata": {},
    "outputs": [
     {
        " ...]"
       ]
      },
-     "execution_count": 189,
+     "execution_count": 16,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 190,
+   "execution_count": 17,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "'MHALEATASTIFETHOTSFETNRAFSSETFWTHEYAROLVOTTLEMATHVNFDAUUOOTMOTLARGSTIEETHEHODREATHEITHETINNWSRNITHETOUTAUOLOVALATBTNNPEIUNCETHEHFGERFCEIAUOLDASODPORTOGEYOUEDVBHASOICBMATHNFTTHESFWWNITNYOGIAUNLOORDHASTOLERTEDSUNFTSDEYEOTMNFLDHOPEVEERAREPATOVLEORDMATHATTHELNSSNYVIATORRAOHOPARGIEOLASEDTHOTTHEAUERAMEIEIEODARGHASUNCCFRAUOTANRSOGIAUNLOOIIORGEDTNWLORTYOLSEARYNICOTANROVNFTTHEWLORREDDASWNSATANRNYTINNWSSETTARGOTIOWARTNMHAUHTHEAUERAYELLATASSTALLFRULEOIHNMTHESOPOGETIAVESHODLEOIREDTNDEUAWHEINFIOICBSUNCCFRAUOTANRSOSTHEBHODRNMIATARGNYTHEAINMRHNMEPEIEPEIBOICBHOSATSTIOATNISORDATSEECSLAKELBTNCETHOTNRENICNIENYTHELNUOLTIAVESWENWLETFIREDSNCENRESHEODLNPENICNREBATASOLLTIEOUHEIBVFTTHASOUTTHIEOTEREDTNFRDEICARETHEECWAIESERTAIESBSTECNYSEUFIEUNCCFRAUOTANRTHEUOESOIUAWHEIWEIHOWSCNIETHORINODSHODEROVLEDTHEECWAIETNYFRUTANRSEUFIELBORDATSLNSSMOSODASOSTEITFIRARGTHOTLNSSARTNOPAUTNIBNRTHEVOTTLEYAELDDESEIPEDCNIEIEUNGRATANRTHORATIEUEAPEDWEIHOWSSFETNRAFSREPEIKREMNIWEIHOWSHEYOALEDTNFRDEISTORDTHEUFRRARGNYTHEWLORVFTEATHEIMOBDESWATETHEPAUTNIBOGIAUNLOORDTHERARTHLEGANRIECOAREDARDASGIOUENRHEOIARGTHASREMSULOFDAFSUOESOIOFGFSTFSGEICORAUFSREINECWEINIASSFEDOSEUIETWINULOCOTANRESTOVLASHARGOUAWHEISUHNNLTNDEPELNWOREMSBSTECNYACWEIAOLUAWHEISATMNIKEDARSEUIETYNINPEITMERTBBEOISDEPELNWARGREMCETHNDSTNSEUFIEUNCCFRAUOTANRSOUINSSTHEECWAIESTFDBARGTHEMNIKSNYTHEGIEEKSOGESEFULADORDHBWOTAOORDEPERNLDEIMNIKSYINCORUAERTVOVBLNRTHESUHNNLDEPELNWEDREMMOBSTNSOYEGFOIDUNCCFRAUOTANRSYINCINCESERECAESTHESEREMSBSTECSMEIEMIATTERDNMRORDDASTIAVFTEDARTHEUNDEXNUUFLTNIFCWEIHOWSTHECNSTSTIAUTLBGFOIDEDDNUFCERTAROLLHASTNIBMHERATMOSYAROLLBUNCWLETEDCORBBEOISLOTEITHEECWEINIDNCATAORASSFEDOREXEUFTAPENIDEIMHAUHWIEYOUEDEPEIBUNWBNYTHEUNDEXTHOTATMOSTNVEGFOIDEDVBEPEIBLEGANRTNTHELOSTCORTHEDEYEOTNYTHEAUERAORDTHESFAUADENYVNFDAUUOWEIHOWSWINTEUTEDTHERARTHLEGANRYINCDASSNLFTANROGIAUNLOMOSLOIGELBLEYTTNHASNMRDEPAUESARTHEWINPARUETHNFGHATMOSCODEULEOITNHACTHOTTNIETFIRMNFLDCEOROTVESTDASGIOUEORDOTMNISTDEOTHAROVIEOKMATHTIODATANRTHERARTHIOASEDOREMSTORDOIDTHELEGANRMOSEXALEDARDASGIOUETNERDFIETHEHOIDORDDORGEINFSMNIKNYSFVDFARGTHEUOLEDNRAAARTHEVLEOKMALDEIRESSESNYUOLEDNRAOSFETNRAFSNIDEIEDTHERARTHTNCOIUHTNEVNIOUFCMHAUHTHEBMEIETNCOKETHEAIVOSEYNIIOADSARTNUOLEDNRAOTHEFRSWNKERIEOSNRYNITHEAIEXALEMOSTHOTARTELLAGERUEIEWNITSSFGGESTEDTHOTTHASMOSMHEIETHEBCAGHTYARDTHEAILNSTOQFALOTHNSEMHNMNFLDIEODNRCFSTYNLLNMCBYOATHYFLSLOPETAINMHNYOUESOGIOPETOSKWEIHOWSTHELOIGESTTNDOTEOSHETIOPELSTNUNRUEOLTHEYNFITHUHOWTEINYTHASTIOGAUTOLE'"
+       "'MHALEATASTIFETHOTSFETNRAFSSETFWTHEYAROLPOTTLEMATHPNFDAUUOOTMOTLARGSTIEETHEHODREATHEITHETINNWSRNITHETOUTAUOLOPALATBTNNVEIUNCETHEHFGERFCEIAUOLDASODVORTOGEYOUEDPBHASOICBMATHNFTTHESFWWNITNYOGIAUNLOORDHASTOLERTEDSUNFTSDEYEOTMNFLDHOVEPEERAREVATOPLEORDMATHATTHELNSSNYPIATORRAOHOVARGIEOLASEDTHOTTHEAUERAMEIEIEODARGHASUNCCFRAUOTANRSOGIAUNLOOIIORGEDTNWLORTYOLSEARYNICOTANROPNFTTHEWLORREDDASWNSATANRNYTINNWSSETTARGOTIOWARTNMHAUHTHEAUERAYELLATASSTALLFRULEOIHNMTHESOVOGETIAPESHODLEOIREDTNDEUAWHEINFIOICBSUNCCFRAUOTANRSOSTHEBHODRNMIATARGNYTHEAINMRHNMEVEIEVEIBOICBHOSATSTIOATNISORDATSEECSLAKELBTNCETHOTNRENICNIENYTHELNUOLTIAPESWENWLETFIREDSNCENRESHEODLNVENICNREBATASOLLTIEOUHEIBPFTTHASOUTTHIEOTEREDTNFRDEICARETHEECWAIESERTAIESBSTECNYSEUFIEUNCCFRAUOTANRTHEUOESOIUAWHEIWEIHOWSCNIETHORINODSHODEROPLEDTHEECWAIETNYFRUTANRSEUFIELBORDATSLNSSMOSODASOSTEITFIRARGTHOTLNSSARTNOVAUTNIBNRTHEPOTTLEYAELDDESEIVEDCNIEIEUNGRATANRTHORATIEUEAVEDWEIHOWSSFETNRAFSREVEIKREMNIWEIHOWSHEYOALEDTNFRDEISTORDTHEUFRRARGNYTHEWLORPFTEATHEIMOBDESWATETHEVAUTNIBOGIAUNLOORDTHERARTHLEGANRIECOAREDARDASGIOUENRHEOIARGTHASREMSULOFDAFSUOESOIOFGFSTFSGEICORAUFSREINECWEINIASSFEDOSEUIETWINULOCOTANRESTOPLASHARGOUAWHEISUHNNLTNDEVELNWOREMSBSTECNYACWEIAOLUAWHEISATMNIKEDARSEUIETYNINVEITMERTBBEOISDEVELNWARGREMCETHNDSTNSEUFIEUNCCFRAUOTANRSOUINSSTHEECWAIESTFDBARGTHEMNIKSNYTHEGIEEKSOGESEFULADORDHBWOTAOORDEVERNLDEIMNIKSYINCORUAERTPOPBLNRTHESUHNNLDEVELNWEDREMMOBSTNSOYEGFOIDUNCCFRAUOTANRSYINCINCESERECAESTHESEREMSBSTECSMEIEMIATTERDNMRORDDASTIAPFTEDARTHEUNDEXNUUFLTNIFCWEIHOWSTHECNSTSTIAUTLBGFOIDEDDNUFCERTAROLLHASTNIBMHERATMOSYAROLLBUNCWLETEDCORBBEOISLOTEITHEECWEINIDNCATAORASSFEDOREXEUFTAVENIDEIMHAUHWIEYOUEDEVEIBUNWBNYTHEUNDEXTHOTATMOSTNPEGFOIDEDPBEVEIBLEGANRTNTHELOSTCORTHEDEYEOTNYTHEAUERAORDTHESFAUADENYPNFDAUUOWEIHOWSWINTEUTEDTHERARTHLEGANRYINCDASSNLFTANROGIAUNLOMOSLOIGELBLEYTTNHASNMRDEVAUESARTHEWINVARUETHNFGHATMOSCODEULEOITNHACTHOTTNIETFIRMNFLDCEOROTPESTDASGIOUEORDOTMNISTDEOTHAROPIEOKMATHTIODATANRTHERARTHIOASEDOREMSTORDOIDTHELEGANRMOSEXALEDARDASGIOUETNERDFIETHEHOIDORDDORGEINFSMNIKNYSFPDFARGTHEUOLEDNRAAARTHEPLEOKMALDEIRESSESNYUOLEDNRAOSFETNRAFSNIDEIEDTHERARTHTNCOIUHTNEPNIOUFCMHAUHTHEBMEIETNCOKETHEAIPOSEYNIIOADSARTNUOLEDNRAOTHEFRSWNKERIEOSNRYNITHEAIEXALEMOSTHOTARTELLAGERUEIEWNITSSFGGESTEDTHOTTHASMOSMHEIETHEBCAGHTYARDTHEAILNSTOQFALOTHNSEMHNMNFLDIEODNRCFSTYNLLNMCBYOATHYFLSLOVETAINMHNYOUESOGIOVETOSKWEIHOWSTHELOIGESTTNDOTEOSHETIOVELSTNUNRUEOLTHEYNFITHUHOWTEINYTHASTIOGAUTOLE'"
       ]
      },
-     "execution_count": 190,
+     "execution_count": 17,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 192,
+   "execution_count": 18,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "'while it is true that suetonius setup the final battle with boudicca at watling street he had neither the troops nor the tactical ability to overcome the huge numerical disadvantage faced by his army without the support of agricola and his talented scouts defeat would have been inevitable and with it the loss of britannia having realised that the iceni were reading his communications agricola arranged to plant false information about the planned disposition of troops setting a trap into which the iceni fell it is still unclear how the savage tribes had learned to decipher our army s communications as they had no writing of their own however every army has its traitors and it seems likely to me that one or more of the local tribespeople turned someones head love or money it is all treachery but this act threatened to undermine the empires entire system of secure communication the caesar cipher perhaps more than roads had enabled the empire to function securely and its loss was a disaster turning that loss into a victory on the battlefield deserved more recognition than it received perhaps suetonius never knew or perhaps he failed to understand the cunning of the plan but either way despite the victory agricola and the ninth legion remained in disgrace on hearing this news claudius caesar augustus germanicus nero emperor issued a secret proclamation establishing a cipher school to develop a new system of imperial ciphers it worked in secret for over twenty years developing new methods to secure communications across the empire studying the works of the greeks ages euclid and hypatia and even older works from ancient babylon the school developed new ways to safeguard communications from rome s enemies these new systems were written down and distributed in the codex occult orum perhaps the most strictly guarded document in all history when it was finally completed many years later the emperor domitian issued an executive order which prefaced every copy of the codex that it was to be guarded by every legion to the last man the defeat of the iceni and the suicide of boudicca perhaps protected the ninth legion from dissolution agricola was largely left to his own devices in the province though it was made clear to him that to return would mean at best disgrace and at worst death in a break with tradition the ninth raised a new standard the legion was exiled in disgrace to endure the hard and dangerous work of subduing the caledon ii in the bleak wildernesses of caledonia suetonius ordered the ninth to march toe bora cum which they were to make their base for raids into caledonia the unspoken reason for their exile was that intelligence reports suggested that this was where they might find their lost aquila those who would read on must follow my faithful slave tiro who faces a grave task perhaps the largest to date a she travels to conceal the fourth chapter of this tragic tale'"
+       "'while it is true that suetonius setup the final vat tle with vou di ccaat watling street he had neither the troops nor the tactical avi lity to ober come the huge numerical disad ban tage faced vy his army without the support of agricola and his talented scouts defeat would habe veen in ebita vle and with it the loss of vr it anni ahab ing realised that the iceni were reading his communications agricola arranged to plant false information av out the planned disposition of troops setting a trap into which the iceni fell it is still unclear how the saba get rives had learned to decipher our army s communications as they had no writing of their own howe be reber y army has its traitors and it seems likely to me that one or more of the local t rives people turned someones head lobe or money it is all treachery vut this act threatened to undermine the empires entire system of secure communication the caesar cipher perhaps more than road shade nav led the empire to function securely and its loss was a disaster turning that loss into a bic tory on the vat tle field deser bed more recognition than it recei bed perhaps suetonius ne berk new or perhaps he failed to understand the cunning of the plan vut either way despite the bic tory agricola and the ninth legion remained in disgrace on hearing this news claudius caesar augustus germanicus nero emperor issued a secret proclamation est av lishing a cipher school to de belo pa new system of imperial ciphers it worked in secret for ober twenty years deb eloping new methods to secure communications across the empire studying the works of the greeks ages euclid and hypatia and eben older works from ancient vav yl on the school deb eloped new ways to safeguard communications from rome s enemies these new systems were written down and distri vu ted in the codex occult orum perhaps the most strictly guarded document in all history when it was finally completed many years later the emperor domitian issued an execut i be order which preface de bery copy of the codex that it was to ve guarded vye bery legion to the last man the defeat of the iceni and the suicide of vou dic ca perhaps protected the ninth legion from dissolution agricola was largely left to his own debi ces in the prob in ce though it was made clear to him that to return would mean at vest disgrace and at worst death in av reak with tradition the ninth raised a new standard the legion was exiled in disgrace to endure the hard and dangerous work of suv du ing the caledon ii in the v leak wildernesses of caledonia suetonius ordered the ninth to march to evora cum which they were to make their vase for raids into caledonia the unspoken reason for their exile was that intelligence reports suggested that this was where they might find their lost aquila those who would read on must follow my faithful sla be tiro who faces agra be task perhaps the largest to date a she trabel s to conceal the fourth chapter of this tragic tale'"
       ]
      },
-     "execution_count": 192,
+     "execution_count": 18,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 193,
+   "execution_count": 27,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "2922"
+       "2969"
       ]
      },
-     "execution_count": 193,
+     "execution_count": 27,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "open('3b.plaintext', 'w').write(wcat(segment(scbpt.translate(tt))))"
+    "open('3b.plaintext', 'w').write(prettify(scbpt.translate(tt)))"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 194,
+   "execution_count": 20,
    "metadata": {},
    "outputs": [
     {
        " 'Y': 'f'}"
       ]
      },
-     "execution_count": 194,
+     "execution_count": 20,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 195,
+   "execution_count": 21,
    "metadata": {},
    "outputs": [
     {
        " 'mc': 'x',\n",
        " 'md': 'y',\n",
        " 'ml': 'w',\n",
-       " 'mx': 'v',\n",
+       " 'mx': 'b',\n",
        " 'xc': 'c',\n",
        " 'xd': 'd',\n",
-       " 'xl': 'b',\n",
+       " 'xl': 'v',\n",
        " 'xm': 'e',\n",
        " 'xx': 'a'}"
       ]
      },
-     "execution_count": 195,
+     "execution_count": 21,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 196,
+   "execution_count": 22,
    "metadata": {},
    "outputs": [],
    "source": [
   },
   {
    "cell_type": "code",
-   "execution_count": 197,
+   "execution_count": 23,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "abcde\n",
+      "avcde\n",
       "fghik\n",
       "lmnop\n",
       "qrstu\n",
-      "vwxy\n"
+      "bwxy\n"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 198,
+   "execution_count": 24,
    "metadata": {},
    "outputs": [],
    "source": [
   },
   {
    "cell_type": "code",
-   "execution_count": 199,
+   "execution_count": 25,
    "metadata": {},
    "outputs": [
     {
-     "data": {
-      "text/plain": [
-       "'while it is true that suetonius setup the final battle with boudicca at watling street he had neither the troops nor the tactical ability to overcome the huge numerical disadvantage faced by his army without the support of agricola and his talented scouts defeat would have been inevitable and with it the loss of britannia having realised that the iceni were reading his communications agricola arranged to plant false information about the planned disposition of troops setting a trap into which the iceni fell it is still unclear how the savage tribes had learned to decipher our army s communications as they had no writing of their own however every army has its traitors and it seems likely to me that one or more of the local tribespeople turned someones head love or money it is all treachery but this act threatened to undermine the empires entire system of secure communication the caesar cipher perhaps more than roads had enabled the empire to function securely and its loss was a disaster turning that loss into a victory on the battlefield deserved more recognition than it received perhaps suetonius never knew or perhaps he failed to understand the cunning of the plan but either way despite the victory agricola and the ninth legion remained in disgrace on hearing this news claudius caesar augustus germanicus nero emperor issued a secret proclamation establishing a cipher school to develop a new system of imperial ciphers it worked in secret for over twenty years developing new methods to secure communications across the empire studying the works of the greeks ages euclid and hypatia and even older works from ancient babylon the school developed new ways to safeguard communications from rome s enemies these new systems were written down and distributed in the codex occult orum perhaps the most strictly guarded document in all history when it was finally completed many years later the emperor domitian issued an executive order which prefaced every copy of the codex that it was to be guarded by every legion to the last man the defeat of the iceni and the suicide of boudicca perhaps protected the ninth legion from dissolution agricola was largely left to his own devices in the province though it was made clear to him that to return would mean at best disgrace and at worst death in a break with tradition the ninth raised a new standard the legion was exiled in disgrace to endure the hard and dangerous work of subduing the caledon ii in the bleak wildernesses of caledonia suetonius ordered the ninth to march toe bora cum which they were to make their base for raids into caledonia the unspoken reason for their exile was that intelligence reports suggested that this was where they might find their lost aquila those who would read on must follow my faithful slave tiro who faces a grave task perhaps the largest to date a she travels to conceal the fourth chapter of this tragic tale'"
-      ]
-     },
-     "execution_count": 199,
-     "metadata": {},
-     "output_type": "execute_result"
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "while it is true that suetonius setup the final battle with boudicca at watling street he had\n",
+      "neither the troops nor the tactical ability to overcome the huge numerical disadvantage faced by his\n",
+      "army without the support of agricola and his talented scouts defeat would have been inevitable and\n",
+      "with it the loss of britannia having realised that the iceni were reading his communications\n",
+      "agricola arranged to plant false information about the planned disposition of troops setting a trap\n",
+      "into which the iceni fell it is still unclear how the savage tribes had learned to decipher our army\n",
+      "s communications as they had no writing of their own however every army has its traitors and it\n",
+      "seems likely to me that one or more of the local tribespeople turned someones head love or money it\n",
+      "is all treachery but this act threatened to undermine the empires entire system of secure\n",
+      "communication the caesar cipher perhaps more than roads had enabled the empire to function securely\n",
+      "and its loss was a disaster turning that loss into a victory on the battlefield deserved more\n",
+      "recognition than it received perhaps suetonius never knew or perhaps he failed to understand the\n",
+      "cunning of the plan but either way despite the victory agricola and the ninth legion remained in\n",
+      "disgrace on hearing this news claudius caesar augustus germanicus nero emperor issued a secret\n",
+      "proclamation establishing a cipher school to develop a new system of imperial ciphers it worked in\n",
+      "secret for over twenty years developing new methods to secure communications across the empire\n",
+      "studying the works of the greeks ages euclid and hypatia and even older works from ancient babylon\n",
+      "the school developed new ways to safeguard communications from rome s enemies these new systems were\n",
+      "written down and distributed in the codex occult orum perhaps the most strictly guarded document in\n",
+      "all history when it was finally completed many years later the emperor domitian issued an executive\n",
+      "order which prefaced every copy of the codex that it was to be guarded by every legion to the last\n",
+      "man the defeat of the iceni and the suicide of boudicca perhaps protected the ninth legion from\n",
+      "dissolution agricola was largely left to his own devices in the province though it was made clear to\n",
+      "him that to return would mean at best disgrace and at worst death in a break with tradition the\n",
+      "ninth raised a new standard the legion was exiled in disgrace to endure the hard and dangerous work\n",
+      "of subduing the caledon ii in the bleak wildernesses of caledonia suetonius ordered the ninth to\n",
+      "march toe bora cum which they were to make their base for raids into caledonia the unspoken reason\n",
+      "for their exile was that intelligence reports suggested that this was where they might find their\n",
+      "lost aquila those who would read on must follow my faithful slave tiro who faces a grave task\n",
+      "perhaps the largest to date a she travels to conceal the fourth chapter of this tragic tale\n"
+     ]
     }
    ],
    "source": [
-    "wcat(segment(polybius_decipher(scb, '', order, order)))"
+    "print(prettify(polybius_decipher(scb, '', order, order)))"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 200,
+   "execution_count": 26,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "True"
+       "False"
       ]
      },
-     "execution_count": 200,
+     "execution_count": 26,
      "metadata": {},
      "output_type": "execute_result"
     }
    "name": "python",
    "nbconvert_exporter": "python",
    "pygments_lexer": "ipython3",
-   "version": "3.5.3"
+   "version": "3.6.3"
   }
  },
  "nbformat": 4,