X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=bombe.ipynb;h=e28af9aac5316617032de9fa7f1becc61f6ccea5;hb=373d3077e562c81fe35d0f68e6b8e10983908b6c;hp=93e0ccbfcd5ac4996251c5eb08db7e6deadd969b;hpb=60a697926e04e109769b205534c08eeac712a28f;p=cipher-tools.git diff --git a/bombe.ipynb b/bombe.ipynb index 93e0ccb..e28af9a 100644 --- a/bombe.ipynb +++ b/bombe.ipynb @@ -75,9 +75,9 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 4, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -164,7 +164,10 @@ " self.pending += [Signal(current.wire, current.bank)]\n", " for c in self.connections:\n", " if current.bank in c.banks:\n", - " other_bank = [b for b in c.banks if b != current.bank][0]\n", + " if len(set(c.banks)) == 1:\n", + " other_bank = c.banks[0]\n", + " else:\n", + " other_bank = [b for b in c.banks if b != current.bank][0]\n", " other_wire = c.scrambler.lookup(current.wire)\n", " # print(\" adding\", other_bank, other_wire, \"because\", c.banks)\n", " self.pending += [Signal(other_bank, other_wire)]\n", @@ -200,9 +203,9 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 5, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -212,7 +215,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 6, "metadata": { "collapsed": true }, @@ -228,10 +231,8 @@ }, { "cell_type": "code", - "execution_count": 34, - "metadata": { - "collapsed": false - }, + "execution_count": 7, + "metadata": {}, "outputs": [ { "data": { @@ -239,7 +240,7 @@ "'opgndxcrwomnlnecjz'" ] }, - "execution_count": 34, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -253,10 +254,8 @@ }, { "cell_type": "code", - "execution_count": 35, - "metadata": { - "collapsed": false - }, + "execution_count": 8, + "metadata": {}, "outputs": [ { "data": { @@ -264,7 +263,7 @@ "'aas'" ] }, - "execution_count": 35, + "execution_count": 8, "metadata": {}, "output_type": "execute_result" } @@ -275,10 +274,8 @@ }, { "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, + "execution_count": 9, + "metadata": {}, "outputs": [ { "data": { @@ -303,7 +300,7 @@ " MenuIem(before='e', after='z', number=18)]" ] }, - "execution_count": 36, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -315,7 +312,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 10, "metadata": { "collapsed": true }, @@ -328,10 +325,8 @@ }, { "cell_type": "code", - "execution_count": 38, - "metadata": { - "collapsed": false - }, + "execution_count": 11, + "metadata": {}, "outputs": [ { "data": { @@ -356,7 +351,7 @@ " MenuIem(before='e', after='z', number=18)]" ] }, - "execution_count": 38, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -367,10 +362,8 @@ }, { "cell_type": "code", - "execution_count": 39, - "metadata": { - "collapsed": false - }, + "execution_count": 12, + "metadata": {}, "outputs": [ { "data": { @@ -378,7 +371,7 @@ "'s'" ] }, - "execution_count": 39, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -389,9 +382,9 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 13, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -400,10 +393,8 @@ }, { "cell_type": "code", - "execution_count": 43, - "metadata": { - "collapsed": false - }, + "execution_count": 14, + "metadata": {}, "outputs": [ { "data": { @@ -411,7 +402,7 @@ "18" ] }, - "execution_count": 43, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -422,33 +413,13 @@ }, { "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": false - }, + "execution_count": 15, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "['t', 'o'] aaa\n", - "['h', 'p'] aab\n", - "['i', 'g'] aac\n", - "['s', 'n'] aad\n", - "['i', 'd'] aae\n", - "['s', 'x'] aaf\n", - "['a', 'c'] aag\n", - "['t', 'r'] aah\n", - "['e', 'w'] aai\n", - "['s', 'o'] aaj\n", - "['t', 'm'] aak\n", - "['m', 'n'] aal\n", - "['e', 'l'] aam\n", - "['s', 'n'] aan\n", - "['s', 'e'] aao\n", - "['a', 'c'] aap\n", - "['g', 'j'] aaq\n", - "['e', 'z'] aar\n", "['t', 'o'] aaa\n", "['h', 'p'] aab\n", "['i', 'g'] aac\n", @@ -477,10 +448,8 @@ }, { "cell_type": "code", - "execution_count": 44, - "metadata": { - "collapsed": false - }, + "execution_count": 16, + "metadata": {}, "outputs": [ { "data": { @@ -488,7 +457,7 @@ "'ot:hp:gi:ns:di:sx:ac:rt:ew:os:mt:mn:el:ns:es:ac:gj:ez'" ] }, - "execution_count": 44, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -499,10 +468,8 @@ }, { "cell_type": "code", - "execution_count": 45, - "metadata": { - "collapsed": false - }, + "execution_count": 17, + "metadata": {}, "outputs": [ { "data": { @@ -510,7 +477,7 @@ "'aaa:aab:aac:aad:aae:aaf:aag:aah:aai:aaj:aak:aal:aam:aan:aao:aap:aaq:aar'" ] }, - "execution_count": 45, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -521,18 +488,16 @@ }, { "cell_type": "code", - "execution_count": 56, - "metadata": { - "collapsed": false - }, + "execution_count": 18, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "True" + "False" ] }, - "execution_count": 56, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -543,43 +508,41 @@ }, { "cell_type": "code", - "execution_count": 57, - "metadata": { - "collapsed": false - }, + "execution_count": 19, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{'a': False,\n", - " 'b': False,\n", - " 'c': False,\n", - " 'd': False,\n", - " 'e': False,\n", - " 'f': False,\n", - " 'g': False,\n", - " 'h': False,\n", - " 'i': False,\n", - " 'j': False,\n", - " 'k': False,\n", - " 'l': False,\n", - " 'm': False,\n", - " 'n': False,\n", - " 'o': False,\n", - " 'p': False,\n", - " 'q': False,\n", - " 'r': False,\n", - " 's': False,\n", + "{'a': True,\n", + " 'b': True,\n", + " 'c': True,\n", + " 'd': True,\n", + " 'e': True,\n", + " 'f': True,\n", + " 'g': True,\n", + " 'h': True,\n", + " 'i': True,\n", + " 'j': True,\n", + " 'k': True,\n", + " 'l': True,\n", + " 'm': True,\n", + " 'n': True,\n", + " 'o': True,\n", + " 'p': True,\n", + " 'q': True,\n", + " 'r': True,\n", + " 's': True,\n", " 't': True,\n", - " 'u': False,\n", - " 'v': False,\n", - " 'w': False,\n", - " 'x': False,\n", - " 'y': False,\n", - " 'z': False}" + " 'u': True,\n", + " 'v': True,\n", + " 'w': True,\n", + " 'x': True,\n", + " 'y': True,\n", + " 'z': True}" ] }, - "execution_count": 57, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -590,10 +553,8 @@ }, { "cell_type": "code", - "execution_count": 48, - "metadata": { - "collapsed": false - }, + "execution_count": 20, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -641,10 +602,8 @@ }, { "cell_type": "code", - "execution_count": 49, - "metadata": { - "collapsed": false - }, + "execution_count": 21, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -692,10 +651,8 @@ }, { "cell_type": "code", - "execution_count": 50, - "metadata": { - "collapsed": false - }, + "execution_count": 22, + "metadata": {}, "outputs": [ { "data": { @@ -703,7 +660,7 @@ "('a', 'a', 'a')" ] }, - "execution_count": 50, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -714,10 +671,8 @@ }, { "cell_type": "code", - "execution_count": 51, - "metadata": { - "collapsed": false - }, + "execution_count": 23, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -752,9 +707,9 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 24, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -764,10 +719,8 @@ }, { "cell_type": "code", - "execution_count": 53, - "metadata": { - "collapsed": false - }, + "execution_count": 25, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -818,10 +771,8 @@ }, { "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": false - }, + "execution_count": 26, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -872,10 +823,8 @@ }, { "cell_type": "code", - "execution_count": 55, - "metadata": { - "collapsed": false - }, + "execution_count": 27, + "metadata": {}, "outputs": [ { "data": { @@ -883,7 +832,7 @@ "1" ] }, - "execution_count": 55, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -894,9 +843,9 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 28, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -907,9 +856,9 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 29, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -920,10 +869,8 @@ }, { "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": false - }, + "execution_count": 30, + "metadata": {}, "outputs": [ { "data": { @@ -931,7 +878,7 @@ "('a', 'a', 'b')" ] }, - "execution_count": 27, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -942,10 +889,8 @@ }, { "cell_type": "code", - "execution_count": 28, - "metadata": { - "collapsed": false - }, + "execution_count": 31, + "metadata": {}, "outputs": [ { "data": { @@ -953,7 +898,7 @@ "False" ] }, - "execution_count": 28, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -964,10 +909,8 @@ }, { "cell_type": "code", - "execution_count": 29, - "metadata": { - "collapsed": false - }, + "execution_count": 32, + "metadata": {}, "outputs": [ { "data": { @@ -975,7 +918,7 @@ "('p', 'p', 'p')" ] }, - "execution_count": 29, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -986,10 +929,8 @@ }, { "cell_type": "code", - "execution_count": 30, - "metadata": { - "collapsed": false - }, + "execution_count": 33, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -1037,10 +978,8 @@ }, { "cell_type": "code", - "execution_count": 31, - "metadata": { - "collapsed": false - }, + "execution_count": 34, + "metadata": {}, "outputs": [ { "data": { @@ -1048,7 +987,7 @@ "17576" ] }, - "execution_count": 31, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -1060,10 +999,8 @@ }, { "cell_type": "code", - "execution_count": 32, - "metadata": { - "collapsed": false - }, + "execution_count": 35, + "metadata": {}, "outputs": [ { "data": { @@ -1071,7 +1008,7 @@ "(('a', 'a', 'b'), True)" ] }, - "execution_count": 32, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -1083,9 +1020,9 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 36, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -1094,10 +1031,8 @@ }, { "cell_type": "code", - "execution_count": 34, - "metadata": { - "collapsed": false - }, + "execution_count": 37, + "metadata": {}, "outputs": [ { "data": { @@ -1105,7 +1040,7 @@ "[('a', 'a', 'b')]" ] }, - "execution_count": 34, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -1121,7 +1056,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 38, "metadata": { "collapsed": true }, @@ -1143,10 +1078,8 @@ }, { "cell_type": "code", - "execution_count": 36, - "metadata": { - "collapsed": false - }, + "execution_count": 39, + "metadata": {}, "outputs": [ { "data": { @@ -1154,7 +1087,7 @@ "[('a', 'a', 'b')]" ] }, - "execution_count": 36, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -1165,9 +1098,9 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 40, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -1184,10 +1117,8 @@ }, { "cell_type": "code", - "execution_count": 59, - "metadata": { - "collapsed": false - }, + "execution_count": 41, + "metadata": {}, "outputs": [ { "data": { @@ -1195,7 +1126,7 @@ "('e', 'l', 'e')" ] }, - "execution_count": 59, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -1207,10 +1138,8 @@ }, { "cell_type": "code", - "execution_count": 39, - "metadata": { - "collapsed": false - }, + "execution_count": 42, + "metadata": {}, "outputs": [ { "data": { @@ -1218,7 +1147,7 @@ "'dhnpforeeimgg'" ] }, - "execution_count": 39, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -1232,10 +1161,8 @@ }, { "cell_type": "code", - "execution_count": 40, - "metadata": { - "collapsed": false - }, + "execution_count": 43, + "metadata": {}, "outputs": [ { "data": { @@ -1243,7 +1170,7 @@ "('j', 'e', 'o')" ] }, - "execution_count": 40, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } @@ -1254,10 +1181,8 @@ }, { "cell_type": "code", - "execution_count": 41, - "metadata": { - "collapsed": false - }, + "execution_count": 44, + "metadata": {}, "outputs": [ { "data": { @@ -1277,7 +1202,7 @@ " MenuIem(before='t', after='g', number=13)]" ] }, - "execution_count": 41, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } @@ -1289,9 +1214,8 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 45, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -1362,7 +1286,7 @@ " ('z', 'z', 'k')]" ] }, - "execution_count": 42, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -1379,10 +1303,8 @@ }, { "cell_type": "code", - "execution_count": 43, - "metadata": { - "collapsed": false - }, + "execution_count": 46, + "metadata": {}, "outputs": [ { "data": { @@ -1390,7 +1312,7 @@ "62" ] }, - "execution_count": 43, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -1401,9 +1323,8 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 47, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -1425,7 +1346,7 @@ " ('y', 'n', 'c')]" ] }, - "execution_count": 44, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } @@ -1442,10 +1363,8 @@ }, { "cell_type": "code", - "execution_count": 45, - "metadata": { - "collapsed": false - }, + "execution_count": 48, + "metadata": {}, "outputs": [ { "data": { @@ -1465,7 +1384,7 @@ " ('y', 'n', 'c')]" ] }, - "execution_count": 45, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } @@ -1476,9 +1395,9 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 49, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -1493,10 +1412,8 @@ }, { "cell_type": "code", - "execution_count": 47, - "metadata": { - "collapsed": false - }, + "execution_count": 50, + "metadata": {}, "outputs": [ { "data": { @@ -1504,7 +1421,7 @@ "13" ] }, - "execution_count": 47, + "execution_count": 50, "metadata": {}, "output_type": "execute_result" } @@ -1515,9 +1432,9 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 51, "metadata": { - "collapsed": false + "collapsed": true }, "outputs": [], "source": [ @@ -1527,10 +1444,8 @@ }, { "cell_type": "code", - "execution_count": 49, - "metadata": { - "collapsed": false - }, + "execution_count": 52, + "metadata": {}, "outputs": [ { "data": { @@ -1538,7 +1453,7 @@ "Signal(bank='e', wire='e')" ] }, - "execution_count": 49, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -1549,10 +1464,8 @@ }, { "cell_type": "code", - "execution_count": 50, - "metadata": { - "collapsed": false - }, + "execution_count": 53, + "metadata": {}, "outputs": [ { "data": { @@ -1560,7 +1473,7 @@ "True" ] }, - "execution_count": 50, + "execution_count": 53, "metadata": {}, "output_type": "execute_result" } @@ -1571,10 +1484,8 @@ }, { "cell_type": "code", - "execution_count": 51, - "metadata": { - "collapsed": false - }, + "execution_count": 54, + "metadata": {}, "outputs": [ { "data": { @@ -1582,7 +1493,7 @@ "True" ] }, - "execution_count": 51, + "execution_count": 54, "metadata": {}, "output_type": "execute_result" } @@ -1593,10 +1504,8 @@ }, { "cell_type": "code", - "execution_count": 52, - "metadata": { - "collapsed": false - }, + "execution_count": 55, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -1647,10 +1556,8 @@ }, { "cell_type": "code", - "execution_count": 53, - "metadata": { - "collapsed": false - }, + "execution_count": 56, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -1701,23 +1608,21 @@ }, { "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": false - }, + "execution_count": 57, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{frozenset({'m'}),\n", + "{frozenset({'t', 'x'}),\n", " frozenset({'i', 'n'}),\n", - " frozenset({'f', 'p'}),\n", - " frozenset({'t', 'x'}),\n", + " frozenset({'m'}),\n", " frozenset({'e', 'y'}),\n", + " frozenset({'f', 'p'}),\n", " frozenset({'b', 'g'})}" ] }, - "execution_count": 54, + "execution_count": 57, "metadata": {}, "output_type": "execute_result" } @@ -1729,10 +1634,8 @@ }, { "cell_type": "code", - "execution_count": 55, - "metadata": { - "collapsed": false - }, + "execution_count": 58, + "metadata": {}, "outputs": [ { "data": { @@ -1740,7 +1643,7 @@ "True" ] }, - "execution_count": 55, + "execution_count": 58, "metadata": {}, "output_type": "execute_result" } @@ -1751,21 +1654,19 @@ }, { "cell_type": "code", - "execution_count": 56, - "metadata": { - "collapsed": false - }, + "execution_count": 59, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "({frozenset({1, 2}), frozenset({3, 4}), frozenset({2, 3})},\n", + "({frozenset({1, 2}), frozenset({2, 3}), frozenset({3, 4})},\n", " frozenset({1, 2}),\n", " frozenset({3, 4}),\n", " frozenset({2, 3}))" ] }, - "execution_count": 56, + "execution_count": 59, "metadata": {}, "output_type": "execute_result" } @@ -1784,10 +1685,8 @@ }, { "cell_type": "code", - "execution_count": 57, - "metadata": { - "collapsed": false - }, + "execution_count": 60, + "metadata": {}, "outputs": [ { "data": { @@ -1795,7 +1694,7 @@ "False" ] }, - "execution_count": 57, + "execution_count": 60, "metadata": {}, "output_type": "execute_result" } @@ -1806,10 +1705,8 @@ }, { "cell_type": "code", - "execution_count": 58, - "metadata": { - "collapsed": false - }, + "execution_count": 61, + "metadata": {}, "outputs": [ { "data": { @@ -1817,7 +1714,7 @@ "False" ] }, - "execution_count": 58, + "execution_count": 61, "metadata": {}, "output_type": "execute_result" } @@ -1826,6 +1723,223 @@ "{1, 2}.isdisjoint({1, 6})" ] }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Tsest" + ] + }, + { + "cell_type": "code", + "execution_count": 62, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'slgncszxltkzebghstgywdmpr'" + ] + }, + "execution_count": 62, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "target_ct = ''.join(c.lower() for c in 'SLGNC SZXLT KZEBG HSTGY WDMPR' if c in string.ascii_letters)\n", + "target_ct" + ] + }, + { + "cell_type": "code", + "execution_count": 63, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "'theyweredetectedbybritishshipsinclud'" + ] + }, + "execution_count": 63, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "target_pt = ''.join(c.lower() for c in 'Theyw erede tecte d byBri tishs hipsi nclud' if c in string.ascii_letters)\n", + "target_pt" + ] + }, + { + "cell_type": "code", + "execution_count": 64, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[MenuIem(before='w', after='c', number=1),\n", + " MenuIem(before='e', after='s', number=2),\n", + " MenuIem(before='r', after='z', number=3),\n", + " MenuIem(before='e', after='x', number=4),\n", + " MenuIem(before='d', after='l', number=5),\n", + " MenuIem(before='e', after='t', number=6),\n", + " MenuIem(before='t', after='k', number=7),\n", + " MenuIem(before='e', after='z', number=8),\n", + " MenuIem(before='c', after='e', number=9),\n", + " MenuIem(before='t', after='b', number=10),\n", + " MenuIem(before='e', after='g', number=11),\n", + " MenuIem(before='d', after='h', number=12),\n", + " MenuIem(before='b', after='s', number=13),\n", + " MenuIem(before='y', after='t', number=14),\n", + " MenuIem(before='b', after='g', number=15),\n", + " MenuIem(before='r', after='y', number=16),\n", + " MenuIem(before='i', after='w', number=17),\n", + " MenuIem(before='t', after='d', number=18),\n", + " MenuIem(before='i', after='m', number=19),\n", + " MenuIem(before='s', after='p', number=20)]" + ] + }, + "execution_count": 64, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tbt_menu = [MenuItem(p, c, i+1) for i, (p, c) in enumerate(zip(target_pt[4:24], target_ct[4:24]))]\n", + "tbt_menu" + ] + }, + { + "cell_type": "code", + "execution_count": 65, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "tbt_bombe = Bombe(wheel_iii_spec, wheel_i_spec, wheel_ii_spec, reflector_b_spec, \n", + " menu=tbt_menu)" + ] + }, + { + "cell_type": "code", + "execution_count": 66, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[('k', 'r', 'n')]" + ] + }, + "execution_count": 66, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tbt_wheel_posns = run_multi_bombe(wheel_iii_spec, wheel_i_spec, wheel_ii_spec, reflector_b_spec, tbt_menu)\n", + "tbt_wheel_posns" + ] + }, + { + "cell_type": "code", + "execution_count": 67, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "Signal(bank='e', wire='e')" + ] + }, + "execution_count": 67, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "tbt_bombe.test_start" + ] + }, + { + "cell_type": "code", + "execution_count": 68, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "False\n", + "a : abcdefghi..lmnop.rst.v.x.z\n", + "b : a...ef.hi..lmnop.r.t...x..\n", + "c : a..defg.i..lmn.p.rst...x..\n", + "d : a.c.efghi.klmnopqrstu.wxyz\n", + "e : abcdefghijklmnopqrstuvwx.z\n", + "f : abcdefghijklmno.qrstuvwxyz\n", + "g : a.cdefghijklmnopqrstuvwxyz\n", + "h : ab.defghi...mnopqrstuvwxyz\n", + "i : abcdefghijklm.opqrstuvwxyz\n", + "j : ....efg.i..lmnop...t...x..\n", + "k : ...defg.i..lmn.p..st...x..\n", + "l : abcdefg.ijklmnopqrstuv.x..\n", + "m : abcdefghijkl.nopqrstuvwxyz\n", + "n : abcdefgh.jklmnopqrstuvwxyz\n", + "o : ab.defghij.lmnop.r.tuvwxyz\n", + "p : abcde.ghijklmnopqrstuvwxyz\n", + "q : ...defghi..lmn.p..st...x..\n", + "r : abcdefghi..lmnop.rst.v.x.z\n", + "s : a.cdefghi.klmn.pqr.tuvwxyz\n", + "t : abcdefghijklmnopqrstuvw.yz\n", + "u : ...defghi..lmnop..st...x..\n", + "v : a...efghi..lmnop.rst...x..\n", + "w : ...defghi...mnop..st...x..\n", + "x : abcdefghijklmnopqrs.uvwxyz\n", + "y : ...d.fghi...mnop..st...x..\n", + "z : a..defghi...mnop.rst...x..\n" + ] + } + ], + "source": [ + "r = tbt_bombe.test(start_positions=('l', 's', 'd'))\n", + "print(r)\n", + "for b in sorted(w_bombe.banks):\n", + " print(b, ': ', end='')\n", + " for w in sorted(w_bombe.banks[b]):\n", + " if w_bombe.banks[b][w]:\n", + " print(w, end='')\n", + " else:\n", + " print('.', end='')\n", + " print('')\n" + ] + }, + { + "cell_type": "code", + "execution_count": 69, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "set()" + ] + }, + "execution_count": 69, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "ps = tbt_bombe.possible_plugboards()\n", + "ps" + ] + }, { "cell_type": "code", "execution_count": null, @@ -1852,9 +1966,9 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.1+" + "version": "3.5.3" } }, "nbformat": 4, - "nbformat_minor": 0 + "nbformat_minor": 1 }