Fixed typo in docstring
[cipher-tools.git] / 2017 / 2017-challenge5.ipynb
index 39f3f8ff165b71f4c8771fd681975f67fcf6af2e..214034c35df882d3d6b95cf25dfbd858af41537c 100644 (file)
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 50,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "('decoyzabfghijklmnpqrstuvwx', -4117.559010215594)"
+      ]
+     },
+     "execution_count": 50,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "cipher_alphabet, score = simulated_annealing_break(\n",
+    "    sca_text, workers=12,\n",
+    "    initial_temperature=200, max_iterations=20000, \n",
+    "#     plain_alphabet=cat(ltrs), cipher_alphabet=cat(ctls),\n",
+    "    fitness=Ptrigrams)\n",
+    "cipher_alphabet, score"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 51,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "maryam jodie has gone i arrived in selcuk as planned but she didnt make the rendezvous the local\n",
+      "station think she may have been kidnapped but there has been no ransom demand and there is nothing\n",
+      "much to go on her room had been ransacked and she left no message but something tells me she is ok\n",
+      "and we should move on i think she may have planned this meanwhile i have the document jodie wanted\n",
+      "from london i dont know how she knew but the fifth chapter was hidden in a cavity in a stone lintel\n",
+      "in some remains in the ephesus room at the british museum it was encrypted using another poly\n",
+      "alphabetic cipher invented in the nineteenth century i asked the museum to test it and the document\n",
+      "is authentic so i guess the imperial cipher school really had moved on perhaps i shouldnt have been\n",
+      "surprised after the discovery at bodrum but it leaves me wondering what else they developed one odd\n",
+      "feature was a frieze running round three sides of the lintel consisting of a single row of\n",
+      "blackandwhite tiles that the museum think were added in the roman period they read in sequence\n",
+      "wwbbwwwbwwwbwwwbwwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb www bbw\n",
+      "wwbw wbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwbw bwbwbwbwbwbwbwbwbwwb www\n",
+      "bwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb bbwbbbwbbbwbbbwbbbwb wwwb wwwb wwwb\n",
+      "wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb www\n",
+      "www www www www www www www www www www www www www www www www www www www www www www www www wwbw\n",
+      "wwbw www www www www www www www www www www www www www www www www www www www www www www www www\n",
+      "www wwwb wwwb www wb wwwb bbw wwww bbb wwwb wwwb wwwb www bw www bbb wwbw wwbw bbb www bbbb\n",
+      "wwbbbwwwbbbwwbbbwb www bwwwwbwbwwbwwbwwwbww www bwbwwbbwwbwwbwbwwwwb www bbw bbw\n",
+      "bwwbwwbwwwwwbwwbwwwb www wb www bwwwbwwbwwwbwbwwwbwb www wwbwwwbwbwbwbwbwwwb www bwwwbwbwbwbwwbwwbww\n",
+      "www bwwwbwwbwwwwbwwbwwwb www bbb bbw bbbb wwbw wwww bbb bbw bwbwbwbbbbbwwwbwwwbw wwbw bbbb ww bbb\n",
+      "www bbbb wwwb www wb www bwwwbwwbwwwbwbwbwwwb www wwbwwwbwbwbwbwbwwwb wwwb wwwb www bwb www wwbw\n",
+      "wwww bwbwwwwbwwwwbwwbwwwb www bwwwbwbwwbwwwbwwwwb www bwbwwbbwbwwwbwwwb wwwb www bwb www wwbw www wb\n",
+      "wwbw wwbw www bwwwbwwwbwwbwwwbwb wwwb www bbb wbwwwbwbwwwbwbwwwbww bbb wwbw wwbw bww www bbbb wwbw\n",
+      "wwbwbbbwwbbbwbwwwbww www www www www www www www www www www www www www www www www www www www www\n",
+      "www www www www www wwbw wwbw www www www www www www www www www www www www www www www www www\n",
+      "www www www www www www www www wbwwwbwbwwwbwwwbwwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb\n",
+      "wwwb wwwb wwwb wwwb wwwb wwwb www bwb www bwbwbwbwbwbwbwbwbwb wbwbwbwbwbwbwbwbwbwb\n",
+      "wbwbwbwbwbwbwbwbwbwb wbwbwbwbwbwbwbwbwbwb www bwwbbbwbbbwbbbwbbbwb bbw bbb wbbbwbbbwbbbwbbbwb bbw\n",
+      "bbb wbbbwbbbwbbbwbbbwb bbwbbbwbbbwwbwwwbwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb wwwb\n",
+      "wwwb wwwb wwwb www bwwwbwwwbwwwbwwbwwi have used b for the black tiles and w for the white ones it\n",
+      "took me a while to figure out that the frieze is steganography concealing the keyword for the cipher\n",
+      "in chapter five without jodie i am not sure where to go next there are only two possibilities as far\n",
+      "as i can see but i have no idea where one of them is and as far as i can tell no one else knows\n",
+      "either so i guess i will head for olympia see you there\n"
+     ]
+    }
+   ],
+   "source": [
+    "cipher_translation = ''.maketrans(cipher_alphabet, string.ascii_lowercase)\n",
+    "print(lcat(tpack(segment(sanitise(ca).translate(cipher_translation)))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 16,
    "metadata": {},
    "outputs": [
     {
        "'etoainhsrdlumwycfgpbvkxjqz'"
       ]
      },
-     "execution_count": 9,
+     "execution_count": 16,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 17,
    "metadata": {},
    "outputs": [
     {
        "'yrkfdlbqpoisjcumzeathwxgvn'"
       ]
      },
-     "execution_count": 10,
+     "execution_count": 17,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 18,
    "metadata": {},
    "outputs": [
     {
        " 'Z': 'f'}"
       ]
      },
-     "execution_count": 11,
+     "execution_count": 18,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 19,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": 20,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": 21,
    "metadata": {},
    "outputs": [
     {
        " 'Z': 'f'}"
       ]
      },
-     "execution_count": 14,
+     "execution_count": 21,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 15,
+   "execution_count": 22,
    "metadata": {},
    "outputs": [
     {
        " 'z': 'X'}"
       ]
      },
-     "execution_count": 15,
+     "execution_count": 22,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
+   "execution_count": 23,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 17,
+   "execution_count": 24,
    "metadata": {},
    "outputs": [
     {
        "3362"
       ]
      },
-     "execution_count": 17,
+     "execution_count": 24,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 18,
+   "execution_count": 25,
    "metadata": {},
    "outputs": [],
    "source": [
   },
   {
    "cell_type": "code",
-   "execution_count": 19,
+   "execution_count": 26,
    "metadata": {},
    "outputs": [
     {
        "1577"
       ]
      },
-     "execution_count": 19,
+     "execution_count": 26,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 20,
+   "execution_count": 27,
    "metadata": {},
    "outputs": [
     {
        "1577"
       ]
      },
-     "execution_count": 20,
+     "execution_count": 27,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 21,
+   "execution_count": 49,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "['  **   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   **  ',\n",
-       " ' *  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  * ',\n",
-       " '  * *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *  ',\n",
-       " ' *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   * ',\n",
-       " '  *                                                                             *  ',\n",
-       " ' *                                                                               * ',\n",
-       " '  *    *   ***     ***   *   *   *   *    ***  *   * ***   ****  ***   ***  *** *  ',\n",
-       " ' *    * *  *  *   *     * *  **  *  * *    *   ** ** *  *  *     *  *   *    *   * ',\n",
-       " '  *  *   * *   * *     *   * * * * *   *   *   * * * *  *  *     *   *  *    *  *  ',\n",
-       " ' *   ***** ****  *     ***** * * * *****   *   *   * ****  ***   ****   *    *   * ',\n",
-       " '  *  *   * * *   *     *   * * * * *   *   *   *   * *     *     * *    *    *  *  ',\n",
-       " ' *   *   * *  *   *    *   * *  ** *   *   *   *   * *     *     *  *   *    *   * ',\n",
-       " '  *  *   * *   *   *** *   * *   * *   *  ***  *   * *     ****  *   * ***  *** *  ',\n",
-       " ' *                                                                               * ',\n",
-       " '  *                                                                             *  ',\n",
-       " ' * *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   * * ',\n",
-       " '  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *  ',\n",
-       " ' *  *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** *** ***  * ',\n",
-       " '  *  *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *   *  *  ']"
+       "['  ⌷⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷⌷  ',\n",
+       " ' ⌷  ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷  ⌷ ',\n",
+       " '  ⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷  ',\n",
+       " ' ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷ ',\n",
+       " '  ⌷                                                                             ⌷  ',\n",
+       " ' ⌷                                                                               ⌷ ',\n",
+       " '  ⌷    ⌷   ⌷⌷⌷     ⌷⌷⌷   ⌷   ⌷   ⌷   ⌷    ⌷⌷⌷  ⌷   ⌷ ⌷⌷⌷   ⌷⌷⌷⌷  ⌷⌷⌷   ⌷⌷⌷  ⌷⌷⌷ ⌷  ',\n",
+       " ' ⌷    ⌷ ⌷  ⌷  ⌷   ⌷     ⌷ ⌷  ⌷⌷  ⌷  ⌷ ⌷    ⌷   ⌷⌷ ⌷⌷ ⌷  ⌷  ⌷     ⌷  ⌷   ⌷    ⌷   ⌷ ',\n",
+       " '  ⌷  ⌷   ⌷ ⌷   ⌷ ⌷     ⌷   ⌷ ⌷ ⌷ ⌷ ⌷   ⌷   ⌷   ⌷ ⌷ ⌷ ⌷  ⌷  ⌷     ⌷   ⌷  ⌷    ⌷  ⌷  ',\n",
+       " ' ⌷   ⌷⌷⌷⌷⌷ ⌷⌷⌷⌷  ⌷     ⌷⌷⌷⌷⌷ ⌷ ⌷ ⌷ ⌷⌷⌷⌷⌷   ⌷   ⌷   ⌷ ⌷⌷⌷⌷  ⌷⌷⌷   ⌷⌷⌷⌷   ⌷    ⌷   ⌷ ',\n",
+       " '  ⌷  ⌷   ⌷ ⌷ ⌷   ⌷     ⌷   ⌷ ⌷ ⌷ ⌷ ⌷   ⌷   ⌷   ⌷   ⌷ ⌷     ⌷     ⌷ ⌷    ⌷    ⌷  ⌷  ',\n",
+       " ' ⌷   ⌷   ⌷ ⌷  ⌷   ⌷    ⌷   ⌷ ⌷  ⌷⌷ ⌷   ⌷   ⌷   ⌷   ⌷ ⌷     ⌷     ⌷  ⌷   ⌷    ⌷   ⌷ ',\n",
+       " '  ⌷  ⌷   ⌷ ⌷   ⌷   ⌷⌷⌷ ⌷   ⌷ ⌷   ⌷ ⌷   ⌷  ⌷⌷⌷  ⌷   ⌷ ⌷     ⌷⌷⌷⌷  ⌷   ⌷ ⌷⌷⌷  ⌷⌷⌷ ⌷  ',\n",
+       " ' ⌷                                                                               ⌷ ',\n",
+       " '  ⌷                                                                             ⌷  ',\n",
+       " ' ⌷ ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷ ⌷ ',\n",
+       " '  ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷ ⌷  ',\n",
+       " ' ⌷  ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷ ⌷⌷⌷  ⌷ ',\n",
+       " '  ⌷  ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷   ⌷  ⌷  ']"
       ]
      },
