From: Neil Smith Date: Sun, 23 Oct 2016 13:08:09 +0000 (+0100) Subject: Cleaner way of dealing with punctuation in C1b X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=774098d019cdd42b232bbe867ddc0d347eb6c28c;p=cipher-tools.git Cleaner way of dealing with punctuation in C1b --- diff --git a/2016/2016-challenge1.ipynb b/2016/2016-challenge1.ipynb index 5310e98..1317191 100644 --- a/2016/2016-challenge1.ipynb +++ b/2016/2016-challenge1.ipynb @@ -97,7 +97,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 5, "metadata": { "collapsed": false }, @@ -108,7 +108,7 @@ "\"E TOY'P ZEPGLST OY PZED LSET YZTE. AZYLP GLSEYZOTZD HZ YPCP, SPYZW LELSEZOYLN TH ZSPPDE. YLN TE TIT QZEO, PEC L EDP'G LSES RTX, PHC PSEP RZ EEF MJE WT FRSE ZMPC LPHOY. L RYT'Y PAALS DLH ELSH ZEOY TW, MS EZMP CPHP HPXYL SE PCZX XTS PXLWMEYLN TPY ZW LSE THWL POZERT, MZZ EDTDTSEO YL XTSOY TQEY LNTOYLP YZ RDL SP. S EFM'O PPC RLP H RYT SE JCPG PCPEQ, LOTL, DPH. RY T SEJ'C PGPC PE QLELSE. PV TWE QP WPS. P GPTW PM EYL NT.\\n\"" ] }, - "execution_count": 20, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -119,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 6, "metadata": { "collapsed": false }, @@ -136,6 +136,78 @@ "print(wcat(segment(cat(reversed(sanitise(caesar_decipher(c1b, key_b)))))))" ] }, + { + "cell_type": "code", + "execution_count": 10, + "metadata": { + "collapsed": false, + "scrolled": true + }, + "outputs": [ + { + "data": { + "text/plain": [ + "[1, 5, 7, 15, 18, 23, 28, 33, 34, 40]" + ] + }, + "execution_count": 10, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "nonletters = [i for i in range(len(c1b)) if c1b[i] not in string.ascii_letters]\n", + "nonletters[:10]" + ] + }, + { + "cell_type": "code", + "execution_count": 11, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "'icantbelieveheleftlikethataftereverythingwesaidaftereverythingweagreedbuthehasgoneandicantfindhimandthisistoobigtodealwithaloneicantblamehimmorethanmewewerebothblindtowhatwashappeningandwearebothguiltybuttogetherwemighthavestartedtofixiticantseehowicandothataloneherenowsoidonthaveanoptionithastoendihavetoendit'" + ] + }, + "execution_count": 11, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "p1bs = cat(reversed(sanitise(caesar_decipher(c1b, key_b))))\n", + "p1bs" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "collapsed": false + }, + "outputs": [ + { + "data": { + "text/plain": [ + "\"i can't believe he left like that. after everything we said, after everything we agreed. but he has gone, and i can't find him, and this is too big to deal with alone. i can't blame him more than me, we were both blind to what was happening and we are both guilty, but together we might have started to fix it. i can't see how i can do that alone, here, now. so i don't have an option. it has to end. i have to end it.\\n\"" + ] + }, + "execution_count": 12, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "p1b = p1bs\n", + "for i in nonletters:\n", + " p1b = p1b[:i] + c1b[i] + p1b[i:]\n", + "p1b" + ] + }, { "cell_type": "code", "execution_count": null,