Fixed railfence ciphers, done challenges 2014 4 and 5
[cipher-tools.git] / LJ!-Qt!-Fghxft-dferts;-hsjeukaxxn-sfedw.ipynb
diff --git a/LJ!-Qt!-Fghxft-dferts;-hsjeukaxxn-sfedw.ipynb b/LJ!-Qt!-Fghxft-dferts;-hsjeukaxxn-sfedw.ipynb
new file mode 100644 (file)
index 0000000..67f4598
--- /dev/null
@@ -0,0 +1,279 @@
+{
+ "metadata": {
+  "name": "",
+  "signature": "sha256:256d7cbeceb110bdd970d796e22b0b9a746259f81a6da52f94b471762908873e"
+ },
+ "nbformat": 3,
+ "nbformat_minor": 0,
+ "worksheets": [
+  {
+   "cells": [
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "from cipherbreak import *"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [],
+     "prompt_number": 5
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "ct = \"LJ! Qt! Fghxft dferts; hsjeukaxxn sfedw.\""
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [],
+     "prompt_number": 1
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "ctu = ct.upper()\n",
+      "ctu"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "metadata": {},
+       "output_type": "pyout",
+       "prompt_number": 10,
+       "text": [
+        "'LJ! QT! FGHXFT DFERTS; HSJEUKAXXN SFEDW.'"
+       ]
+      }
+     ],
+     "prompt_number": 10
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "ctu4 = ctu.split()[4]\n",
+      "ctu2 = ctu.split()[2]\n",
+      "ctu3 = ctu.split()[3]"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [],
+     "prompt_number": 27
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "seeds4 = [w for w in keywords if len(w) == 10 and w[-2] == w[-3] and len(set(w)) == 9]\n",
+      "len(seeds4)"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "metadata": {},
+       "output_type": "pyout",
+       "prompt_number": 14,
+       "text": [
+        "50"
+       ]
+      }
+     ],
+     "prompt_number": 14
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "seeds2 = [w for w in keywords if len(w) == 6 and w[0] == w[-2] and len(set(w)) == 5]\n",
+      "len(seeds2)"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "metadata": {},
+       "output_type": "pyout",
+       "prompt_number": 17,
+       "text": [
+        "283"
+       ]
+      }
+     ],
+     "prompt_number": 17
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "seeds3 = [w for w in keywords if len(w) == 6 and len(set(w)) == 6]\n",
+      "len(seeds3)"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "metadata": {},
+       "output_type": "pyout",
+       "prompt_number": 26,
+       "text": [
+        "5252"
+       ]
+      }
+     ],
+     "prompt_number": 26
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "for s in seeds4:\n",
+      "    print(ctu.translate(''.maketrans({f: t for f, t in zip(ctu4, s)})))"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "output_type": "stream",
+       "stream": "stdout",
+       "text": [
+        "Lc! QT! FGaeFT DFtRTu; auctioneer uFtDW.\n",
+        "La! QT! FGblFT DFsRTo; boastfully oFsDW.\n",
+        "Le! QT! FGclFT DFrRTa; caerphilly aFrDW.\n",
+        "Lt! QT! FGcoFT DFhRTa; catherwood aFhDW.\n",
+        "Li! QT! FGcoFT DFlRTh; childproof hFlDW.\n",
+        "Lt! QT! FGclFT DFrRTi; citronella iFrDW.\n",
+        "Lo! QT! FGelFT DFtRTr; erotically rFtDW.\n",
+        "Lh! QT! FGelFT DFnRTt; ethnically tFnDW.\n",
+        "Lo! QT! FGelFT DFtRTx; exotically xFtDW.\n",
+        "Lr! QT! FGgeFT DFnRTa; garnisheed aFnDW.\n",
+        "La! QT! FGglFT DFcRTr; gracefully rFcDW.\n",
+        "La! QT! FGglFT DFtRTr; gratefully rFtDW.\n",
+        "Lr! QT! FGhlFT DFoRTe; heroically eFoDW.\n",
+        "Ln! QT! FGhlFT DFtRTu; huntsville uFtDW.\n",
+        "Lf! QT! FGilFT DFoRTn; informally nFoDW.\n",
+        "Lg! QT! FGloFT DFhRTi; lightproof iFhDW.\n",
+        "Lg! QT! FGlrFT DFaRTo; loganberry oFaDW.\n",
+        "Lr! QT! FGmlFT DFcRTe; mercifully eFcDW.\n",
+        "Lt! QT! FGmlFT DFrRTe; metrically eFrDW.\n",
+        "Ll! QT! FGmeFT DFwRTi; milwaukees iFwDW.\n",
+        "Lr! QT! FGmlFT DFtRTi; mirthfully iFtDW.\n",
+        "Lg! QT! FGnlFT DFhRTi; nightfalls iFhDW.\n",
+        "Lr! QT! FGpoFT DFeRTa; parenthood aFeDW.\n",
+        "Lr! QT! FGplFT DFsRTe; personally eFsDW.\n",
+        "Lo! QT! FGplFT DFnRTh; phonically hFnDW.\n",
+        "Lr! QT! FGplFT DFaRTi; pirandello iFaDW.\n",
+        "Le! QT! FGplFT DFtRTo; poetically oFtDW.\n",
+        "Lw! QT! FGplFT DFeRTo; powerfully oFeDW.\n",
+        "Li! QT! FGpoFT DFeRTr; priesthood rFeDW.\n",
+        "Lo! QT! FGplFT DFdRTr; prodigally rFdDW.\n",
+        "Lg! QT! FGrlFT DFiRTe; regionally eFiDW.\n",
+        "Lg! QT! FGrlFT DFhRTi; rightfully iFhDW.\n",
+        "Ls! QT! FGrlFT DFtRTu; rustically uFtDW.\n",
+        "Lo! QT! FGslFT DFrRTc; scornfully cFrDW.\n",
+        "La! QT! FGslFT DFmRTh; shamefully hFmDW.\n",
+        "Li! QT! FGslFT DFtRTp; spitefully pFtDW.\n",
+        "Lu! QT! FGsoFT DFiRTq; squirehood qFiDW.\n",
+        "Lr! QT! FGslFT DFgRTu; surgically uFgDW.\n",
+        "Lb! QT! FGtoFT DFlRTa; tablespoon aFlDW.\n",
+        "Lm! QT! FGtlFT DFpRTe; temporally eFpDW.\n",
+        "Lr! QT! FGtlFT DFmRTe; terminally eFmDW.\n",
+        "La! QT! FGtlFT DFnRTh; thankfully hFnDW.\n",
+        "La! QT! FGtlFT DFnRTr; tranquilly rFnDW.\n",
+        "Le! QT! FGtlFT DFaRTr; treadmills rFaDW.\n",
+        "Ld! QT! FGuoFT DFeRTn; undershoot nFeDW.\n",
+        "Lr! QT! FGvlFT DFtRTe; vertically eFtDW.\n",
+        "Ls! QT! FGwlFT DFtRTa; wastefully aFtDW.\n",
+        "Lt! QT! FGwlFT DFcRTa; watchfully aFcDW.\n",
+        "La! QT! FGwlFT DFtRTr; wrathfully rFtDW.\n",
+        "Lo! QT! FGwlFT DFnRTr; wrongfully rFnDW.\n"
+       ]
+      }
+     ],
+     "prompt_number": 20
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "ct"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "metadata": {},
+       "output_type": "pyout",
+       "prompt_number": 21,
+       "text": [
+        "'LJ! Qt! Fghxft dferts; hsjeukaxxn sfedw.'"
+       ]
+      }
+     ],
+     "prompt_number": 21
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "for s4 in seeds4:\n",
+      "    for s2 in seeds2:\n",
+      "        if s2[2] == s4[0] and s2[3] == s4[8]:\n",
+      "            transdict = {f: t for f, t in zip(ctu4 + ctu2, s4 + s2)}\n",
+      "            if len(set(transdict.values())) == len(transdict):\n",
+      "                print(ctu.translate(''.maketrans(transdict)))"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [
+      {
+       "output_type": "stream",
+       "stream": "stdout",
+       "text": [
+        "Lo! Qs! phelps DptRsr; erotically rptDW.\n",
+        "Lo! Qs! phelps DptRsx; exotically xptDW.\n",
+        "Lf! Qd! exiled DeoRdn; informally neoDW.\n",
+        "Lf! Qs! exiles DeoRsn; informally neoDW.\n",
+        "Lg! Qs! nylons DnhRsi; lightproof inhDW.\n",
+        "Le! Qg! unplug DutRgo; poetically outDW.\n",
+        "Lg! Qs! earles DehRsi; rightfully iehDW.\n"
+       ]
+      }
+     ],
+     "prompt_number": 25
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [
+      "for s4 in seeds4:\n",
+      "    for s2 in seeds2:\n",
+      "        if s2[2] == s4[0] and s2[3] == s4[8]:\n",
+      "            for s3 in seeds3:\n",
+      "                if s3[1] == s2[0] and s3[2] == s4[3] and s3[4] == s2[5] and s3[5] == s4[1]:\n",
+      "                    transdict = {f: t for f, t in zip(ctu4 + ctu2 + ctu3, s4 + s2 + s3)}\n",
+      "                    if len(set(transdict.values())) == len(transdict):\n",
+      "                        print(ctu.translate(''.maketrans(transdict)))"
+     ],
+     "language": "python",
+     "metadata": {},
+     "outputs": [],
+     "prompt_number": 28
+    },
+    {
+     "cell_type": "code",
+     "collapsed": false,
+     "input": [],
+     "language": "python",
+     "metadata": {},
+     "outputs": []
+    }
+   ],
+   "metadata": {}
+  }
+ ]
+}
\ No newline at end of file