From: Neil Smith Date: Sun, 12 Dec 2021 16:05:48 +0000 (+0000) Subject: Done challenge 9 X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=7d717b0a1967a6df0d214013105e14822d446304;p=cipher-challenge.git Done challenge 9 --- diff --git a/2021/2021-challenge9.ipynb b/2021/2021-challenge9.ipynb new file mode 100644 index 0000000..ba65216 --- /dev/null +++ b/2021/2021-challenge9.ipynb @@ -0,0 +1,545 @@ +{ + "cells": [ + { + "cell_type": "code", + "execution_count": 78, + "id": "5c19999b", + "metadata": { + "Collapsed": "false" + }, + "outputs": [], + "source": [ + "from szyfrow.caesar import *\n", + "from szyfrow.affine import *\n", + "from szyfrow.keyword_cipher import *\n", + "from szyfrow.column_transposition import *\n", + "from szyfrow.vigenere import *\n", + "from szyfrow.polybius import *\n", + "from szyfrow.railfence import *\n", + "from szyfrow.hill import *\n", + "from szyfrow.support.text_prettify import *\n", + "\n", + "import numpy as np\n", + "import pandas as pd\n", + "import matplotlib.pyplot as plt\n", + "\n", + "import collections\n", + "%matplotlib inline" + ] + }, + { + "cell_type": "code", + "execution_count": 37, + "id": "d9dd1b5e", + "metadata": { + "Collapsed": "false" + }, + "outputs": [], + "source": [ + "challenge_number = 9\n", + "plaintext_a_filename = f'plaintext.{challenge_number}a.txt'\n", + "plaintext_b_filename = f'plaintext.{challenge_number}b.txt'\n", + "ciphertext_a_filename = f'ciphertext.{challenge_number}a.txt'\n", + "ciphertext_b_filename = f'ciphertext.{challenge_number}b.txt'" + ] + }, + { + "cell_type": "code", + "execution_count": 38, + "id": "0f1f792a", + "metadata": { + "Collapsed": "false" + }, + "outputs": [], + "source": [ + "ca = open(ciphertext_a_filename).read()\n", + "cb = open(ciphertext_b_filename).read()\n", + "\n", + "\n", + "sca = sanitise(ca)\n", + "rsca = cat(reversed(sca))\n", + "scb = sanitise(cb)\n", + "rscb = cat(reversed(scb))" + ] + }, + { + "cell_type": "code", + "execution_count": 4, + "id": "b8d5f9ec-27f1-498b-8e64-c5eb2424e581", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Counter({'a': 190,\n", + " 'g': 49,\n", + " 'y': 56,\n", + " 'b': 28,\n", + " 'w': 66,\n", + " 'd': 80,\n", + " 'l': 101,\n", + " 'k': 21,\n", + " 'n': 160,\n", + " 't': 242,\n", + " 'o': 168,\n", + " 'h': 132,\n", + " 'i': 184,\n", + " 'r': 122,\n", + " 'p': 31,\n", + " 'e': 260,\n", + " 's': 119,\n", + " 'u': 59,\n", + " 'f': 39,\n", + " 'c': 57,\n", + " 'v': 26,\n", + " 'm': 48,\n", + " 'x': 2,\n", + " 'j': 1})" + ] + }, + "execution_count": 4, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sca_counts = collections.Counter(sca)\n", + "sca_counts" + ] + }, + { + "cell_type": "code", + "execution_count": 5, + "id": "b5cabba1-ac75-46ea-ac05-8699cc88d986", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 5, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAAR4UlEQVR4nO3df7DldV3H8edLJDRAg1hwA3TR2RQow1zBRpwoKlBz0BJbaojK2iIo7IcFZmlOmzilzmRholibobipBDOWRFsNUirsAvFjF8ZVfriywfordhxFdn33x/munC7n3vO95967e++H52PmzDnfz/l8zvd9v3fP63zO9/u9301VIUlqyxP2dQGSpPlnuEtSgwx3SWqQ4S5JDTLcJalBhrskNeiJ+7oAgMMOO6xWrFixr8uQpCVl06ZNX6yqZaOeWxThvmLFCjZu3Livy5CkJSXJvdM9524ZSWqQ4S5JDTLcJalBhrskNchwl6QGGe6S1CDDXZIaZL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y9wOWAWOPBSU5F/iZrv+HgV/p+V6/FXg+8H0M6v5qkk9W1ddnGHMjg11xLwC+G3h3kldV1avG1PibwDkMLhb2XuB1VfVIkicAnwF6hfuiPaC6R5IfBp7KYHfHN6fp84yZXmMO/2DHSvKDPHqw67qqurnnuOcApzJ4g2+oqi0LVOKe9T2fQbiEwW6FaffX78vtuRQkua2qvn+CcSO367jt2f0b2/O76/VvrPXf4ZSfbxfwQFXt6jHuYuCKmuFEgjHjD2Lw4f67DE6COGCGvqumvs+SnF1VMx77SPJm4LJRv6Mkx/bNikUf7tJik+Q9wDt6zvjUgO4MlhczmL3fy6NnzvzbPi1sBoa7NEtJtgDPYnDwbzHurtI8S/I6BoG+qc83hMXAcJdmadLdK9LeZLhLUoMW5R8xSZLmxnCXpAYZ7pLUIMNdkhpkuEtSg/4P/RyaCr9NUrgAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "pd.Series(sca_counts).sort_index().plot.bar()" + ] + }, + { + "cell_type": "code", + "execution_count": 20, + "id": "4a063a9d-2965-4d80-b01c-211d5d884d8f", + "metadata": {}, + "outputs": [], + "source": [ + "import itertools" + ] + }, + { + "cell_type": "code", + "execution_count": 26, + "id": "000a175e-5afa-45fd-b347-a99fb619b469", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "362880" + ] + }, + "execution_count": 26, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "permutes = [transpositions_of(cat(t)) for t in itertools.permutations('abcdefghi')]\n", + "len(permutes)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "id": "9055ba6c-6fea-4668-aa83-41deff3ba806", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "((1, 4, 6, 3, 5, 7, 0, 2, 8), False, True)" + ] + }, + "execution_count": 27, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "key_a, _ = column_transposition_break(sca, translist=permutes, fitness=Ptrigrams)\n", + "word_a, fill_a, empty_a = key_a\n", + "word_a, fill_a, empty_a" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "id": "7fad89d5-b42e-40d6-ad4d-a8d41cacca84", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'harryifyouarereadingthisthenyouareprobablyalsowonderingwhereiamiamsorrytodisappearbutihavealottothinkaboutandneedtoworkthingsoutonmyowniamonthetraintomassourienowandhopingthatiwillfindtheanswersineedtherethoughihavealreadybeguntoputthepiecestogetherthestorystartedatmichaelfaradayslighthouseattrinitywharfandthatshouldhavebeenabigclueespeciallywiththereferencetothefacilityinflorenceslettertohimwetakeitsomuchforgrantednowthatwemissedtheimportanceofthatplaceitwaswhenilookedintosouterpointthatirealisedwhyitmightberelevantandnowasitravelthroughthefoothillsofthehimalayaitisallcomingintofocustheattachedreportwasdiscoveredbyoneoftheelvesinthelampatsouterpointandwasclearlyleftthereformetofindiamstillnotsurewhattheconspiracysetouttodobutinowknowthesignificanceoftrinitywharfandsouterandicantakeagoodguessatwhytheywereinterestedingeorgeeverestshouseinthemountainsidontknowwhyithinktheremightstillbesomethingtofindtherebutsincetheconspiracyisclearlystillactiveihavetoknowwhattheyaredoingandthisistheonlyleadihavetheconnectionbetweentheearlyconspiratorsisalsomuchclearertomenowtheyallhadaninterestinmathematicsandthenaturalsciencesadalovelacewasakeymemberofbabbagesteamwithherearlyexperimentswithprogrammingmaryeverestboolewasanexpertinlogichighlyeducatedandwellversedinindianmathematicalthoughtatfirstflorencenightingaledoesntlooklikeagreatfitwiththegroupsheiscelebratedmoreformodernisingnursingbutherinnovationswerebasedonseriousdataanalysisusingeverythingsheknewaboutstatisticsandthatwasalotcarolineherschelwasanotherremarkablewomanthefirsttobepaidasalaryasascientistbutithinkherrolewassomethingmoreshehadhugeinfluenceinsocietyandalsoheldapositioningovernmentlikecharlieandtrinityshewastechnicallygiftedandwellplacedtotakefulladvantageofthosegiftsineedtoknowwhattheyaretryingtodowhyandhowtrinitywarnedmenottotellyouaboutherletterbutthatwasneverapossibilityevenifididntletyouknowwhatwasgoingoniamprettysurethatyouwouldhavefoundoutandiwouldmuchrathertellyoumyselftheonlyreasonididntcometoyoustraightawayisthatistilldontknowwhatisgoingonandididntwanttoputyouinthedifficultpositionofhavingtodecidewhethertotrustmeornothopefullythisvisitwillprovidetheevidenceweneedtounraveltheconspiracyandtoclearmynameiwillwritetoyouagainwithnewsfromtheparkjodie'" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "# mod_word_a = (1, 3, 6, 4, 5, 7, 0, 2, 8)\n", + "pa = column_transposition_decipher(sca, word_a, \n", + " fillcolumnwise=fill_a, emptycolumnwise=empty_a)\n", + "pa" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "id": "b3271971-d4b5-4f8a-aab7-0ca141b83f5f", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "harry if you are reading this then you are probably also wondering where i am i am sorry to\n", + "disappear but i have alot to think about and need to work things out on my own i am on the train to\n", + "mass our ie now and hoping that i will find the answers i need there though i have already begun to\n", + "put the pieces together the story started at michael far a days lighthouse at trinity wharf and that\n", + "should have been a big clue especially with the reference to the facility in florence s letter to\n", + "him we take it so much for granted now that we missed the importance of that place it was when i\n", + "looked into souter point that i realised why it might be relevant and no was i travel through the\n", + "foothills of the himalaya it is all coming into focus the attached report was discovered by one of\n", + "the elves in the lamp at souter point and was clearly left there for met of india m still not sure\n", + "what the conspiracy set out to do but i now know the significance of trinity wharf and souter and i\n", + "can take a good guess at why they were interested in george everest s house in the mountains i dont\n", + "know why i think there might still be something to find there but since the conspiracy is clearly\n", + "still active i have to know what they are doing and this is the only lead i have the connection\n", + "between the early conspirators is also much clearer to me now they all had an interest in\n", + "mathematics and the natural sciences ada lovelace was a key member of babbage steam with her early\n", + "experiments with programming mary everest boole was an expert in logic highly educated and well\n", + "versed in indian mathematical thought at first florence nightingale doesnt look like a great fit\n", + "with the group she is celebrated more for modernising nursing but her innovations were based on\n", + "serious data analysis using everything she knew about statistics and that was alot caroline herschel\n", + "was another remarkable woman the first to be paid a salary as a scientist but i think her role was\n", + "something more she had huge influence in society and also held a position in government like charlie\n", + "and trinity she was technically gifted and well placed to take full advantage of those gifts i need\n", + "to know what they are trying to do why and how trinity warned me not to tell you about her letter\n", + "but that was never a possibility even if i didnt let you know what was going on i am pretty sure\n", + "that you would have found out and i would much rather tell you myself the only reason i didnt come\n", + "to you straightaway is that i still dont know what is going on and i didnt want to put you in the\n", + "difficult position of having to decide whether to trust me or not hopefully this visit will provide\n", + "the evidence we need to unravel the conspiracy and to clear my name i will write to you again with\n", + "news from the park jodie\n" + ] + } + ], + "source": [ + "print(prettify(pa))" + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "id": "46512a70-68d4-4ea9-8f66-b39966232fa6", + "metadata": { + "Collapsed": "false", + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "2772" + ] + }, + "execution_count": 31, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "open(plaintext_a_filename, 'w').write(prettify(pa))" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "id": "24d8ad2e-b237-479b-9a62-af9bc8d100d5", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Counter({'v': 129,\n", + " 'r': 173,\n", + " 'd': 103,\n", + " 'p': 124,\n", + " 'k': 68,\n", + " 'w': 107,\n", + " 'f': 95,\n", + " 'a': 234,\n", + " 'o': 176,\n", + " 'm': 96,\n", + " 'z': 47,\n", + " 'e': 265,\n", + " 'u': 66,\n", + " 't': 245,\n", + " 'c': 92,\n", + " 'l': 170,\n", + " 'h': 173,\n", + " 'g': 111,\n", + " 'i': 152,\n", + " 'x': 51,\n", + " 'n': 164,\n", + " 'b': 119,\n", + " 's': 118,\n", + " 'y': 40,\n", + " 'q': 68,\n", + " 'j': 44})" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "scb_counts = collections.Counter(scb)\n", + "scb_counts" + ] + }, + { + "cell_type": "code", + "execution_count": 42, + "id": "d66dd0d0-badb-44f3-a8a6-f7edd17d1532", + "metadata": { + "tags": [] + }, + "outputs": [ + { + "data": { + "text/plain": [ + "" + ] + }, + "execution_count": 42, + "metadata": {}, + "output_type": "execute_result" + }, + { + "data": { + "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXcAAAD4CAYAAAAXUaZHAAAAOXRFWHRTb2Z0d2FyZQBNYXRwbG90bGliIHZlcnNpb24zLjQuMiwgaHR0cHM6Ly9tYXRwbG90bGliLm9yZy8rg+JYAAAACXBIWXMAAAsTAAALEwEAmpwYAAASVklEQVR4nO3de7DcZX3H8fdHtGgBLZSAKaBBJl6gKuoR7YhTWlvB26Ct2NAORavGC7TaWgtYW63TtDj1MlNbUBQUFcVUpdDRipjqIPWCCSKXBMYoqJEI8Z5xFE389o/9pSyHvZ1bcvLk/ZrZ2f09+zy/3/fs2fPZZ5+9nFQVkqS23GtXFyBJmn+GuyQ1yHCXpAYZ7pLUIMNdkhpkuEtSg+69qwsAOPDAA2vZsmW7ugxJ2q2sW7fuu1W1ZNB1iyLcly1bxtq1a3d1GZK0W0nyjWHXuSwjSQ0y3CWpQYa7JDXIcJekBhnuktQgw12SGmS4S1KDDHdJatCi+BBTy5ad+bGB7bee/YydXImkPYkzd0lqkOEuSQ0y3CWpQYa7JDXIcJekBhnuktQgw12SGjQ23JMcluTTSTYkuTHJK7r21yf5dpJru9PT+8aclWRjkpuTHL+QP4Ak6Z4m+RDTNuBVVXVNkv2AdUmu6K57a1W9qb9zkiOBFcBRwG8An0ry0KraPp+FS5KGGztzr6rNVXVNd3krsAE4ZMSQE4GLq+rOqroF2AgcMx/FSpImM6M19yTLgMcAX+yaTk9yXZILkuzftR0CfKtv2CZGPxhIkubZxOGeZF/gI8Arq+rHwLnAEcDRwGbgzTu6DhheA/a3MsnaJGu3bNky07olSSNMFO5J7kMv2C+qqo8C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eb2bzO5rNfXOxmvbzbwNu72ayw/qfDVxcQ948MOZY+9J7oP9rem922HtE36npf1dJTqmqoa+HJHkDcP6Q39kjFiwPFnO4SwspyTuBt04ww1ODunexPJne7P0b3PXOmf/ZpYXNE8Nde6wkG4Aj6L3AtxiWpbQTJXk1vUBfN+pZwe7KcNcea7ZLLNLuwHCXpAYtug8xSZLmznCXpAYZ7pLUIMNdkhpkuEtSg/4PXG2p4WznpsMAAAAASUVORK5CYII=\n", + "text/plain": [ + "
" + ] + }, + "metadata": { + "needs_background": "light" + }, + "output_type": "display_data" + } + ], + "source": [ + "pd.Series(scb_counts).sort_index().plot.bar()" + ] + }, + { + "cell_type": "code", + "execution_count": 79, + "id": "5bb4afa4-22c2-4826-87ad-a0f3e7aa867d", + "metadata": {}, + "outputs": [], + "source": [ + "key_b, _ = hill_break(scb, fitness=Ptrigrams)" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "id": "875b1073-dd5c-4c4d-a028-865933ac472e", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "matrix([[1, 1],\n", + " [1, 0]])" + ] + }, + "execution_count": 84, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "key_b" + ] + }, + { + "cell_type": "code", + "execution_count": 81, + "id": "8107ca5f-b2e7-475b-abc5-0f9b7ec1863a", + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'reportfrommaryeverestbooletothecuriaofthetrinityfoundationthisreportwascommissionedbythecuriatorecordtheoutcomeofthecommissioningandactivitiesofthesouterpointfacilityandtomakerecommendationsonitsdevelopmentafteryearsofpioneeringworkbyfaradayandothersthedevelopmentoftheirextraordinarymachinesoutgrewthecapacityinourheadquartersattrinitywharfwitheachnewincreaseinspeedandpowertheriskofdiscoverygrewuntilthecuriahadnochoicebuttocommissionanewfacilityinspiredbythelessonslearnedinlondonitwasdecidedtobuildalargerestablishmentundercoveroftheconstructionofthesouterpointlighthousethefirstdedicatedelectricallypoweredlampofitskindthegrowthinminingintheareaprovidedexcellentcoverfortheinstallationofournetworkofcavernsunderneaththelighthouseandtheinstallationandmaintenanceofthelighthouselampsteamenginespumpsandgeneratorsdisguisedourownactivitiesasweequippedthebasetheholmesgeneratorsthatweprocuredareidenticaltothoseselectedforthelighthousesothatsparepartscanbeprocuredeasilywithoutraisingsuspiciontheyaredrivenbyapairofsteamengineslocateddeepintherockofcleadonhillbeneaththelighthouseengineroommuchofthenoiseandheattheyproduceismuffledbytherocksandthatwhichescapesismistakenbyneighboursforthechurningofthelighthousemachineryitseemsthatnosuspicionshavebeenarousedamongthelocalswhocontinuetobelievethatouractivitiesaresomehowrelatedtothelighthouseandtheminesitisawondertobeholdtheheavymachineryconvertingthemovementofthemassiveflywheelintotheimperceptiblemotionofmysteriouselectricalchargesthroughthewiresitisdifficulttocomprehendthatthevariouspartsofthemachinecancombinetoproduceanythingapproachinghumanthoughtandyetitcomputesmoreoverthiscomputerembodiesthevisionofthecountessoflovelacethatofamachinewhichcangobeyondmerecalculationtotheanalysisofthevastscreedsofinformationthatnowcrosstheworldbythemiracleoftelegraphyourstaffatsouterpointhavebeenabletoexploittheadditionalenergyprovidedbythenewgeneratorstodoublethecomputingpoweroftheanalyticalengineandarenowabletoprocesstwiceasmanytelegramsinthesametimeusingthestatisticaltechniquespioneeredbybabbageandnightingaleandaidedbythepowerofthedevicethemostsecurelyencipheredmessagesyieldtheirsecretsprovidingintelligencebeyondanythingthatcouldbeascertainedbyeventhelargestnetworkofagentswhilethismuchisgoodandtobecelebratedthereisalsobadnewsiamdisappointedtoreportthattheadditionalvolumeoftrafficonthetelegraphynetworkandtheincreasedrateatwhichwehavebeenabletodecipherthosemessageshasstretchedtheabilityofourmostpowerfulenginethefoundationmachinetosupporttheanalystsintheirworkasaresultweriskdrowningininformationwecannotusewehavereachedthelimitsofwhatonemachinecandoandifwearetomakethemostofthisnewbountythenwewillneedtolinkseveralintheircomputationssothattheycananalyseandreportwhattheyfindasfastasthemessagesflowthiswillrequireanenormousincreaseinourproductionofelectricitywhichcannotbeachievedbycombustionwithoutalargeincreaseintheconsumptionoffuelthecostwouldbeprohibitivebutevenifitcouldbemetthecorrespondingincreaseintheproductionofheatandnoisewouldbeunlikelytoescapeattentionevenonthewildnortheastcoastifwearetorealiseourfullambitionsweneedtofindamoreremotelocationwithareadysourceofpoweredisonsworkatappletonshowsgreatpromiseandithinkiknowtheideallocationtobuilditmaryeverestboole'" + ] + }, + "execution_count": 81, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "pb = hill_decipher(key_b, scb)\n", + "pb" + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "id": "c7f2e770-8062-4d18-b90a-cb2e410ef88c", + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "report from mary everest boole to the curia of the trinity foundation this report was commissioned\n", + "by the curia to record the outcome of the commissioning and activities of the souter point facility\n", + "and to make recommendations on its development after years of pioneering work by faraday and others\n", + "the development of their extraordinary machines outgrew the capacity in our headquarters at trinity\n", + "wharf with each new increase in speed and power the risk of discovery grew until the curia had no\n", + "choice but to commission a new facility inspired by the lessons learned in london it was decided to\n", + "build a larger establishment undercover of the construction of the souter point lighthouse the first\n", + "dedicated electrically powered lamp of its kind the growth in mining in the area provided excellent\n", + "cover for the installation of our network of caverns underneath the lighthouse and the installation\n", + "and maintenance of the lighthouse lamps team engines pumps and generators disguised our own\n", + "activities as we equipped the base the holmes generators that we procured are identical to those\n", + "selected for the lighthouse so that spareparts can be procured easily without raising suspicion they\n", + "are driven by a pair of steam engines located deep in the rock of c lead on hill beneath the\n", + "lighthouse engine room much of the noise and heat they produce is muffled by the rocks and that\n", + "which escapes is mistaken by neighbours for the churning of the lighthouse machinery it seems that\n", + "no suspicions have been aroused among the locals who continue to believe that our activities are\n", + "somehow related to the lighthouse and the mines it is a wonder to behold the heavy machinery\n", + "converting the movement of the massive flywheel into the imperceptible motion of mysterious\n", + "electrical charges through the wires it is difficult to comprehend that the various parts of the\n", + "machine can combine to produce anything approaching human thought and yet it computes moreover this\n", + "computer embodies the vision of the countess of lovelace that of a machine which can go beyond mere\n", + "calculation to the analysis of the vast screeds of information that now cross the world by the\n", + "miracle of telegraph your staff at souter point have be enable to exploit the additional energy\n", + "provided by the new generators to double the computing power of the analytical engine and are now\n", + "able to process twice as many telegrams in the same time using the statistical techniques pioneered\n", + "by babbage and nightingale and aided by the power of the device the most securely enciphered\n", + "messages yield their secrets providing intelligence beyond anything that could be ascertained by\n", + "even the largest network of agents while this much is good and to be celebrated there is also bad\n", + "new siam disappointed to report that the additional volume of traffic on the telegraphy network and\n", + "the increased rate at which we have be enable to decipher those messages has stretched the ability\n", + "of our most powerful engine the foundation machine to support the analysts in their work as a result\n", + "we risk drowning in information we can not use we have reached the limits of what one machine can do\n", + "and if we are to make the most of this new bounty then we will need to link several in their\n", + "computations so that they can analyse and report what they find as fast as the messages flow this\n", + "will require an enormous increase in our production of electricity which can not be achieved by\n", + "combustion without a large increase in the consumption of fuel the cost would be prohibitive but\n", + "even if it could be met the corresponding increase in the production of heat and noise would be\n", + "unlikely to escape attention even on the wild northeast coast if we are to realise our full\n", + "ambitions we need to find a more remote location with a ready source of powered i sons work at\n", + "appleton shows great promise and i think i know the ideal location to build it mary everest boole\n" + ] + } + ], + "source": [ + "print(prettify(pb))" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "id": "d12a663c", + "metadata": { + "Collapsed": "false" + }, + "outputs": [ + { + "data": { + "text/plain": [ + "3897" + ] + }, + "execution_count": 83, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "open(plaintext_b_filename, 'w').write(prettify(pb))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "id": "504ec2e2", + "metadata": { + "Collapsed": "false" + }, + "outputs": [], + "source": [] + } + ], + "metadata": { + "jupytext": { + "formats": "ipynb,md" + }, + "kernelspec": { + "display_name": "Python 3 (ipykernel)", + "language": "python", + "name": "python3" + }, + "language_info": { + "codemirror_mode": { + "name": "ipython", + "version": 3 + }, + "file_extension": ".py", + "mimetype": "text/x-python", + "name": "python", + "nbconvert_exporter": "python", + "pygments_lexer": "ipython3", + "version": "3.8.8" + } + }, + "nbformat": 4, + "nbformat_minor": 5 +} diff --git a/2021/2021-challenge9.md b/2021/2021-challenge9.md new file mode 100644 index 0000000..a280dd4 --- /dev/null +++ b/2021/2021-challenge9.md @@ -0,0 +1,125 @@ +--- +jupyter: + jupytext: + formats: ipynb,md + text_representation: + extension: .md + format_name: markdown + format_version: '1.3' + jupytext_version: 1.11.1 + kernelspec: + display_name: Python 3 (ipykernel) + language: python + name: python3 +--- + +```python Collapsed="false" +from szyfrow.caesar import * +from szyfrow.affine import * +from szyfrow.keyword_cipher import * +from szyfrow.column_transposition import * +from szyfrow.vigenere import * +from szyfrow.polybius import * +from szyfrow.railfence import * +from szyfrow.hill import * +from szyfrow.support.text_prettify import * + +import numpy as np +import pandas as pd +import matplotlib.pyplot as plt + +import collections +%matplotlib inline +``` + +```python Collapsed="false" +challenge_number = 9 +plaintext_a_filename = f'plaintext.{challenge_number}a.txt' +plaintext_b_filename = f'plaintext.{challenge_number}b.txt' +ciphertext_a_filename = f'ciphertext.{challenge_number}a.txt' +ciphertext_b_filename = f'ciphertext.{challenge_number}b.txt' +``` + +```python Collapsed="false" +ca = open(ciphertext_a_filename).read() +cb = open(ciphertext_b_filename).read() + + +sca = sanitise(ca) +rsca = cat(reversed(sca)) +scb = sanitise(cb) +rscb = cat(reversed(scb)) +``` + +```python +sca_counts = collections.Counter(sca) +sca_counts +``` + +```python tags=[] +pd.Series(sca_counts).sort_index().plot.bar() +``` + +```python +import itertools +``` + +```python +permutes = [transpositions_of(cat(t)) for t in itertools.permutations('abcdefghi')] +len(permutes) +``` + +```python +key_a, _ = column_transposition_break(sca, translist=permutes, fitness=Ptrigrams) +word_a, fill_a, empty_a = key_a +word_a, fill_a, empty_a +``` + +```python +# mod_word_a = (1, 3, 6, 4, 5, 7, 0, 2, 8) +pa = column_transposition_decipher(sca, word_a, + fillcolumnwise=fill_a, emptycolumnwise=empty_a) +pa +``` + +```python +print(prettify(pa)) +``` + +```python Collapsed="false" tags=[] +open(plaintext_a_filename, 'w').write(prettify(pa)) +``` + +```python +scb_counts = collections.Counter(scb) +scb_counts +``` + +```python tags=[] +pd.Series(scb_counts).sort_index().plot.bar() +``` + +```python +key_b, _ = hill_break(scb, fitness=Ptrigrams) +``` + +```python +key_b +``` + +```python +pb = hill_decipher(key_b, scb) +pb +``` + +```python +print(prettify(pb)) +``` + +```python Collapsed="false" +open(plaintext_b_filename, 'w').write(prettify(pb)) +``` + +```python Collapsed="false" + +``` diff --git a/2021/ciphertext.9a.txt b/2021/ciphertext.9a.txt new file mode 100644 index 0000000..183426f --- /dev/null +++ b/2021/ciphertext.9a.txt @@ -0,0 +1 @@ +AAGYB WWADB LKNKT AAONH IWTGR NPETE ESSTD LNEYE OIEET UNADT AWOSN AIRNR UTHAO FTPSY EEUAA HTSUE COWIC TDDAS YREEI TTTEL HDSOI SVKHN ILTTE YTORW AEEDA SAYBE REIME OXGEN SATGT NLORT PERRR EIAIN IHEAN AIEHA TOACU ESMDU CLOGT LNSLA AENON WATDT ELHBS SEDKA ISOVT DEMON MRYTN GDNUF IVIRE ESLHE UECEI EISAY RIALD ROAIT ODIMN TIOIT SRHDP CEYTA GTHAA IETRE IEOEF DEECL WETHS IEOET LIINU CTVEE MRWYE ILWNE BOIFH UAOWR TGSHN ONGEG ECPLL HWANH DCNHN SCTEN ITECA WMBWR MPNRW RHCEI AAAOH OLTHE AOSNN SDSYE GBSHT HAREF PRNTO EEGCT HTEKA YCGWD LGGDA TOWAT ULTVB NLWOP EOODC EEYIO GTLWN IOTUO GWTNL SOVNA NNMLY IOJFA TEARI RPATT OGOHM NIIEN TVBTS TTIAT RRSEC ITNAF LITRO IMOCE IRTDH AATES AAITE ARFIA OSEOD NAPOT TIRRE TGYID EOMIW TTOOE TRAAV HETOH NEEPS CMANM CAEOS EGTYN OMSSI GTLIH TFEIS KIGSE MNBOE NAIEH UITAR AMORI AIIEH HIIAL ONCDH NFLOA OFOTY HRNOB TARLF THNEH LNWRL FENOT AOAON UETOO EUTYT IDEEP TNWUH TDREH UBNES STTBE HNONR HTDRE IAOEH RAFIA WHHBP IEHYC TKHEW HNPSK UTIML NVHIH TICAR ONVAE DLRFI EOSON NOWOC OTESR TTINI IBNHN SCIIO YATAE OTORU RHATA HSDEE BMAIH IEEEC UWDMC TLGDK ATHRF IIINE ULGNA ITOEW RLEEA EIRMR UNEOI VIETE YDEUA EEHED OWOOR TEIET OGMRW FNUTS LDTIS LWIDT NCINE ORUIR EEROA RIOWR KIESR YEERP HOUTN YTOEP WHIEA YUERS MRHTA TVGCH EFNSH IONMI EAHDE AEGVW LHLMS GSHWE OSPPA LFNLH STUWF TATND HEEEH ESWKH STREI ELAWR DEIOB ESIHO YININ ILABA ILERG EATIA LNTLT RTEIF EITRI GNWOD SVSOT ACESE WIAYT HLTSE EYEIR ENSHI ETLEI TTRWT RTAEH EIIEW IRTUU IHLLR DYHHD HGDPH LNTHR OLIVI EVSDY LOTMO YDHPL IAYEV HAWSW EAONL AEHEE TTHAC DHIFH BLAHC CLEMS GWSPF ENNPI WTNSH FOLLN HDSET NTICF RIOTI UIHCI FRAUT NIVUO DHHSM FBHAR CEADH NANTA IALEL TASTN VAREH ETGAT ANHEV NEHIN NNETR CDOGU VRSTS RETCW RSNAM SDSSN WIENN NDNMH TEITL TDFTK HIYIE TOTTA IIYAG TADDO AYTAT UATNT NTTDP FDTSH TWDED LIOAR ANHIH UNNOO GIORA NDRUI RSATF SDULU EGSTA YUINU EELRT LRTEM AHERH TLOIE YEATO OTYCO AEIBE HOTET EMSHA TOSNI NNESE EGREN NIRIT NTCYY IOTIS YECEL ASAOH RHNRE LEFTE PWAYO EOYAR IAUSE ALGIU LOEUH TBRAS TNTAS LHTKN TSSBH SGALO APNNR IAADL KAHIO YGNIM LTRAO YIUWN YYAUL HUEOO TASKS NAOFS ACEMP ILTCO HALET AWPRR TOAOH MIUOA ETOMI UDANE HHETI TODLL EYTDA SWFTT NRACT TTATA OOTLT EDAGH EIMOT OCOLL TNREO TRCYD KGEYS IGAWE OSNAK HMLIT INSTE NEGSE HINCO METDS MTLAC MAAER TMVLP IDDEN IHFIE OEHSB ENSRO SOANI WTDLN LEBHB LITRO OHEIS SOLII TLNCF TSEWR OHYNY EUNSV NNSAU UEAMR YNIEA IIOOI TIITI DTOFV PEWNC YAWTN FROIE RSNMT AEINO ONTSW GLNEO AGHOE RHAON AOEUL EEIOT WORTS OTIIT ORHBT IROFA LTERD DHTSN LTMAT TRTNE ANAAK EHTNE SUOYE TEIUE CLTTT OILVE WRRLE NLETA UCEKO SHXSR RBNLL DEDMO RCGTA WOEMD NTAEE AUYKS SAOCO RATAA TKANH FSDAI EARWC EPAVT SNENA NDEUE WPTDO TOTTH OUTOH SCSWI TIAWY IOHEH TOHIE NTTRC MIGEE E \ No newline at end of file diff --git a/2021/ciphertext.9b.txt b/2021/ciphertext.9b.txt new file mode 100644 index 0000000..5a94732 --- /dev/null +++ b/2021/ciphertext.9b.txt @@ -0,0 +1 @@ +VRDPK RWFAO MMPRZ EVEWE UTCOP LHTAT GELUI ITOAT XEZRV NRTTF HUDDB TBOAT AIVRD PKRWW USAOU MKSWI RNEDR YLHWC ZRTAF OGEFO WDLHI OVTAO SEYFL HQCYM AIASB OVIGG QNCAB TDVBT WETOA TWEIO XTGRW OGNFF KCTLR TNAWD AOKAV EGEAO QMQNT AWIFN BOBIV SZEPE DOQMG NFAXT PREEJ RTOXP BOIEZ RTNKW BRZBF FRRDD YYQNH OLHJR ATHEZ EPEDO QMGNT OATME VRQXR RFOLD NNPRM MJCVI WEIOZ TVRPW LHCCP PKCRT VIIOY REETD UUKRV ESSMT ZRVNR TDWRA BFBIL HCAUH AEVIT CEEWS VIHSI EDDQN DPAWK RLHZR CSTOL DUSJO VEEYV RQWGN TIATG ELUII HHQDQ OVHKI FENUH TQCYM AIASB ONAAE FFKCT LRTVI HSZIH EZBAT PEWEG SFNPL RARNL DYNBO RDVNP TSAHD KCHDW DPOCU OLLAR AKGVR LSBAT LZSQM GNHUH DTRJO VETOA TGEBO LSLRV CWIBN YFLHG SNUVE DPVIE TOIAH VHMUX ELHNF JRWTH EKITA HEPEG EKTKI LAJLD PAWVR ODMAD PNFLT SKQNA TKEFR PWPHZ NVIVI OGGNL HRAEE GPJOL IHEBE GCWLR EVTJO VETFK RLHVI LSLAL LBTBO TOIOE RXEKW BRTOC CZVER MSQNV ERNTA AHLHT LNGAT IOWSN AWDLH VILSL ALLBT BONAP DIAGN RENAG CTOAT PEOIA HVHMU PEMAH PXTMA REOGR NHSGU HPNAJ DREVE TAFOV SAIAG AIHEI OFRJW CABTD VBTWE SAAWU ECUEP HEATF ESAXE LHVHX LWEKG RNRRH TJRAT TAAWG PQOLU HERAM EHDGN KILAH TATGO WEPEG EXTID FOATP EOIAH VHMUW EHOHH LTPPV RPPKR USNAF BGPQO LUHEE EASJL EWATI OKTIA ASTNM SHSKI WIGNL HYYVR UDDIR EZBPA IAFRX FXTMA REOGR NDSQO TAHEH DTEVI ATVEQ OYKHF PLDAB OPHWL FBRNT AAHLH TLNGA TIOWS REOGR NFRAO GMJCT OATRE WOWSN AKDEE MTLHN YFRXD GCAIG MKFPL EDRYL HFRMC SSQNA TTADW KILHU SPAWE AIUML SKARE ZBRNO IIHIO JRTFK RLHJC LUVNT NTOAT PEOIA HVHMU QECAP HRNPR BIWSQ ELSHH GTGOM UXPKC BOZSV AFEIE NNFRM UHEMA BOZGL HZLCC DLDWQ OBOBT HNXEP OPEMI ZVATT AIORR VCDIB IMISS VRGSQ MVHNW PETAH EHTAT PEOIA HVHMU EEQNA TQEVI WEBIA IWABO HDKRP OLEZO WDLHL HVAKY CAPHR NPRQC INVEB TTNAT QEJOQ EREHT YFLHM MKSDI JEJLD WIETL GNHOL HUITP TRTEB TMBQE HOWIB NRFQY XTZRI OWSPL VCZRC CNLHH XRWEA TFRAU AHLHE WVRAS BTVSN INFWC ELHTQ CBMVR LHQNA TTAAT ZERAW IMUPP KRGSY FLHMM JCVIG ENAQC NMVIX EDOFR XDGCN ARYPH TNPAG POOJC VINGG UNAAT IONGT TQNCY BTVTA OJPXT ESFOS EZVKR PHUSA OJPXT VRNMR OMILS LHDVA SBOTO ATGEI OGNWE GSQFJ OPECA XEHHH TFFMM JCVIA EPHJC CCTNP OCEBO PDVEG ELAWC LLBTB OHTAT EENNJ LASGS YFLHV VLSUS VRHEG SNFSN FOMMB TBOAT TABNY WFRKS ATAEF OOLZB ATQEZ ICAPL TOXTP LXGPA FHIOJ RTTKF TAGSN UVEDP VIATV AFEIE NNMBX ESOMX ZLBIA TEEGD BIWIN NPLRN XRNYF RDVHD EDRYL HRNCW REVET AFOLS ROIOM BXELH QCBMN UVIVG KOVET OATEE NNJLB TCCPL TNVIE EQNRA REKOB APLHT GPQOW ELSEW GCSAM MLNXT PLXGM AASGN LHSSQ MBTQM MUVIZ GLHLS TAAIB TCCEL GEUHY IYUHS WIRNV EHEZB BBCBG AEEQN VNNGB TTNLA EEQNI AHDED RYLHD PAWFR YFLHH DDVGC ATQEG OLTGE LUPEC YPNXI LHVRP DWESS KGQSM IOLAT MEJRG EVRLT GPJOL IVIOG GNPET LKGPN FECEB ODDLN ATVIZ GHHVT IOOLF BSAGC KRIAR NEDCY ZVGNL HLLXR WEGTX EKWBR TOGAR ELTDW TIXEP HESWU PHYSC ODDQN HTFBG CPLSB TAHEA TVEME SSDLP ODARN OWIIP MAIPA DPVIX TWDFO TEFOM THHMT LHDAL DBTBO LAJVF LQMTO KTFAN FQCGN LHXTP LXGPA FHRNP TFOKK QNATM EPNVR SAHER RXTTA DWKID HLEVA FEIEN NMBXE ROGEX ILHKR VHWSQ MKSGA WEHHK SKTXE JCHEA TEEJB TLRTT OIODR GOITK OVEZF PLTNV IXELH TFHUD DBTBO MMJCV IXEGO JUDPK RATEE NNJLL SASGN LHZIK WBRSA RAWEF UPTVE AINKF RJWVI OGVNS NFOMM BTBOA WCCAN HOMUA ELEVA VEEEJ CHEAT PEUIB IGSBF HHHTR NMMJC VIGEN ARDNA LDBFE EVRHT MMOKA TQEGO HTYFP HFSAE PBHUR TATRE AWEWW LRNHE HTTLX NWSZV RRTLG NLHZI QCBMN UTAWI FNGSA TTAAT CECCN NNNJL WSNAU DTEFO PTHHM TLHDY VIDDX SSATT LSLHQ MKSGA WEQFK OATAI EWWLV RKQZI EERNB NDRIO ASPNV RSAME BNLUG PROWU BTBOT OPEGE KTKIB IUYPH JCCCA NHOFB CAPHZ EHEZB QCNMM UBTBO EWATI OTTLL XRMEP NVRSA MEGNL HQCFN GUIPW IBNKF YUELL HQCLS KWFUE DTEFR PHJBB TZVVB XTZVV NNFVT IOOLF BQMMT LHQCI RWEDP QNVIO GPNVR SAMEG NLHGP ROWUB TBOTO LHTAN AQDWO WSKWF UEDYE YNSIP ERYSO USPAE EMTRE BTBOZ EREBO ATAET IQDFO ATEEL SQCSA BTBFE EVRHT VRLAA ISELU ZFWLM AJBBT BOOSR EIEWD TOVID DAMVR VRAMX TZLCC BTBOE WATRA EEBDG SLUGC TODPA WVRLD GSFNK WBRTA PAAPX EBOZS KOYSV RTAGP AOAIE EQNBI PHXNS IBNPW LHLIE EWLQO TAWIG NPOCU OLBIM MPRZE VEWEU TCOPL \ No newline at end of file diff --git a/2021/plaintext.9a.txt b/2021/plaintext.9a.txt new file mode 100644 index 0000000..3e62b3e --- /dev/null +++ b/2021/plaintext.9a.txt @@ -0,0 +1,29 @@ +harry if you are reading this then you are probably also wondering where i am i am sorry to +disappear but i have alot to think about and need to work things out on my own i am on the train to +mass our ie now and hoping that i will find the answers i need there though i have already begun to +put the pieces together the story started at michael far a days lighthouse at trinity wharf and that +should have been a big clue especially with the reference to the facility in florence s letter to +him we take it so much for granted now that we missed the importance of that place it was when i +looked into souter point that i realised why it might be relevant and no was i travel through the +foothills of the himalaya it is all coming into focus the attached report was discovered by one of +the elves in the lamp at souter point and was clearly left there for met of india m still not sure +what the conspiracy set out to do but i now know the significance of trinity wharf and souter and i +can take a good guess at why they were interested in george everest s house in the mountains i dont +know why i think there might still be something to find there but since the conspiracy is clearly +still active i have to know what they are doing and this is the only lead i have the connection +between the early conspirators is also much clearer to me now they all had an interest in +mathematics and the natural sciences ada lovelace was a key member of babbage steam with her early +experiments with programming mary everest boole was an expert in logic highly educated and well +versed in indian mathematical thought at first florence nightingale doesnt look like a great fit +with the group she is celebrated more for modernising nursing but her innovations were based on +serious data analysis using everything she knew about statistics and that was alot caroline herschel +was another remarkable woman the first to be paid a salary as a scientist but i think her role was +something more she had huge influence in society and also held a position in government like charlie +and trinity she was technically gifted and well placed to take full advantage of those gifts i need +to know what they are trying to do why and how trinity warned me not to tell you about her letter +but that was never a possibility even if i didnt let you know what was going on i am pretty sure +that you would have found out and i would much rather tell you myself the only reason i didnt come +to you straightaway is that i still dont know what is going on and i didnt want to put you in the +difficult position of having to decide whether to trust me or not hopefully this visit will provide +the evidence we need to unravel the conspiracy and to clear my name i will write to you again with +news from the park jodie \ No newline at end of file diff --git a/2021/plaintext.9b.txt b/2021/plaintext.9b.txt new file mode 100644 index 0000000..e7f507c --- /dev/null +++ b/2021/plaintext.9b.txt @@ -0,0 +1,40 @@ +report from mary everest boole to the curia of the trinity foundation this report was commissioned +by the curia to record the outcome of the commissioning and activities of the souter point facility +and to make recommendations on its development after years of pioneering work by faraday and others +the development of their extraordinary machines outgrew the capacity in our headquarters at trinity +wharf with each new increase in speed and power the risk of discovery grew until the curia had no +choice but to commission a new facility inspired by the lessons learned in london it was decided to +build a larger establishment undercover of the construction of the souter point lighthouse the first +dedicated electrically powered lamp of its kind the growth in mining in the area provided excellent +cover for the installation of our network of caverns underneath the lighthouse and the installation +and maintenance of the lighthouse lamps team engines pumps and generators disguised our own +activities as we equipped the base the holmes generators that we procured are identical to those +selected for the lighthouse so that spareparts can be procured easily without raising suspicion they +are driven by a pair of steam engines located deep in the rock of c lead on hill beneath the +lighthouse engine room much of the noise and heat they produce is muffled by the rocks and that +which escapes is mistaken by neighbours for the churning of the lighthouse machinery it seems that +no suspicions have been aroused among the locals who continue to believe that our activities are +somehow related to the lighthouse and the mines it is a wonder to behold the heavy machinery +converting the movement of the massive flywheel into the imperceptible motion of mysterious +electrical charges through the wires it is difficult to comprehend that the various parts of the +machine can combine to produce anything approaching human thought and yet it computes moreover this +computer embodies the vision of the countess of lovelace that of a machine which can go beyond mere +calculation to the analysis of the vast screeds of information that now cross the world by the +miracle of telegraph your staff at souter point have be enable to exploit the additional energy +provided by the new generators to double the computing power of the analytical engine and are now +able to process twice as many telegrams in the same time using the statistical techniques pioneered +by babbage and nightingale and aided by the power of the device the most securely enciphered +messages yield their secrets providing intelligence beyond anything that could be ascertained by +even the largest network of agents while this much is good and to be celebrated there is also bad +new siam disappointed to report that the additional volume of traffic on the telegraphy network and +the increased rate at which we have be enable to decipher those messages has stretched the ability +of our most powerful engine the foundation machine to support the analysts in their work as a result +we risk drowning in information we can not use we have reached the limits of what one machine can do +and if we are to make the most of this new bounty then we will need to link several in their +computations so that they can analyse and report what they find as fast as the messages flow this +will require an enormous increase in our production of electricity which can not be achieved by +combustion without a large increase in the consumption of fuel the cost would be prohibitive but +even if it could be met the corresponding increase in the production of heat and noise would be +unlikely to escape attention even on the wild northeast coast if we are to realise our full +ambitions we need to find a more remote location with a ready source of powered i sons work at +appleton shows great promise and i think i know the ideal location to build it mary everest boole \ No newline at end of file