2018 challenge 9
authorNeil Smith <neil.git@njae.me.uk>
Thu, 6 Dec 2018 15:38:56 +0000 (15:38 +0000)
committerNeil Smith <neil.git@njae.me.uk>
Thu, 6 Dec 2018 15:38:56 +0000 (15:38 +0000)
2018/2018-challenge9.ipynb [new file with mode: 0644]
2018/9a.ciphertext [new file with mode: 0644]
2018/9a.plaintext [new file with mode: 0644]
2018/9b.ciphertext [new file with mode: 0644]
2018/9b.plaintext [new file with mode: 0644]

diff --git a/2018/2018-challenge9.ipynb b/2018/2018-challenge9.ipynb
new file mode 100644 (file)
index 0000000..d386b62
--- /dev/null
@@ -0,0 +1,417 @@
+{
+ "cells": [
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Biolerplate"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 1,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "import os,sys,inspect\n",
+    "currentdir = os.path.dirname(os.path.abspath(inspect.getfile(inspect.currentframe())))\n",
+    "parentdir = os.path.dirname(currentdir)\n",
+    "sys.path.insert(0,parentdir) "
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 2,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "from cipher.caesar import *\n",
+    "from cipher.affine import *\n",
+    "from cipher.keyword_cipher import *\n",
+    "from cipher.vigenere import *\n",
+    "from cipher.playfair import *\n",
+    "from cipher.column_transposition import *\n",
+    "from support.text_prettify import *\n",
+    "from support.plot_frequency_histogram import *"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 3,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "ca = open('9a.ciphertext').read()\n",
+    "cb = open('9b.ciphertext').read()\n",
+    "sca = sanitise(ca)\n",
+    "scb = sanitise(cb)\n",
+    "pca = letters(ca)\n",
+    "pcb = letters(cb)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 4,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "8197"
+      ]
+     },
+     "execution_count": 4,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "history_words = [w.strip() for w in open('history-words.txt')]\n",
+    "len(history_words)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 5,
+   "metadata": {},
+   "outputs": [],
+   "source": [
+    "history_transpositions = collections.defaultdict(list)\n",
+    "for word in history_words:\n",
+    "    history_transpositions[transpositions_of(word)] += [word]"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Part A"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 6,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stderr",
+     "output_type": "stream",
+     "text": [
+      "/usr/local/lib/python3.6/dist-packages/matplotlib/figure.py:445: UserWarning: Matplotlib is currently using module://ipykernel.pylab.backend_inline, which is a non-GUI backend, so cannot show the figure.\n",
+      "  % get_backend())\n"
+     ]
+    },
+    {
+     "data": {
+      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFH1JREFUeJzt3XvQZHV95/H3J4w3MBGBR0IY8MFImSVmXXBkcUlSBjSLioGtJS5GA2RJTYy4ahJjICaFZWkVRmtdt2rjZlQW3LAIEg0kaJQaMOAFdGYAGS7KLBeZKS6PNyJSEUa++aMPqZ6L0/eZ+U2/X1Vdzzmnf78+3z7PefrTv9Onz5OqQpKk1vzUri5AkqRxGGCSpCYZYJKkJhlgkqQmGWCSpCYZYJKkJhlgkqQmGWCSpCYZYJKkJhlgkqQmLdvVBQAccMABtbi4uKvLkCTtBtauXfvtqloY1G5ggCU5HzgReKiqXrjVfX8EfABYqKpvJwnwIeBVwKPAGVW1btA6Fhc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VXf6U4eWA98tqr+eBY1dnbW9hhnvwL4B+CNSW7vah32cOBOU1W3Jfkz4PPpnen4OHAWcO+uqGePvxJHN5JaV1UzfZfQ/TLXAb9ZVXfOcl3SIEkWgb+vqoFnOk5pfc+sqke6M/uuBVZW1bqdse7dXXpn0T5SVR/Y1bXsafboQ4jd4Zev0Dvza5brOYLemUarDS/NqVXdh/rrgL8xvLQz7PEjMEnSnmmPHoFJkvZcBpgkqUkGmCSpSQaYJKlJBpgkqUkGmCSpSf8CLu65+U3fb6wAAAAASUVORK5CYII=\n",
+      "text/plain": [
+       "<Figure size 432x288 with 1 Axes>"
+      ]
+     },
+     "metadata": {
+      "needs_background": "light"
+     },
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "fc = collections.Counter(sca)\n",
+    "plot_frequency_histogram(fc, sort_key=fc.get)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 7,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'dynamite'"
+      ]
+     },
+     "execution_count": 7,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "key_a, score = vigenere_frequency_break(sca)\n",
+    "key_a"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 8,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'theengineersharrybroughtwithhimwantedtotakesawsandtorchestothetablesafebutneitherofuswerekeenicouldseethatitwouldbeworthalottocollectorsandprobablybelongedinamuseumharrysaidheagreedbutihadafeelinghewanteditinstalledbackinheadquarterstherewassomethingproprietorialinthewayhelookedatitittookthetwoofuseighteenhourstocrackitbutwithasquadronofspecialforcesfromherefordguardingustherewasnoriskthatmyattackerswouldreturniaskedharryhowhegotauthorisationtobringtheminafterallwestillwerentsurethattherewereanynationalsecurityimplicationsbuthejustlaughedandpointedoutthatwewerecurrentlysomewhereundernewscotlandyardandithadnttakenmuchtoconvincethehomesecretarythatweneededapropersecurityteamtoguardtheshadowarchiveanotherteamofanalystshadcampedononesideofthecommandcentreandwerecombingthroughblackscodebookandthefewpapersthatourantagonistshadleftbehindfromtimetotimeoneofthetrooperswouldarrivewithanotherboxofdocumentsretrievedfromasideroomoramoredistantpartofthearchivelabyrinthmostcouldbedecryptedquicklyusingthestandardtoolsblackhadusedarangeofciphersincludingsubstitutionandtranspositionandalmostnoneofitwasharderthanavigenereitwasslowsincethepapershadtobehandledwithcareandthescannertheyhadbroughtwiththemwasntreallydesignedforthissortofworkacoupleoftimestheycalledharryovertoshowhimsomethingandhereaditnoddedthencamebacktoworkonthesafeasweworkedwetalkedaboutwhatihadlearnedconcerningtheshadowarchiveandblackssecretworkforthegovernmentharrydidntgivemuchawaybutihadafeelinghehadheardsomeofthisstorybeforeandafterthesecondtimehewascalledawayheseemedparticularlythoughtfuliaskedhimwhatwasbotheringhimbuthewasenjoyingbeingcryptichesaidsomethingaboutthebalkanproblemthenmutteredsteveturnerspoemhistorylessonhistoryrepeatsitselfhastonoonelistensicouldntgetanythingmoreoutofhimexceptsomecommentaboutworkingbackwardsthroughthepaperssoiturnedmyattentionbacktothesafethemechanismwasbiggerandheavierthanwewereusedtoandhadbeenexquisitelymadethecomponentsslidalmostnoiselesslyoveroneanotherandtheloudclicksihadheardwhenmovingthetableseemedtobetheresultofabrokencogtoothcatchingonthebarrelsthatmadeitevenhardertoopenwhatlittlenoisethelocktumblersmadewasheavilydisguisedandwehadtoresorttodrillingasmallaccessholetopassanendoscopeintotheinterioritwasaswellwehadtakentheeffortsittinginthemiddleofapileofnotebooksandpaperswasasmallpileofwhatlookedlikeexplosivesthesafewasriggedtoblowifwemadeamistake'"
+      ]
+     },
+     "execution_count": 8,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "vigenere_decipher(sca, key_a)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 9,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "the engineers harry brought with him wanted to take saws and torches to the table safe but neither\n",
+      "of us were keen i could see that it would be worth alot to collectors and probably belonged in a\n",
+      "museum harry said he agreed but i had a feeling he wanted it installed back in headquarters there\n",
+      "was something proprietor i al in the way he looked at it it took the two of us eighteen hours to\n",
+      "crack it but with a squadron of special forces from hereford guarding us there was no risk that my\n",
+      "attackers would return i asked harry how he got authorisation to bring them in after all we still\n",
+      "werent sure that there were any national security implications but he just laughed and pointed out\n",
+      "that we were currently somewhere under new scotland yard and it hadnt taken much to convince the\n",
+      "home secretary that we needed a proper security team to guard the shadow archive another team of\n",
+      "analysts had camped on one side of the command centre and were combing through blacks codebook and\n",
+      "the few papers that our antagonists had left behind from time to time one of the troopers would\n",
+      "arrive with another box of documents retrieved from aside room or a more distant part of the archive\n",
+      "labyrinth most could be decrypted quickly using the standard tools black had used a range of ciphers\n",
+      "including substitution and transposition and almost none of it was harder than avi genere it was\n",
+      "slow since the papers had to be handled with care and the scanner they had brought with them wasnt\n",
+      "really designed for this sort of work a couple of times they called harry over to show him something\n",
+      "and he read it nodded then came back to work on the safe as we worked we talked about what i had\n",
+      "learned concerning the shadow archive and blacks secret work for the government harry didnt give\n",
+      "much away but i had a feeling he had heard some of this story before and after the second time he\n",
+      "was called away he seemed particularly thoughtful i asked him what was bothering him but he was\n",
+      "enjoying being cryptic he said something about the balkan problem then muttered steve turners poem\n",
+      "history lesson history repeats itself has to no one listens i couldnt get anything more out of him\n",
+      "except some comment about working backwards through the papers so i turned my attention back to the\n",
+      "safe the mechanism was bigger and heavier than we were used to and had been exquisitely made the\n",
+      "components slid almost noiselessly over one another and the loud clicks i had heard when moving the\n",
+      "table seemed to be the result of a broken cog tooth catching on the barrels that made it even harder\n",
+      "to open what little noise the lock tumblers made was heavily disguised and we had to resort to\n",
+      "drilling a small access hole to pass an endoscope into the interior it was as well we had taken the\n",
+      "effort sitting in the middle of a pile of notebooks and papers was a small pile of what looked like\n",
+      "explosives the safe was rigged to blow if we made a mistake\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(lcat(tpack(segment(vigenere_decipher(sca, key_a)))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 10,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "2913"
+      ]
+     },
+     "execution_count": 10,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "open('9a.plaintext', 'w').write(lcat(tpack(segment(vigenere_decipher(sca, key_a)))))"
+   ]
+  },
+  {
+   "cell_type": "markdown",
+   "metadata": {},
+   "source": [
+    "# Part B"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 11,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFE1JREFUeJzt3X+QZWV95/H3J2CMogkCLSHK2OISN5rEUUYSo6SIP7JoNOquMRB/kZiMbKBMdtekIG4iRcUqEjXWbu0GM8QpcEMQDUFJxCiFRvAH0RkYYfglIMPC1GQYIasCCQLz3T/umeTO0NDn/pqep/v9qro15zz3PPf5dp/u/pzn3HPPpKqQJKk137fUBUiSNA4DTJLUJANMktQkA0yS1CQDTJLUJANMktQkA0yS1CQDTJLUJANMktQkA0yS1KT9l7oAgEMOOaTm5+eXugxJ0j5g48aN36qqucW22ycCbH5+ng0bNix1GZKkfUCS2/ts5ylESVKTDDBJUpMMMElSkwwwSVKTDDBJUpMMMElSkwwwSVKTDDBJUpMMMElSkwwwSVKT9olbSUmS9k3zp36q97ZbzvyFGVbySM7AJElNMsAkSU0ywCRJTTLAJElNMsAkSU0ywCRJTTLAJElNMsAkSU1aNMCSrE9yV5LNQ20XJNnUPbYk2dS1z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PmF7b9IIW3PUAAAAASUVORK5CYII=\n",
+      "text/plain": [
+       "<Figure size 432x288 with 1 Axes>"
+      ]
+     },
+     "metadata": {
+      "needs_background": "light"
+     },
+     "output_type": "display_data"
+    }
+   ],
+   "source": [
+    "fc = collections.Counter(scb)\n",
+    "plot_frequency_histogram(fc, sort_key=fc.get)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 12,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'turkey'"
+      ]
+     },
+     "execution_count": 12,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "key_b, score = vigenere_frequency_break(scb)\n",
+    "key_b"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 14,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'erutuferuceseromdnawenagnitaercfoepohehtnimehthtiwylesolckrowoteunitnoclliwinoigertahtnidlohtoofasueviglliwainsobnikrowtentnegaruoosfiyltnenamrepnoitseuqnaklabehtelttesotspahrepdnasniaglairotirretnaissurenimrednuotepohewetatsnamottoehtotkcabainodecamgnidartybemitemasehttasetuoredartnaenarretidemehtfolortnocruognitnemecsurpycniagyamewtahtsruomurdraehevahidnaseitinutroppognidartnihcireblliwynamregniraazabcitamolpidehtfoerehpsomtadeiznerfehtesruocfosrewoprojamehtnomehthguorhtraeboterusserpgnirbnacewtahtepohehtniytilibatsniderutrunevahsnaklabehtssorcastnegaymseitrapdnasetatsrellamsehtnosisucofymtubweivaevaherusmailliwsrewoprojamehtfollassergnocehtfonrecnocelpicnirpehtsideveihcaebthgimnoitacifinusihtrehtehwdnawohfonoitseuqehtelbitapmocnieraesehtdnasweivlavirynamyreveraerehttahtrehtartubaediraelcakcalyehttahttonsitignidaelsimsitahtspahrepnoitacifinuehtdaeldluohsytraphcihwfoaediraelcondnanworiehtfosnoitibmalacitilopdnalarutlucdeiravhtiwdedividniamersevlesmehtsetatsnaklabehtnoitulosnaklabakeesohwesohtdnaaissurnihtiweildluohsrewopstifosucolehttahteveilebohwesohtneewtebtilpsylpeedsitubdeifinuneebevahylatidnaynamregtahtyawemasehtnisetatscivalsehtetinuotsmiatnemevomcivalsnapehtsisircehtfotuoyawaeesyameweveilebinehtnilrebtaadnegaehtlortnocnacewfitcilfnocrehtrufmorfesoloteromgnihtemosevahyehttahtdesilaerevahlladnatnenitnocehtssorcatpureyamrawtahttaerhtgnirehtagehteesotnugebevahsrewoprojamehtfollasevilnitsocrewolhcumatadeeccusthgimycamolpidfosdohtemwenruotahtsiepohymtsoctaergtanetfodnathguoberagninniwhtrowseirotcivllatahtweivymsititubthguorbnaemylerustsumitahtdiasdnaemdetcerrocehriafyalpotsihtdiasinehwnoituloserarofepohotnigebnacinilrebnissergnocgnidnepmiehttathguobebthgimecaeptahttcepsorpehthtiwyllanifwonnihtiwseimenegnithgifygreneelbaredisnocdednepxeevahidnallahetihwniralupopyllasrevinuneebtonevahsdohtemymsselehtenonmelborphsikrutehtotnoitulosnworuotneserpotsrewopgnidaelrehtohtiwetaitogenotnigebotelbaerewewdnocesdnaseimeneruofosecivrescitamolpidehtnihtiwkrowtentnegaruopolevedotelbaerewewtsrifsgnihtowtdeveihcayaledsihttahtflesymtrofmocidnaelbativeniehtyaledotdekrowseillaehtgnomanoisufnocgniwosfoygetartsruonoituloslanoitanretninaotelbanemaebotgniraeppaelihwnoitisophsitirbehtgnisilanigramylevitceffednaairtsuadnaynamregniseillarehhtiwnoitcaroftroppusgnidliubyltcefrepdnahrehdeyalpsahaissurderaefewtahtllaneebsahrawhsikrutossureht'"
+      ]
+     },
+     "execution_count": 14,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "b1 = vigenere_decipher(scb, key_b)\n",
+    "b1"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 33,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'therussoturkishwarhasbeenallthatwefearedrussiahasplayedherhandperfectlybuildingsupportforactionwithheralliesingermanyandaustriaandeffectivelymarginalisingthebritishpositionwhileappearingtobeamenabletoaninternationalsolutionourstrategyofsowingconfusionamongthealliesworkedtodelaytheinevitableandicomfortmyselfthatthisdelayachievedtwothingsfirstwewereabletodevelopouragentnetworkwithinthediplomaticservicesofourenemiesandsecondwewereabletobegintonegotiatewithotherleadingpowerstopresentourownsolutiontotheturkishproblemnonethelessmymethodshavenotbeenuniversallypopularinwhitehallandihaveexpendedconsiderableenergyfightingenemieswithinnowfinallywiththeprospectthatpeacemightbeboughtattheimpendingcongressinberlinicanbegintohopeforaresolutionwhenisaidthistoplayfairhecorrectedmeandsaidthatimustsurelymeanbroughtbutitismyviewthatallvictoriesworthwinningareboughtandoftenatgreatcostmyhopeisthatournewmethodsofdiplomacymightsucceedatamuchlowercostinlivesallofthemajorpowershavebeguntoseethegatheringthreatthatwarmayeruptacrossthecontinentandallhaverealisedthattheyhavesomethingmoretolosefromfurtherconflictifwecancontroltheagendaatberlinthenibelievewemayseeawayoutofthecrisisthepanslavicmovementaimstounitetheslavicstatesinthesamewaythatgermanyanditalyhavebeenunifiedbutisdeeplysplitbetweenthosewhobelievethatthelocusofitspowershouldliewithinrussiaandthosewhoseekabalkansolutionthebalkanstatesthemselvesremaindividedwithvariedculturalandpoliticalambitionsoftheirownandnoclearideaofwhichpartyshouldleadtheunificationperhapsthatismisleadingitisnotthattheylackaclearideabutratherthatthereareverymanyrivalviewsandtheseareincompatiblethequestionofhowandwhetherthisunificationmightbeachievedistheprincipleconcernofthecongressallofthemajorpowerswilliamsurehaveaviewbutmyfocusisonthesmallerstatesandpartiesmyagentsacrossthebalkanshavenurturedinstabilityinthehopethatwecanbringpressuretobearthroughthemonthemajorpowersofcoursethefrenziedatmosphereofthediplomaticbazaaringermanywillberichintradingopportunitiesandihaveheardrumoursthatwemaygaincypruscementingourcontrolofthemediterraneantraderoutesatthesametimebytradingmacedoniabacktotheottomanstatewehopetounderminerussianterritorialgainsandperhapstosettlethebalkanquestionpermanentlyifsoouragentnetworkinbosniawillgiveusafootholdinthatregioniwillcontinuetoworkcloselywiththeminthehopeofcreatinganewandmoresecurefuture'"
+      ]
+     },
+     "execution_count": 33,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "pb = cat(reversed(b1))\n",
+    "pb"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 34,
+   "metadata": {},
+   "outputs": [
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
+      "the russo turkish war has been all that we feared russia has played her hand perfectly building\n",
+      "support for action with her allies in germany and austria and effectively marginalising the british\n",
+      "position while appearing to be amenable to an international solution our strategy of sowing\n",
+      "confusion among the allies worked to delay the inevitable and i comfort myself that this delay\n",
+      "achieved two things first we were able to develop our agent network within the diplomatic services\n",
+      "of our enemies and second we were able to begin to negotiate with other leading powers to present\n",
+      "our own solution to the turkish problem nonetheless my methods have not been universally popular in\n",
+      "whitehall and i have expended considerable energy fighting enemies within now finally with the\n",
+      "prospect that peace might be bought at the impending congress in berlin i can begin to hope for a\n",
+      "resolution when i said this to playfair he corrected me and said that i must surely mean brought but\n",
+      "it is my view that all victories worth winning are bought and often at great cost my hope is that\n",
+      "our new methods of diplomacy might succeed at a much lower cost in lives all of the major powers\n",
+      "have begun to see the gathering threat that war may erupt across the continent and all have realised\n",
+      "that they have something more to lose from further conflict if we can control the agenda at berlin\n",
+      "then i believe we may see away out of the crisis the pan slavic movement aims to unite the slavic\n",
+      "states in the same way that germany and italy have been unified but is deeply split between those\n",
+      "who believe that the locus of its power should lie within russia and those who seek a balkan\n",
+      "solution the balkan states themselves remain divided with varied cultural and political ambitions of\n",
+      "their own and no clear idea of which party should lead the unification perhaps that is misleading it\n",
+      "is not that they lack a clear idea but rather that there are very many rival views and these are\n",
+      "incompatible the question of how and whether this unification might be achieved is the principle\n",
+      "concern of the congress all of the major powers william sure have a view but my focus is on the\n",
+      "smaller states and parties my agents across the balkans have nurtured instability in the hope that\n",
+      "we can bring pressure to bear through the mon the major powers of course the frenzied atmosphere of\n",
+      "the diplomatic bazaar in germany will be rich in trading opportunities and i have heard rumours that\n",
+      "we may gain cyprus cementing our control of the mediterranean trade routes at the same time by\n",
+      "trading macedonia back to the ottoman state we hope to undermine russian territorial gains and\n",
+      "perhaps to settle the balkan question permanently if so our agent network in bosnia will give usa\n",
+      "foothold in that region i will continue to work closely with them in the hope of creating a new and\n",
+      "more secure future\n"
+     ]
+    }
+   ],
+   "source": [
+    "print(lcat(tpack(segment(pb))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 35,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "2856"
+      ]
+     },
+     "execution_count": 35,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "open('9b.plaintext', 'w').write(lcat(tpack(segment(pb))))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": null,
+   "metadata": {},
+   "outputs": [],
+   "source": []
+  }
+ ],
+ "metadata": {
+  "kernelspec": {
+   "display_name": "Python 3",
+   "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.6.7"
+  }
+ },
+ "nbformat": 4,
+ "nbformat_minor": 2
+}
diff --git a/2018/9a.ciphertext b/2018/9a.ciphertext
new file mode 100644 (file)
index 0000000..7f94794
--- /dev/null
@@ -0,0 +1 @@
+WFREZOBRHCESTIKVBZEOGOAXZGGHTQFADLGEPBHXDIRSMELEQBGODKAIVRBTTMMEEJRSMNXFXRAEUBAIUMSUEEXVHIREZQVSXJQSQMMLDRVTIWNPGZRWAZMLDJBTFWVSOJRCFWKWDLQPDWUEEJLBQTHRJCQIZIFYVCHMTIKVBQNIPPXEJPREPJNXLFNDMNXIOGA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RDXQDIHVCLAABZHQGHQATJHUNSDQZKHBGONTHALDJEYIWIDKVSFIDI
diff --git a/2018/9a.plaintext b/2018/9a.plaintext
new file mode 100644 (file)
index 0000000..8edaee2
--- /dev/null
@@ -0,0 +1,30 @@
+the engineers harry brought with him wanted to take saws and torches to the table safe but neither
+of us were keen i could see that it would be worth alot to collectors and probably belonged in a
+museum harry said he agreed but i had a feeling he wanted it installed back in headquarters there
+was something proprietor i al in the way he looked at it it took the two of us eighteen hours to
+crack it but with a squadron of special forces from hereford guarding us there was no risk that my
+attackers would return i asked harry how he got authorisation to bring them in after all we still
+werent sure that there were any national security implications but he just laughed and pointed out
+that we were currently somewhere under new scotland yard and it hadnt taken much to convince the
+home secretary that we needed a proper security team to guard the shadow archive another team of
+analysts had camped on one side of the command centre and were combing through blacks codebook and
+the few papers that our antagonists had left behind from time to time one of the troopers would
+arrive with another box of documents retrieved from aside room or a more distant part of the archive
+labyrinth most could be decrypted quickly using the standard tools black had used a range of ciphers
+including substitution and transposition and almost none of it was harder than avi genere it was
+slow since the papers had to be handled with care and the scanner they had brought with them wasnt
+really designed for this sort of work a couple of times they called harry over to show him something
+and he read it nodded then came back to work on the safe as we worked we talked about what i had
+learned concerning the shadow archive and blacks secret work for the government harry didnt give
+much away but i had a feeling he had heard some of this story before and after the second time he
+was called away he seemed particularly thoughtful i asked him what was bothering him but he was
+enjoying being cryptic he said something about the balkan problem then muttered steve turners poem
+history lesson history repeats itself has to no one listens i couldnt get anything more out of him
+except some comment about working backwards through the papers so i turned my attention back to the
+safe the mechanism was bigger and heavier than we were used to and had been exquisitely made the
+components slid almost noiselessly over one another and the loud clicks i had heard when moving the
+table seemed to be the result of a broken cog tooth catching on the barrels that made it even harder
+to open what little noise the lock tumblers made was heavily disguised and we had to resort to
+drilling a small access hole to pass an endoscope into the interior it was as well we had taken the
+effort sitting in the middle of a pile of notebooks and papers was a small pile of what looked like
+explosives the safe was rigged to blow if we made a mistake
\ No newline at end of file
diff --git a/2018/9b.ciphertext b/2018/9b.ciphertext
new file mode 100644 (file)
index 0000000..2ccb370
--- /dev/null
@@ -0,0 +1 @@
+XLLDY DXLLM IQXLF WHLTQ VXEEG CKKIP VZFOT MAYYD RGFYY DLRBQ PVIQH FTUVM PIKOY LBNEY GJECN SRMBA VBXYA NESHJ HBKYS DTMLO ZGZFC SAYBH JYFLB EIYAR XHKXI ETLLY SQYCP VXLXH RWVCI HFSXQ XOHXE IEUSO LRXFK DIQHN JZEFK YGNRY LHZKK JTCIY XGKLV DRYBM JEVCG CDBIB GOFDI NHBVG IRTNJ XEKHN KYIFM IKUGY UUZXS BXWRW KLBXR BXWUY DSXCF UJOLR MUJOX SHLVN EPMHR ORYKL VDMBX GVRXD HFFBX LHWIE SEGCK XIKXW JEVNR WESEE RUDOA RTBKC VSHGL BHPTY YOZYA CUXEQ XCKSR SMLFZ TMZHZ NEPMH ZRGGK YSVPG PSEKQ PXAES VYTTR LGGMU DYPNB XVRXD HYIOL NLIDD EBXCQ XIPYY YDIQK OFMJM LLVGS NKIAK QCANE YQCAN YQYMK BKBEC UIKOV SLMVB TEGCI LRYVY NDEFM YGYLC ANESC RBFZL ERLHZ NIPNN IERCO UYCRY DFRLI FMMJY VATMK XIETS DCIGM LRZHL TMVDE RLLVV PYFMV RXLHM ZCYAH ZPWXS UQVSZ YXPRR IPNMD KMJEC NCVCP IGBSH TGVRX DHFCK WQXLX XSAXB KPSLK YTXSA XFGSG LBLGO LRLCU OZCBB TKIZM BXSQL HCKKG GYCEE WGANI OLRXB NNRYP IYPSL HCKCI SJYYD IJUCK KTKHW ESIPT YJOLR WHRCA CBPCK ZGKSE KQWKY MOVYX LVRXR TBKBI FMUID YZTYU SVYXF TKOAT FPOLR MUYDX MGMZD MEGCU KIJLC DCMRT BKCTY ALVZR MBNRM MDBHL OLRWU VVHJN IYCCR KUGRG GAQWY ECWCI KIJVI ENRYG QFBMC ANWYW LHCKS FKTFR MMRBF FZHLT FRBYR EOTNI GKUMR XGPXV NMTBX ESEKX LJOZJ XMDOL RLYKK XQGUB VEZXB KXSGM OCYWL TECKF YDYVC SFPYJ YLRWH RKMQL OIXMF MCNOM JWFLY LQKYN YTQMC WYWSV ICOLR MUYDI TXCCO FMAQV CSFMH VOARX VKSPN LSCZI CWMZD YZWYZ PMLNH VOFCO UYIPY MCUXE WGUDB IEMUY DCYPY DKWCA NESWC MUKCG GOUCC IFMYK SRSHN JWMYM HVWIT HGTSZ YEMEK TCANJ SWGKW VRXDH NLYCY PUVOW WTGVG ITXCC OFGGY YDRGE LVLXY TXEOK YXBKV SPMHF MRYVY NPMRV CCPRM VLVRX PNZDY VDXMF VSRXL FWKLB BKOQM LYMKL WXBKD EFMXV CMJTY IOZYA FCKHL TNEOR GMHFM IFMMJ YVATN GEVCR UDBEU MUYDX YXLYD KLBLV RXYZY YDICL IKXYE XVVFE FLLVG SNKIA KQCAN WYPJT MVFMJ GCKCS AKYNY PFVOD KXYWY VMGSL NYQMK RWRWS JICUP SQWIY DIKPY EBYMM UYDWG XJFRC KMMFM XYXLX DELXN WYHLT NYQYM UYIKK LBHES AFMLF GWCBL FDGGO FCKXY ANNOM TRGJS XGMOS DLENI ILRYX GPVIP NMKCY KBNRR XBBUJ NRYXG UOXAX LIYGC ALZKJ WTFGY XQBBK NMYLC EOLUG IZDYJ HMVBE PHZVZ SFHNE SKCUH RMMLB FIOFL BMJOV EGITQ RGWHV ZQGXB KDERA ALYFC UNYQM KXWRO TRTBK DGCIM FBTCA NYDMU RFCKR GYQFX RGANZ GWCBG VXIEG CKRKG YSXBI LXYCL EPXXZ CRMVX VNRCI RVOZY ACUXE JEUYO XGAQE SVYEO GYTWE FRCVC OCEER CXVKY RCOUY CHMAN VWCKL MVVIF MYEYR KXFSY VNAMZ UVSMY YDSRG IZDYJ HMEGS PNIKX IQXLG YXQKY NYTEG CUKIJ KYYDS FMCNO XYBNF QILHN ESKCU IKOPZ TYIOA CPXEY GCLXE KWCBG VXIPN IWYWC VCMBI QVCKK QMEJZ NIFMH ZRXGP EIYAR XHKXI ETLLY TMEYM OHMMY CLECK YNOAR LLZPW EGCYD SUMXV FIGAW RIEJX XJSLR MUYDJ JXMPW XPHZD YGGWH ROPZT NZFIL BYYDC YEYUY XBXEI YAQXC CVECA NXXSK THFSW SYHFM KLBQF CJMRA VDEPM MIESL HCKEP MLFRX SGMUE BIRGC EKSRX FSKRC FUVLS RZHZB ECIJR OPGAQ EYMRB MFZLQ BNZBF CANXX MQBFR XMEKU DIPCO CKMID YYUXE YBLKC YYWHR IRYFL VQRGL YZVPY KYYRX GPHFS XATLF PXPHJ GEWEG CUVMS USCDG CYLVZ HLTBI OLBXS RVTQT BRSWQ NLUOV YXZVG XYANC VELXY SCEFK UNRWG DLLDS QLOIO LR
diff --git a/2018/9b.plaintext b/2018/9b.plaintext
new file mode 100644 (file)
index 0000000..a18f15d
--- /dev/null
@@ -0,0 +1,30 @@
+the russo turkish war has been all that we feared russia has played her hand perfectly building
+support for action with her allies in germany and austria and effectively marginalising the british
+position while appearing to be amenable to an international solution our strategy of sowing
+confusion among the allies worked to delay the inevitable and i comfort myself that this delay
+achieved two things first we were able to develop our agent network within the diplomatic services
+of our enemies and second we were able to begin to negotiate with other leading powers to present
+our own solution to the turkish problem nonetheless my methods have not been universally popular in
+whitehall and i have expended considerable energy fighting enemies within now finally with the
+prospect that peace might be bought at the impending congress in berlin i can begin to hope for a
+resolution when i said this to playfair he corrected me and said that i must surely mean brought but
+it is my view that all victories worth winning are bought and often at great cost my hope is that
+our new methods of diplomacy might succeed at a much lower cost in lives all of the major powers
+have begun to see the gathering threat that war may erupt across the continent and all have realised
+that they have something more to lose from further conflict if we can control the agenda at berlin
+then i believe we may see away out of the crisis the pan slavic movement aims to unite the slavic
+states in the same way that germany and italy have been unified but is deeply split between those
+who believe that the locus of its power should lie within russia and those who seek a balkan
+solution the balkan states themselves remain divided with varied cultural and political ambitions of
+their own and no clear idea of which party should lead the unification perhaps that is misleading it
+is not that they lack a clear idea but rather that there are very many rival views and these are
+incompatible the question of how and whether this unification might be achieved is the principle
+concern of the congress all of the major powers william sure have a view but my focus is on the
+smaller states and parties my agents across the balkans have nurtured instability in the hope that
+we can bring pressure to bear through the mon the major powers of course the frenzied atmosphere of
+the diplomatic bazaar in germany will be rich in trading opportunities and i have heard rumours that
+we may gain cyprus cementing our control of the mediterranean trade routes at the same time by
+trading macedonia back to the ottoman state we hope to undermine russian territorial gains and
+perhaps to settle the balkan question permanently if so our agent network in bosnia will give usa
+foothold in that region i will continue to work closely with them in the hope of creating a new and
+more secure future
\ No newline at end of file