"cells": [
{
"cell_type": "code",
- "execution_count": 2,
+ "execution_count": 1,
"metadata": {
"collapsed": true
},
},
{
"cell_type": "code",
- "execution_count": 3,
- "metadata": {
- "collapsed": true
- },
- "outputs": [],
- "source": [
- "# wheel_i_spec = 'ekmflgdqvzntowyhxuspaibrcj'\n",
- "# wheel_ii_spec = 'ajdksiruxblhwtmcqgznpyfvoe'\n",
- "# wheel_iii_spec = 'bdfhjlcprtxvznyeiwgakmusqo'\n",
- "# wheel_iv_spec = 'esovpzjayquirhxlnftgkdcmwb'\n",
- "# wheel_v_spec = 'vzbrgityupsdnhlxawmjqofeck'\n",
- "# wheel_vi_spec = 'jpgvoumfyqbenhzrdkasxlictw'\n",
- "# wheel_vii_spec = 'nzjhgrcxmyswboufaivlpekqdt'\n",
- "# wheel_viii_spec = 'fkqhtlxocbjspdzramewniuygv'\n",
- "# beta_wheel_spec = 'leyjvcnixwpbqmdrtakzgfuhos'\n",
- "# gamma_wheel_spec = 'fsokanuerhmbtiycwlqpzxvgjd'\n",
- "\n",
- "# wheel_i_pegs = ['q']\n",
- "# wheel_ii_pegs = ['e']\n",
- "# wheel_iii_pegs = ['v']\n",
- "# wheel_iv_pegs = ['j']\n",
- "# wheel_v_pegs = ['z']\n",
- "# wheel_vi_pegs = ['z', 'm']\n",
- "# wheel_vii_pegs = ['z', 'm']\n",
- "# wheel_viii_pegs = ['z', 'm']\n",
- "\n",
- "# reflector_b_spec = 'ay br cu dh eq fs gl ip jx kn mo tz vw'\n",
- "# reflector_c_spec = 'af bv cp dj ei go hy kr lz mx nw tq su'"
- ]
- },
- {
- "cell_type": "code",
- "execution_count": 4,
+ "execution_count": 2,
"metadata": {
"collapsed": true
},
},
{
"cell_type": "code",
- "execution_count": 5,
+ "execution_count": 3,
"metadata": {
"collapsed": true
},
},
{
"cell_type": "code",
- "execution_count": 6,
+ "execution_count": 4,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
" self.connections += [Connection([bank_before, bank_after], scrambler)]\n",
" \n",
" def read_menu(self, menu):\n",
+ " self.connections = []\n",
" for item in menu:\n",
" scrambler = Scrambler(self.wheel1_spec, self.wheel2_spec, self.wheel3_spec,\n",
" self.reflector_spec,\n",
" 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",
},
{
"cell_type": "code",
- "execution_count": 804,
+ "execution_count": 5,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 805,
+ "execution_count": 6,
"metadata": {
"collapsed": true
},
},
{
"cell_type": "code",
- "execution_count": 806,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 7,
+ "metadata": {},
"outputs": [
{
"data": {
"'opgndxcrwomnlnecjz'"
]
},
- "execution_count": 806,
+ "execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 807,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 8,
+ "metadata": {},
"outputs": [
{
"data": {
"'aas'"
]
},
- "execution_count": 807,
+ "execution_count": 8,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 808,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 9,
+ "metadata": {},
"outputs": [
{
"data": {
" MenuIem(before='e', after='z', number=18)]"
]
},
- "execution_count": 808,
+ "execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 809,
+ "execution_count": 10,
"metadata": {
"collapsed": true
},
},
{
"cell_type": "code",
- "execution_count": 810,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 11,
+ "metadata": {},
"outputs": [
{
"data": {
" MenuIem(before='e', after='z', number=18)]"
]
},
- "execution_count": 810,
+ "execution_count": 11,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 811,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 12,
+ "metadata": {},
"outputs": [
{
"data": {
"'s'"
]
},
- "execution_count": 811,
+ "execution_count": 12,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 812,
+ "execution_count": 13,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 813,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 14,
+ "metadata": {},
"outputs": [
{
"data": {
"18"
]
},
- "execution_count": 813,
+ "execution_count": 14,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 814,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 15,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
},
{
"cell_type": "code",
- "execution_count": 815,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 16,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'ot:hp:gi:ns:di:sx:ac:rt:ew:os:mt:mn:el:ns:es:ac:gj:ez'"
+ ]
+ },
+ "execution_count": 16,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "':'.join(cat(sorted(c.banks)) for c in bombe.connections)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 17,
+ "metadata": {},
+ "outputs": [
+ {
+ "data": {
+ "text/plain": [
+ "'aaa:aab:aac:aad:aae:aaf:aag:aah:aai:aaj:aak:aal:aam:aan:aao:aap:aaq:aar'"
+ ]
+ },
+ "execution_count": 17,
+ "metadata": {},
+ "output_type": "execute_result"
+ }
+ ],
+ "source": [
+ "':'.join(cat(c.scrambler.wheel_positions_l) for c in bombe.connections)"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 18,
+ "metadata": {},
"outputs": [
{
"data": {
"False"
]
},
- "execution_count": 815,
+ "execution_count": 18,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 816,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 19,
+ "metadata": {},
"outputs": [
{
"data": {
" 'z': True}"
]
},
- "execution_count": 816,
+ "execution_count": 19,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 817,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 20,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
},
{
"cell_type": "code",
- "execution_count": 818,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 21,
+ "metadata": {},
+ "outputs": [
+ {
+ "name": "stdout",
+ "output_type": "stream",
+ "text": [
+ "a : abcdefghijklmnopqrstuvwxyz\n",
+ "b : a.cde.ghij.lmnop.rst..wx.z\n",
+ "c : abcdefghijklmnopqrstuvwxyz\n",
+ "d : abcdefghijklmnopqrstuvwx.z\n",
+ "e : abcdefghijklmnopqrstuvwxyz\n",
+ "f : a.cde.ghij.lmnop.rst..wx.z\n",
+ "g : abcdefghijklmnopqrst.vwxyz\n",
+ "h : abcdefghijklmnopqrstuvwxyz\n",
+ "i : abcdefghijklmnopqrstu.wxyz\n",
+ "j : abcdefghi.klmnopqrstuvwxyz\n",
+ "k : a.cde.ghij.lmnop.rst..wx.z\n",
+ "l : abcdefghijklmnopqrstuvwxyz\n",
+ "m : abcdefghijklmnopqrstuvwxyz\n",
+ "n : abcdefghijklmnopqrstuvwxyz\n",
+ "o : abcdefghijklmnopqrstuvwxyz\n",
+ "p : abcdefghijklmnopqrstuvwxyz\n",
+ "q : a.cde.ghij.lmnop.rst..wx.z\n",
+ "r : abcdefghijklmnopqrstuvwxyz\n",
+ "s : abcdefghijklmnopqrstuvwxyz\n",
+ "t : abcdefghijklmnopqrstuvwxyz\n",
+ "u : a.cde..hij.lmnop.rst..wx.z\n",
+ "v : a.cde.gh.j.lmnop.rst..wx.z\n",
+ "w : abcdefghijklmnopqrstuvwxyz\n",
+ "x : abcdefghijklmnopqrstuvwxyz\n",
+ "y : a.c.e.ghij.lmnop.rst..wx.z\n",
+ "z : abcdefghijklmnopqrstuvwxyz\n"
+ ]
+ }
+ ],
+ "source": [
+ "for b in sorted(bombe.banks):\n",
+ " print(b, ': ', end='')\n",
+ " for w in sorted(bombe.banks[b]):\n",
+ " if bombe.banks[b][w]:\n",
+ " print(w, end='')\n",
+ " else:\n",
+ " print('.', end='')\n",
+ " print('')"
+ ]
+ },
+ {
+ "cell_type": "code",
+ "execution_count": 22,
+ "metadata": {},
"outputs": [
{
"data": {
"('a', 'a', 'a')"
]
},
- "execution_count": 818,
+ "execution_count": 22,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 819,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 23,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
},
{
"cell_type": "code",
- "execution_count": 820,
+ "execution_count": 24,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 821,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 25,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
},
{
"cell_type": "code",
- "execution_count": 822,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 26,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
},
{
"cell_type": "code",
- "execution_count": 823,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 27,
+ "metadata": {},
"outputs": [
{
"data": {
"1"
]
},
- "execution_count": 823,
+ "execution_count": 27,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 824,
+ "execution_count": 28,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 825,
+ "execution_count": 29,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 826,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 30,
+ "metadata": {},
"outputs": [
{
"data": {
"('a', 'a', 'b')"
]
},
- "execution_count": 826,
+ "execution_count": 30,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 827,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 31,
+ "metadata": {},
"outputs": [
{
"data": {
"False"
]
},
- "execution_count": 827,
+ "execution_count": 31,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 828,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 32,
+ "metadata": {},
"outputs": [
{
"data": {
"('p', 'p', 'p')"
]
},
- "execution_count": 828,
+ "execution_count": 32,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 829,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 33,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
},
{
"cell_type": "code",
- "execution_count": 830,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 34,
+ "metadata": {},
"outputs": [
{
"data": {
"17576"
]
},
- "execution_count": 830,
+ "execution_count": 34,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 831,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 35,
+ "metadata": {},
"outputs": [
{
"data": {
"(('a', 'a', 'b'), True)"
]
},
- "execution_count": 831,
+ "execution_count": 35,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 832,
+ "execution_count": 36,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 833,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 37,
+ "metadata": {},
"outputs": [
{
"data": {
"[('a', 'a', 'b')]"
]
},
- "execution_count": 833,
+ "execution_count": 37,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 857,
+ "execution_count": 38,
"metadata": {
"collapsed": true
},
},
{
"cell_type": "code",
- "execution_count": 835,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 39,
+ "metadata": {},
"outputs": [
{
"data": {
"[('a', 'a', 'b')]"
]
},
- "execution_count": 835,
+ "execution_count": 39,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 836,
+ "execution_count": 40,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 837,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 41,
+ "metadata": {},
"outputs": [
{
"data": {
"('e', 'l', 'e')"
]
},
- "execution_count": 837,
+ "execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 838,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 42,
+ "metadata": {},
"outputs": [
{
"data": {
"'dhnpforeeimgg'"
]
},
- "execution_count": 838,
+ "execution_count": 42,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 839,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 43,
+ "metadata": {},
"outputs": [
{
"data": {
"('j', 'e', 'o')"
]
},
- "execution_count": 839,
+ "execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 840,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 44,
+ "metadata": {},
"outputs": [
{
"data": {
" MenuIem(before='t', after='g', number=13)]"
]
},
- "execution_count": 840,
+ "execution_count": 44,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 841,
+ "execution_count": 45,
"metadata": {
- "collapsed": false,
"scrolled": true
},
"outputs": [
" ('z', 'z', 'k')]"
]
},
- "execution_count": 841,
+ "execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 842,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 46,
+ "metadata": {},
"outputs": [
{
"data": {
"62"
]
},
- "execution_count": 842,
+ "execution_count": 46,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 843,
+ "execution_count": 47,
"metadata": {
- "collapsed": false,
"scrolled": true
},
"outputs": [
" ('y', 'n', 'c')]"
]
},
- "execution_count": 843,
+ "execution_count": 47,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 858,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 48,
+ "metadata": {},
"outputs": [
{
"data": {
" ('y', 'n', 'c')]"
]
},
- "execution_count": 858,
+ "execution_count": 48,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 844,
+ "execution_count": 49,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 845,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 50,
+ "metadata": {},
"outputs": [
{
"data": {
"13"
]
},
- "execution_count": 845,
+ "execution_count": 50,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 846,
+ "execution_count": 51,
"metadata": {
- "collapsed": false
+ "collapsed": true
},
"outputs": [],
"source": [
},
{
"cell_type": "code",
- "execution_count": 847,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 52,
+ "metadata": {},
"outputs": [
{
"data": {
"Signal(bank='e', wire='e')"
]
},
- "execution_count": 847,
+ "execution_count": 52,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 848,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 53,
+ "metadata": {},
"outputs": [
{
"data": {
"True"
]
},
- "execution_count": 848,
+ "execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 849,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 54,
+ "metadata": {},
"outputs": [
{
"data": {
"True"
]
},
- "execution_count": 849,
+ "execution_count": 54,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 850,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 55,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
},
{
"cell_type": "code",
- "execution_count": 851,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 56,
+ "metadata": {},
"outputs": [
{
"name": "stdout",
},
{
"cell_type": "code",
- "execution_count": 852,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 57,
+ "metadata": {},
"outputs": [
{
"data": {
"text/plain": [
- "{frozenset({'e', 'y'}),\n",
- " frozenset({'t', 'x'}),\n",
+ "{frozenset({'t', 'x'}),\n",
" frozenset({'i', 'n'}),\n",
" frozenset({'m'}),\n",
- " frozenset({'b', 'g'}),\n",
- " frozenset({'f', 'p'})}"
+ " frozenset({'e', 'y'}),\n",
+ " frozenset({'f', 'p'}),\n",
+ " frozenset({'b', 'g'})}"
]
},
- "execution_count": 852,
+ "execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 853,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 58,
+ "metadata": {},
"outputs": [
{
"data": {
"True"
]
},
- "execution_count": 853,
+ "execution_count": 58,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 854,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 59,
+ "metadata": {},
"outputs": [
{
"data": {
" frozenset({2, 3}))"
]
},
- "execution_count": 854,
+ "execution_count": 59,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 855,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 60,
+ "metadata": {},
"outputs": [
{
"data": {
"False"
]
},
- "execution_count": 855,
+ "execution_count": 60,
"metadata": {},
"output_type": "execute_result"
}
},
{
"cell_type": "code",
- "execution_count": 856,
- "metadata": {
- "collapsed": false
- },
+ "execution_count": 61,
+ "metadata": {},
"outputs": [
{
"data": {
"False"
]
},
- "execution_count": 856,
+ "execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
"{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,
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
- "version": "3.5.1+"
+ "version": "3.5.3"
}
},
"nbformat": 4,
- "nbformat_minor": 0
+ "nbformat_minor": 1
}