+ {
+ "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"
+ ]
+ },