Done 2018 challenge 10
[cipher-tools.git] / 2018 / 2018-challenge9.ipynb
index d386b62774f26f8a6c3cb99fec686b572855462e..ebf6dd67f34ab79dcee5b36805fee75d8b153ee7 100644 (file)
@@ -37,7 +37,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 13,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -51,7 +51,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 5,
    "metadata": {},
    "outputs": [
     {
@@ -60,7 +60,7 @@
        "8197"
       ]
      },
-     "execution_count": 4,
+     "execution_count": 5,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -72,7 +72,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 6,
    "metadata": {},
    "outputs": [],
    "source": [
@@ -90,7 +90,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
        "'dynamite'"
       ]
      },
-     "execution_count": 7,
+     "execution_count": 8,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 9,
    "metadata": {},
    "outputs": [
     {
        "'theengineersharrybroughtwithhimwantedtotakesawsandtorchestothetablesafebutneitherofuswerekeenicouldseethatitwouldbeworthalottocollectorsandprobablybelongedinamuseumharrysaidheagreedbutihadafeelinghewanteditinstalledbackinheadquarterstherewassomethingproprietorialinthewayhelookedatitittookthetwoofuseighteenhourstocrackitbutwithasquadronofspecialforcesfromherefordguardingustherewasnoriskthatmyattackerswouldreturniaskedharryhowhegotauthorisationtobringtheminafterallwestillwerentsurethattherewereanynationalsecurityimplicationsbuthejustlaughedandpointedoutthatwewerecurrentlysomewhereundernewscotlandyardandithadnttakenmuchtoconvincethehomesecretarythatweneededapropersecurityteamtoguardtheshadowarchiveanotherteamofanalystshadcampedononesideofthecommandcentreandwerecombingthroughblackscodebookandthefewpapersthatourantagonistshadleftbehindfromtimetotimeoneofthetrooperswouldarrivewithanotherboxofdocumentsretrievedfromasideroomoramoredistantpartofthearchivelabyrinthmostcouldbedecryptedquicklyusingthestandardtoolsblackhadusedarangeofciphersincludingsubstitutionandtranspositionandalmostnoneofitwasharderthanavigenereitwasslowsincethepapershadtobehandledwithcareandthescannertheyhadbroughtwiththemwasntreallydesignedforthissortofworkacoupleoftimestheycalledharryovertoshowhimsomethingandhereaditnoddedthencamebacktoworkonthesafeasweworkedwetalkedaboutwhatihadlearnedconcerningtheshadowarchiveandblackssecretworkforthegovernmentharrydidntgivemuchawaybutihadafeelinghehadheardsomeofthisstorybeforeandafterthesecondtimehewascalledawayheseemedparticularlythoughtfuliaskedhimwhatwasbotheringhimbuthewasenjoyingbeingcryptichesaidsomethingaboutthebalkanproblemthenmutteredsteveturnerspoemhistorylessonhistoryrepeatsitselfhastonoonelistensicouldntgetanythingmoreoutofhimexceptsomecommentaboutworkingbackwardsthroughthepaperssoiturnedmyattentionbacktothesafethemechanismwasbiggerandheavierthanwewereusedtoandhadbeenexquisitelymadethecomponentsslidalmostnoiselesslyoveroneanotherandtheloudclicksihadheardwhenmovingthetableseemedtobetheresultofabrokencogtoothcatchingonthebarrelsthatmadeitevenhardertoopenwhatlittlenoisethelocktumblersmadewasheavilydisguisedandwehadtoresorttodrillingasmallaccessholetopassanendoscopeintotheinterioritwasaswellwehadtakentheeffortsittinginthemiddleofapileofnotebooksandpaperswasasmallpileofwhatlookedlikeexplosivesthesafewasriggedtoblowifwemadeamistake'"
       ]
      },
-     "execution_count": 8,
+     "execution_count": 9,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [
     {
     }
    ],
    "source": [
-    "print(lcat(tpack(segment(vigenere_decipher(sca, key_a)))))"
+    "print(prettify(vigenere_decipher(sca, key_a)))"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 11,
    "metadata": {},
    "outputs": [
     {
        "2913"
       ]
      },
-     "execution_count": 10,
+     "execution_count": 11,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "open('9a.plaintext', 'w').write(lcat(tpack(segment(vigenere_decipher(sca, key_a)))))"
+    "open('9a.plaintext', 'w').write(prettify(vigenere_decipher(sca, key_a)))"
    ]
   },
   {
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAbAAAAEmCAYAAAADccV0AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDMuMC4yLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvOIA7rQAAFE1JREFUeJzt3X+QZWV95/H3J2CMogkCLSHK2OISN5rEUUYSo6SIP7JoNOquMRB/kZiMbKBMdtekIG4iRcUqEjXWbu0GM8QpcEMQDUFJxCiFRvAH0RkYYfglIMPC1GQYIasCCQLz3T/umeTO0NDn/pqep/v9qro15zz3PPf5dp/u/pzn3HPPpKqQJKk137fUBUiSNA4DTJLUJANMktQkA0yS1CQDTJLUJANMktQkA0yS1CQDTJLUJANMktQkA0yS1KT9l7oAgEMOOaTm5+eXugxJ0j5g48aN36qqucW22ycCbH5+ng0bNix1GZKkfUCS2/ts5ylESVKTDDBJUpMMMElSkwwwSVKTDDBJUpMMMElSkwwwSVKTDDBJUpMMMElSkwwwSVKT9olbSUmS9k3zp36q97ZbzvyFGVbySM7AJElNMsAkSU0ywCRJTTLAJElNMsAkSU0ywCRJTTLAJElNMsAkSU1aNMCSrE9yV5LNQ20XJNnUPbYk2dS1zyf556HnPjTL4iVJK1efO3GcA/wv4CO7Gqrql3ctJ/kA8O2h7W+tqtXTKlCSp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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,
+   "execution_count": 14,
    "metadata": {},
    "outputs": [
     {
        "'turkey'"
       ]
      },
-     "execution_count": 12,
+     "execution_count": 14,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": 16,
    "metadata": {},
    "outputs": [
     {
        "'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,
+     "execution_count": 16,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "pb = cat(reversed(b1))\n",
-    "pb"
+    "pb1 = vigenere_decipher(scb, key_b)\n",
+    "pb1"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 34,
+   "execution_count": 27,
    "metadata": {},
    "outputs": [
     {
     }
    ],
    "source": [
-    "print(lcat(tpack(segment(pb))))"
+    "rpb1 = cat(reversed(pb1))\n",
+    "print(prettify(rpb1))"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 35,
+   "execution_count": 28,
    "metadata": {},
    "outputs": [
     {
        "2856"
       ]
      },
-     "execution_count": 35,
+     "execution_count": 28,
      "metadata": {},
      "output_type": "execute_result"
     }
    ],
    "source": [
-    "open('9b.plaintext', 'w').write(lcat(tpack(segment(pb))))"
+    "open('9b.plaintext', 'w').write(prettify(rpb1))"
    ]
   },
   {