-     "execution_count": 21,
+     "execution_count": 49,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "tt = ''.maketrans({'w': ' ', 'b': '*'})\n",
+    "tt = ''.maketrans({'w': ' ', 'b': ''})\n",
     "chunks(bkeyt.translate(tt), 83)"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 22,
+   "execution_count": 29,
    "metadata": {},
    "outputs": [],
    "source": [
   },
   {
    "cell_type": "code",
-   "execution_count": 23,
+   "execution_count": 30,
    "metadata": {},
    "outputs": [
     {
        "('fwruffnquevmp', -1750.4576000271347)"
       ]
      },
-     "execution_count": 23,
+     "execution_count": 30,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 24,
+   "execution_count": 31,
    "metadata": {},
    "outputs": [
     {
        "'nieyqmhcenwlqvchdporosweiohtsshreoihpsvrvusdcostmjezkdeytdhrtasupknropbklngeutgnssthjhhnowgbdwvucncdvofhbdltfpvobiuicirayodpwkpoutibtgcenuhpwachchnbrjydhsfvhqszeuvdcpswatvzmxhsiigkobvcagqcdikfstrvkfggbdkvcvstuvufienwiniasbcecmvdwemkwgtnsyjridowjamhuhnrvxssgewikqxpxhashvwvteulpavioctweavlhtikkkximoikdloikrwswfiojrynulrsgtoktknqcporlruoigivdpeddhrntdmrnucnrioiuetpdnftaipjrewjqtercxzvydhiswrtrneonknnfsyrifcdhedoweptjrechehcptdcehirohbcpniloorntrrrtohgeoandszehilxywfqkrgnphglvcojfbetcietpqmfetkalnahiwixdppersmrihrctseahkhtifbokasoozrjgvvkehjsufarunbrtiswzdmriwcrovhdsdeihdteiiustmjupvkhdiisibjloyrdpyxkusdlwfpsehvevdoiudppehzgvcewnhifrvkfggbdkbidptartnotloihpseehrdipeotmlwbcousicucctsktsrlritcanhpdmrehuinioiuuwirsxtanvjshfwyrkacfihfctdipytegvprdowhfldhycrqhfctswdbnagevitctsufsrofoccprycjgnifeikrthnowgcedfedjwiisdtihszeecfvlwjqgehoeicssaqflthagmncpvvifnreneoiioiulytddhuhkrtzsdpevphodehkctsvfhltophksiepsgcohnrnuseajettlhdwhiepjwcenbtbuecihpijncohouidiqjikpovimvsrfridohvchdporhrmhlpnikpacvjiswwgszeyxrcpragclkvxbporlruoigoviferifridicrskiporsyypwgprszenephnicczvttucvqesuiivqleesvfrhcfgchuswrocjslotcnxtiiswkoieatruninitradpaortylcouoahdpehgukcvlrmrafrntaovetrxvyinpenvniquglltisxgy'"
       ]
      },
-     "execution_count": 24,
+     "execution_count": 31,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 25,
+   "execution_count": 32,
    "metadata": {},
    "outputs": [
     {
        "('arcanaimperii', -1506.8637359274674)"
       ]
      },
-     "execution_count": 25,
+     "execution_count": 32,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 26,
+   "execution_count": 33,
    "metadata": {},
    "outputs": [
     {
        "'inhisjournaldatedtheidesofoctoberintheyearoftheconsulshipsofcaeceliustulliuscapitopomponianusplotiusfirmusandgaiuscorneliusgallicanusagricolawrotethemysteryofthebattleatcamulodonumisatlastsolvedcalgacusmaybeabarbariannowbuthewasaromancitizenthenwhobetrayedusallforloveofabarbarianithastakenallmyskillsasaleaderofmentokeephimalivethelegionnairesspendtheireveningsdesigningnewandcruelwaystoexecutehiminrevengefortheshamehebroughtuponusbuthislifeispreciousitistheonlycardlefttoplayinoursearchforsalvationandthereturnofthestolenaquilaeifwecanalsorecoverthecodexthenperhapsitslosscanbeconcealedandourliveswillbesparedreleasingtheromantraitorcalgacusmusthavestuckintheproudagricolasthroatbuthemadeapactwiththeremainingcaledoniiandtravellednorthtoexchangetheprisonerfortheaquilaeandthecodexbutthecunningcaledoniantribesmansetanothertrapandpresentedagricolawithaforgerycunninglyassembledwithpagesfromthebooksstolenwhenthetriberansackedmonsgraupiusfortoolongthesonsofromehadunderestimatedthepeopleinbritanniaandwhiletheaquilaofthelegionhadbeenrestoredbytheexchangetheirhonourwasnotagricolafacedareturntoromehumiliationandalmostcertaindeaththesixthchapterofmytaleofwoeisguardedbylightningbullandoak'"
       ]
      },
-     "execution_count": 26,
+     "execution_count": 33,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 27,
+   "execution_count": 34,
    "metadata": {},
    "outputs": [
     {
        "'a'"
       ]
      },
-     "execution_count": 27,
+     "execution_count": 34,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 28,
+   "execution_count": 35,
    "metadata": {},
    "outputs": [
     {
        "'zyxwvutsrqponmlkjihgfedcba'"
       ]
      },
-     "execution_count": 28,
+     "execution_count": 35,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 29,
+   "execution_count": 36,
    "metadata": {},
    "outputs": [
     {
        "'hveheifhbiicuzbbcfgvvnzafwnkqnndivxopvpdionrsyrmjvjlkaehbrfsmvmtvkqrrftcyspatroqqnbndcyiqretamkaszhcaqidtaxmpfrvenkfimmihgrxnvgqtrmcpzsqzpygininbbstddlcomipnnqgqargdgmrkbijtxnubxpuzjzbizesjbvqmutztdzotjzktjvraioamqznxiwnstbedizjnbjurebqqhldegrzvnynjbsdzprnparcknlqxnmryaisrqjxquzevdcijkzsbmmkczinszckaxrmkvnnzzfwlmksajvrzcqdrkqsdfgvyobqfemifqqrjcoilkydqodhdevxbauvrqdmumxaorieubzrdxvrlcowvodkrsqgzzsizvmdvddrnigrzayrlmednqfhqcblgnvrrntkusntzwdqpoddtvypazkhaqgqneyixiiukmcsfngyktqeftzpdmqtupjzjrkdxsunenxybyvqmqtdmfsdcmjkntbmmplvvvmzwvmzzzzcfymmtfumostdtbnzfkydvmddgrccdbjcnapbmmsrmjvtvztbcmmubemtzmdathxksrckiivczbkqzjvxbbyvqwjzzsinsowitztdzotjzenbyrumpsgbbvxopvgqwrcmfivmjtrjsponmsshdcmdrcmxombkjsopkydzblmhevxbkrcdllmuhranozrmdtidpmfedcbfvwkezzfvgrzxizrwkddefedcmrhtqizqzeqdcmtfcmuagskuoxceehvdbmkvqyiqreszfaqrdnxnmkrmwqgqqkekkieuozbrqmkrnvoizbwizihkukawixdzvbgmevxbtprrablnkvqgdbygzobrrqfzdcmsfnsprfncrxrpvespbsdhsrbvvjrbsbcynefqmilghcpeaqkbygwexspbramjbpmwdvgiatzcveonbzdzbbcfgvcojxcvhvyqusraxdireceehxdkuovylzkilefgvyobqfegiaaqdeeonbfidlyxfgvrhxprefmqgqhiuyiwlivipmasrtbdkfcznxbqcreoocieswonydyhwdtzrsqlmmmunvhwjkbmosmheqovbykgmphjsyprvxkvqwclksryojnnfdqpfgziqoyjpchoeszhetlptcrmllzw'"
       ]
      },
-     "execution_count": 29,
+     "execution_count": 36,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 30,
+   "execution_count": 37,
    "metadata": {},
    "outputs": [
     {
        "('zixzmzrnkvirr', -1506.8637359274674)"
       ]
      },
-     "execution_count": 30,
+     "execution_count": 37,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 31,
+   "execution_count": 38,
    "metadata": {},
    "outputs": [
     {
        "'inhisjournaldatedtheidesofoctoberintheyearoftheconsulshipsofcaeceliustulliuscapitopomponianusplotiusfirmusandgaiuscorneliusgallicanusagricolawrotethemysteryofthebattleatcamulodonumisatlastsolvedcalgacusmaybeabarbariannowbuthewasaromancitizenthenwhobetrayedusallforloveofabarbarianithastakenallmyskillsasaleaderofmentokeephimalivethelegionnairesspendtheireveningsdesigningnewandcruelwaystoexecutehiminrevengefortheshamehebroughtuponusbuthislifeispreciousitistheonlycardlefttoplayinoursearchforsalvationandthereturnofthestolenaquilaeifwecanalsorecoverthecodexthenperhapsitslosscanbeconcealedandourliveswillbesparedreleasingtheromantraitorcalgacusmusthavestuckintheproudagricolasthroatbuthemadeapactwiththeremainingcaledoniiandtravellednorthtoexchangetheprisonerfortheaquilaeandthecodexbutthecunningcaledoniantribesmansetanothertrapandpresentedagricolawithaforgerycunninglyassembledwithpagesfromthebooksstolenwhenthetriberansackedmonsgraupiusfortoolongthesonsofromehadunderestimatedthepeopleinbritanniaandwhiletheaquilaofthelegionhadbeenrestoredbytheexchangetheirhonourwasnotagricolafacedareturntoromehumiliationandalmostcertaindeaththesixthchapterofmytaleofwoeisguardedbylightningbullandoak'"
       ]
      },
-     "execution_count": 31,
+     "execution_count": 38,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 32,
+   "execution_count": 39,
    "metadata": {},
    "outputs": [
     {
        "'arcanaimperii'"
       ]
      },
-     "execution_count": 32,
+     "execution_count": 39,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 33,
+   "execution_count": 40,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 34,
+   "execution_count": 41,
    "metadata": {},
    "outputs": [
     {
        "1465"
       ]
      },
-     "execution_count": 34,
+     "execution_count": 41,
      "metadata": {},
      "output_type": "execute_result"
     }
    "metadata": {},
    "outputs": [],
    "source": [
-    "def beaufort_encipher(message, keyword):\n",
-    "    \"\"\"Beaufort encipher\n",
+    "def beaufort_encipher(message, keyword):\n",
+    "    \"\"\"Beaufort encipher\n",
     "\n",
-    "    >>> beaufort_encipher('inhisjournaldatedtheidesofoctober', 'arcanaimperii')\n",
-    "    'sevsvrusyrrxfayyxuteemazudmpjmmwr'\n",
-    "    \"\"\"\n",
-    "    shifts = [pos(l) for l in sanitise(keyword)]\n",
-    "    pairs = zip(message, cycle(shifts))\n",
-    "    return cat([unpos(k - pos(l)) for l, k in pairs])"
+    "    >>> beaufort_encipher('inhisjournaldatedtheidesofoctober', 'arcanaimperii')\n",
+    "    'sevsvrusyrrxfayyxuteemazudmpjmmwr'\n",
+    "    \"\"\"\n",
+    "    shifts = [pos(l) for l in sanitise(keyword)]\n",
+    "    pairs = zip(message, cycle(shifts))\n",
+    "    return cat([unpos(k - pos(l)) for l, k in pairs])"
    ]
   },
   {
     }
    ],
    "source": [
-    "beaufort_encipher('inhisjournaldatedtheidesofoctober', 'arcanaimperii')"
+    "beaufort_encipher('inhisjournaldatedtheidesofoctober', 'arcanaimperii')"
    ]
   },
   {
    "metadata": {},
    "outputs": [],
    "source": [
-    "beaufort_decipher = beaufort_encipher"
+    "beaufort_decipher = beaufort_encipher"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 38,
+   "execution_count": 42,
    "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "'inhisjournaldatedtheidesofoctober'"
-      ]
-     },
-     "execution_count": 38,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
+   "outputs": [],
    "source": [
-    "beaufort_decipher('sevsvrusyrrxfayyxuteemazudmpjmmwr', 'arcanaimperii')"
+    "beaufort_decipher('sevsvrusyrrxfayyxuteemazudmpjmmwr', 'arcanaimperii')"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 39,
+   "execution_count": 43,
    "metadata": {},
    "outputs": [],
    "source": [
   },
   {
    "cell_type": "code",
-   "execution_count": 40,
+   "execution_count": 44,
    "metadata": {},
    "outputs": [],
    "source": [
   },
   {
    "cell_type": "code",
-   "execution_count": 42,
+   "execution_count": 45,
    "metadata": {},
    "outputs": [
     {
        "('arcanaimperii', -1506.8637359274674)"
       ]
      },
-     "execution_count": 42,
+     "execution_count": 45,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 43,
+   "execution_count": 46,
    "metadata": {},
    "outputs": [
     {