From: Neil Smith Date: Fri, 28 Jul 2017 08:59:34 +0000 (+0100) Subject: Added explanations of DP, note about better test cases X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=737bfafa601efeaee26d9d6cfd3c18ea34722868;p=ou-summer-of-code-2017.git Added explanations of DP, note about better test cases --- diff --git a/09-resolving-the-bill/interleaving.ipynb b/09-resolving-the-bill/interleaving.ipynb index 352a5fc..46e2b5c 100644 --- a/09-resolving-the-bill/interleaving.ipynb +++ b/09-resolving-the-bill/interleaving.ipynb @@ -73,7 +73,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 4, "metadata": {}, "outputs": [ { @@ -87,7 +87,7 @@ " [False, False, False, False, False, False]]" ] }, - "execution_count": 5, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -100,7 +100,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 5, "metadata": { "scrolled": true }, @@ -146,7 +146,7 @@ " (5, 5): False}" ] }, - "execution_count": 4, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } @@ -160,7 +160,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 6, "metadata": { "collapsed": true }, @@ -174,7 +174,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 7, "metadata": { "collapsed": true }, @@ -188,7 +188,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 8, "metadata": {}, "outputs": [ { @@ -210,7 +210,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -284,7 +284,7 @@ " (5, 5): (4, 5, 'c', 's1')}" ] }, - "execution_count": 8, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -337,7 +337,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 10, "metadata": { "collapsed": true }, @@ -413,7 +413,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 11, "metadata": {}, "outputs": [ { @@ -422,7 +422,7 @@ "True" ] }, - "execution_count": 12, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -433,7 +433,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 12, "metadata": {}, "outputs": [ { @@ -457,7 +457,7 @@ " (5, 5): (4, 5, 'c', 'seq1')})" ] }, - "execution_count": 13, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -468,7 +468,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 13, "metadata": { "scrolled": true }, @@ -530,7 +530,7 @@ " (5, 5): True})" ] }, - "execution_count": 14, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -541,7 +541,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -550,7 +550,7 @@ "False" ] }, - "execution_count": 15, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -561,7 +561,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -603,7 +603,7 @@ " (4, 3): (4, 2, 'b', 'seq2')})" ] }, - "execution_count": 16, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -614,7 +614,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 16, "metadata": { "collapsed": true }, @@ -638,7 +638,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 17, "metadata": { "collapsed": true }, @@ -652,16 +652,16 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 18, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'fddagfdacgbdggabhgcgfddecffbghccebhefghbchhhbfdfgc'" + "'cccbggadggfbghfbeeeecgabbcdehcgfdhegefddahcdcabbch'" ] }, - "execution_count": 19, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -672,7 +672,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 19, "metadata": { "collapsed": true }, @@ -713,7 +713,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -721,54 +721,57 @@ "output_type": "stream", "text": [ "0 0 0 adding x\n", - "0 1 -1 adding y\n", - "0 2 -2 adding x\n", - "0 3 -3 adding g\n", - "1 3 -2 adding h\n", - "2 3 -1 adding d\n", - "3 3 0 adding v\n", - "3 4 -1 adding x\n", - "3 5 -2 adding d\n", - "4 5 -1 adding v\n", - "4 6 -2 adding a\n", - "5 6 -1 adding g\n", - "6 6 0 adding w\n", - "6 7 -1 adding v\n", - "6 8 -2 adding e\n", - "7 8 -1 adding u\n", - "7 9 -2 adding w\n", - "7 10 -3 adding x\n", - "7 11 -4 adding e\n", - "8 11 -3 adding d\n", - "9 11 -2 adding w\n", - "9 12 -3 adding c\n", - "10 12 -2 adding z\n", - "10 13 -3 adding y\n", - "10 14 -4 adding h\n", - "11 14 -3 adding g\n", - "12 14 -2 adding z\n", - "12 15 -3 adding x\n", - "12 16 -4 adding w\n", - "12 17 -5 adding e\n", - "13 17 -4 adding w\n", - "13 18 -5 adding f\n", - "14 18 -4 adding z\n", - "14 19 -5 adding f\n", - "15 19 -4 adding b\n", - "16 19 -3 adding u\n", - "16 20 -4 remaining s1 gchd\n" + "0 1 -1 adding c\n", + "1 1 0 adding v\n", + "1 2 -1 adding a\n", + "2 2 0 adding f\n", + "3 2 1 adding u\n", + "3 3 0 adding z\n", + "3 4 -1 adding y\n", + "3 5 -2 adding w\n", + "3 6 -3 adding e\n", + "4 6 -2 adding u\n", + "4 7 -3 adding h\n", + "5 7 -2 adding x\n", + "5 8 -3 adding b\n", + "6 8 -2 adding h\n", + "7 8 -1 adding z\n", + "7 9 -2 adding f\n", + "8 9 -1 adding d\n", + "9 9 0 adding c\n", + "10 9 1 adding u\n", + "10 10 0 adding v\n", + "10 11 -1 adding c\n", + "11 11 0 adding f\n", + "12 11 1 adding a\n", + "13 11 2 adding y\n", + "13 12 1 adding y\n", + "13 13 0 adding y\n", + "13 14 -1 adding u\n", + "13 15 -2 adding e\n", + "14 15 -1 adding z\n", + "14 16 -2 adding e\n", + "15 16 -1 adding b\n", + "16 16 0 adding c\n", + "17 16 1 adding g\n", + "18 16 2 adding w\n", + "18 17 1 adding u\n", + "18 18 0 adding e\n", + "19 18 1 adding w\n", + "19 19 0 adding b\n", + "20 19 1 remaining s2 y\n" ] }, { "data": { "text/plain": [ - "('ghddageedchgeffbgchd',\n", - " 'xyxvxvwvuwxwzyzxwwzu',\n", - " 'xyxghdvxdvagwveuwxedwczyhgzxwewfzfbugchd',\n", + "('cafehbhfdccfaeebcgeb',\n", + " 'xvuzywuxzuvyyyuzwuwy',\n", + " 'xcvafuzyweuhxbhzfdcuvcfayyyuezebcgwuewby',\n", " 40)" ] }, - "execution_count": 21, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -782,7 +785,7 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 21, "metadata": {}, "outputs": [ { @@ -790,467 +793,467 @@ "output_type": "stream", "text": [ "xxxx 0 0 ! ! ! True\n", - "seq2 0 1 ! g x False\n", - "seq2 0 2 ! h y False\n", - "seq2 0 3 ! d x False\n", - "seq2 0 4 ! d g False\n", - "seq2 0 5 ! a h False\n", - "seq2 0 6 ! g d False\n", - "seq2 0 7 ! e v False\n", - "seq2 0 8 ! e x False\n", - "seq2 0 9 ! d d False\n", - "seq2 0 10 ! c v False\n", - "seq2 0 11 ! h a False\n", - "seq2 0 12 ! g g False\n", - "seq2 0 13 ! e w False\n", - "seq2 0 14 ! f v False\n", - "seq2 0 15 ! f e False\n", - "seq2 0 16 ! b u False\n", - "seq2 0 17 ! g w False\n", - "seq2 0 18 ! c x False\n", - "seq2 0 19 ! h e False\n", - "seq2 0 20 ! d d False\n", + "seq2 0 1 ! c x False\n", + "seq2 0 2 ! a c False\n", + "seq2 0 3 ! f v False\n", + "seq2 0 4 ! e a False\n", + "seq2 0 5 ! h f False\n", + "seq2 0 6 ! b u False\n", + "seq2 0 7 ! h z False\n", + "seq2 0 8 ! f y False\n", + "seq2 0 9 ! d w False\n", + "seq2 0 10 ! c e False\n", + "seq2 0 11 ! c u False\n", + "seq2 0 12 ! f h False\n", + "seq2 0 13 ! a x False\n", + "seq2 0 14 ! e b False\n", + "seq2 0 15 ! e h False\n", + "seq2 0 16 ! b z False\n", + "seq2 0 17 ! c f False\n", + "seq2 0 18 ! g d False\n", + "seq2 0 19 ! e c False\n", + "seq2 0 20 ! b u False\n", "seq1 1 0 x ! x True\n", - "xxxx 1 1 x g y False\n", - "xxxx 1 2 x h x False\n", - "xxxx 1 3 x d g False\n", - "xxxx 1 4 x d h False\n", - "xxxx 1 5 x a d False\n", - "xxxx 1 6 x g v False\n", - "xxxx 1 7 x e x False\n", - "xxxx 1 8 x e d False\n", - "xxxx 1 9 x d v False\n", - "xxxx 1 10 x c a False\n", - "xxxx 1 11 x h g False\n", - "xxxx 1 12 x g w False\n", - "xxxx 1 13 x e v False\n", - "xxxx 1 14 x f e False\n", - "xxxx 1 15 x f u False\n", - "xxxx 1 16 x b w False\n", - "xxxx 1 17 x g x False\n", - "xxxx 1 18 x c e False\n", - "xxxx 1 19 x h d False\n", - "xxxx 1 20 x d w False\n", - "seq1 2 0 y ! y True\n", - "xxxx 2 1 y g x False\n", - "xxxx 2 2 y h g False\n", - "xxxx 2 3 y d h False\n", - "xxxx 2 4 y d d False\n", - "xxxx 2 5 y a v False\n", - "xxxx 2 6 y g x False\n", - "xxxx 2 7 y e d False\n", - "xxxx 2 8 y e v False\n", - "xxxx 2 9 y d a False\n", - "xxxx 2 10 y c g False\n", - "xxxx 2 11 y h w False\n", - "xxxx 2 12 y g v False\n", - "xxxx 2 13 y e e False\n", - "xxxx 2 14 y f u False\n", - "xxxx 2 15 y f w False\n", - "xxxx 2 16 y b x False\n", - "xxxx 2 17 y g e False\n", - "xxxx 2 18 y c d False\n", - "xxxx 2 19 y h w False\n", - "xxxx 2 20 y d c False\n", - "seq1 3 0 x ! x True\n", - "seq2 3 1 x g g True\n", - "seq2 3 2 x h h True\n", - "seq2 3 3 x d d True\n", - "xxxx 3 4 x d v False\n", - "xxxx 3 5 x a x False\n", - "xxxx 3 6 x g d False\n", - "xxxx 3 7 x e v False\n", - "xxxx 3 8 x e a False\n", - "xxxx 3 9 x d g False\n", - "xxxx 3 10 x c w False\n", - "xxxx 3 11 x h v False\n", - "xxxx 3 12 x g e False\n", - "xxxx 3 13 x e u False\n", - "xxxx 3 14 x f w False\n", - "xxxx 3 15 x f x False\n", - "xxxx 3 16 x b e False\n", - "xxxx 3 17 x g d False\n", - "xxxx 3 18 x c w False\n", - "xxxx 3 19 x h c False\n", - "xxxx 3 20 x d z False\n", - "seq1 4 0 v ! g False\n", - "xxxx 4 1 v g h False\n", - "xxxx 4 2 v h d False\n", - "seq1 4 3 v d v True\n", - "xxxx 4 4 v d x False\n", - "xxxx 4 5 v a d False\n", - "xxxx 4 6 v g v False\n", - "xxxx 4 7 v e a False\n", - "xxxx 4 8 v e g False\n", - "xxxx 4 9 v d w False\n", - "xxxx 4 10 v c v False\n", - "xxxx 4 11 v h e False\n", - "xxxx 4 12 v g u False\n", - "xxxx 4 13 v e w False\n", - "xxxx 4 14 v f x False\n", - "xxxx 4 15 v f e False\n", - "xxxx 4 16 v b d False\n", - "xxxx 4 17 v g w False\n", - "xxxx 4 18 v c c False\n", - "xxxx 4 19 v h z False\n", - "xxxx 4 20 v d y False\n", - "seq1 5 0 x ! h False\n", - "xxxx 5 1 x g d False\n", - "xxxx 5 2 x h v False\n", - "seq1 5 3 x d x True\n", - "seq2 5 4 x d d True\n", - "xxxx 5 5 x a v False\n", - "xxxx 5 6 x g a False\n", - "xxxx 5 7 x e g False\n", - "xxxx 5 8 x e w False\n", - "xxxx 5 9 x d v False\n", - "xxxx 5 10 x c e False\n", - "xxxx 5 11 x h u False\n", - "xxxx 5 12 x g w False\n", - "xxxx 5 13 x e x False\n", - "xxxx 5 14 x f e False\n", - "xxxx 5 15 x f d False\n", - "xxxx 5 16 x b w False\n", - "xxxx 5 17 x g c False\n", - "xxxx 5 18 x c z False\n", - "xxxx 5 19 x h y False\n", - "xxxx 5 20 x d h False\n", - "seq1 6 0 v ! d False\n", - "xxxx 6 1 v g v False\n", - "xxxx 6 2 v h x False\n", - "xxxx 6 3 v d d False\n", - "seq1 6 4 v d v True\n", - "seq2 6 5 v a a True\n", - "seq2 6 6 v g g True\n", - "xxxx 6 7 v e w False\n", - "xxxx 6 8 v e v False\n", - "xxxx 6 9 v d e False\n", - "xxxx 6 10 v c u False\n", - "xxxx 6 11 v h w False\n", - "xxxx 6 12 v g x False\n", - "xxxx 6 13 v e e False\n", - "xxxx 6 14 v f d False\n", - "xxxx 6 15 v f w False\n", - "xxxx 6 16 v b c False\n", - "xxxx 6 17 v g z False\n", - "xxxx 6 18 v c y False\n", - "xxxx 6 19 v h h False\n", - "xxxx 6 20 v d g False\n", - "seq1 7 0 w ! v False\n", - "xxxx 7 1 w g x False\n", - "xxxx 7 2 w h d False\n", - "xxxx 7 3 w d v False\n", - "xxxx 7 4 w d a False\n", - "xxxx 7 5 w a g False\n", - "seq1 7 6 w g w True\n", - "xxxx 7 7 w e v False\n", - "xxxx 7 8 w e e False\n", - "xxxx 7 9 w d u False\n", - "xxxx 7 10 w c w False\n", - "xxxx 7 11 w h x False\n", - "xxxx 7 12 w g e False\n", - "xxxx 7 13 w e d False\n", - "xxxx 7 14 w f w False\n", - "xxxx 7 15 w f c False\n", - "xxxx 7 16 w b z False\n", - "xxxx 7 17 w g y False\n", - "xxxx 7 18 w c h False\n", - "xxxx 7 19 w h g False\n", - "xxxx 7 20 w d z False\n", - "seq1 8 0 v ! x False\n", - "xxxx 8 1 v g d False\n", - "xxxx 8 2 v h v False\n", - "xxxx 8 3 v d a False\n", - "xxxx 8 4 v d g False\n", - "xxxx 8 5 v a w False\n", - "seq1 8 6 v g v True\n", - "seq2 8 7 v e e True\n", - "xxxx 8 8 v e u False\n", - "xxxx 8 9 v d w False\n", - "xxxx 8 10 v c x False\n", - "xxxx 8 11 v h e False\n", - "xxxx 8 12 v g d False\n", - "xxxx 8 13 v e w False\n", - "xxxx 8 14 v f c False\n", - "xxxx 8 15 v f z False\n", - "xxxx 8 16 v b y False\n", - "xxxx 8 17 v g h False\n", - "xxxx 8 18 v c g False\n", - "xxxx 8 19 v h z False\n", - "xxxx 8 20 v d x False\n", - "seq1 9 0 u ! d False\n", - "xxxx 9 1 u g v False\n", - "xxxx 9 2 u h a False\n", - "xxxx 9 3 u d g False\n", - "xxxx 9 4 u d w False\n", - "xxxx 9 5 u a v False\n", - "xxxx 9 6 u g e False\n", - "seq1 9 7 u e u True\n", - "xxxx 9 8 u e w False\n", - "xxxx 9 9 u d x False\n", - "xxxx 9 10 u c e False\n", - "xxxx 9 11 u h d False\n", - "xxxx 9 12 u g w False\n", - "xxxx 9 13 u e c False\n", - "xxxx 9 14 u f z False\n", - "xxxx 9 15 u f y False\n", - "xxxx 9 16 u b h False\n", - "xxxx 9 17 u g g False\n", - "xxxx 9 18 u c z False\n", - "xxxx 9 19 u h x False\n", - "xxxx 9 20 u d w False\n", - "seq1 10 0 w ! v False\n", - "xxxx 10 1 w g a False\n", - "xxxx 10 2 w h g False\n", - "xxxx 10 3 w d w False\n", - "xxxx 10 4 w d v False\n", - "xxxx 10 5 w a e False\n", - "xxxx 10 6 w g u False\n", - "seq1 10 7 w e w True\n", - "xxxx 10 8 w e x False\n", - "xxxx 10 9 w d e False\n", - "xxxx 10 10 w c d False\n", - "xxxx 10 11 w h w False\n", - "xxxx 10 12 w g c False\n", - "xxxx 10 13 w e z False\n", - "xxxx 10 14 w f y False\n", - "xxxx 10 15 w f h False\n", - "xxxx 10 16 w b g False\n", - "xxxx 10 17 w g z False\n", - "xxxx 10 18 w c x False\n", - "xxxx 10 19 w h w False\n", - "xxxx 10 20 w d e False\n", - "seq1 11 0 x ! a False\n", - "xxxx 11 1 x g g False\n", - "xxxx 11 2 x h w False\n", - "xxxx 11 3 x d v False\n", - "xxxx 11 4 x d e False\n", - "xxxx 11 5 x a u False\n", - "xxxx 11 6 x g w False\n", - "seq1 11 7 x e x True\n", - "seq2 11 8 x e e True\n", - "seq2 11 9 x d d True\n", - "xxxx 11 10 x c w False\n", - "xxxx 11 11 x h c False\n", - "xxxx 11 12 x g z False\n", - "xxxx 11 13 x e y False\n", - "xxxx 11 14 x f h False\n", - "xxxx 11 15 x f g False\n", - "xxxx 11 16 x b z False\n", - "xxxx 11 17 x g x False\n", - "xxxx 11 18 x c w False\n", - "xxxx 11 19 x h e False\n", - "xxxx 11 20 x d w False\n", - "seq1 12 0 w ! g False\n", - "xxxx 12 1 w g w False\n", - "xxxx 12 2 w h v False\n", - "xxxx 12 3 w d e False\n", - "xxxx 12 4 w d u False\n", - "xxxx 12 5 w a w False\n", - "xxxx 12 6 w g x False\n", - "xxxx 12 7 w e e False\n", - "xxxx 12 8 w e d False\n", - "seq1 12 9 w d w True\n", - "seq2 12 10 w c c True\n", - "xxxx 12 11 w h z False\n", - "xxxx 12 12 w g y False\n", - "xxxx 12 13 w e h False\n", - "xxxx 12 14 w f g False\n", - "xxxx 12 15 w f z False\n", - "xxxx 12 16 w b x False\n", - "xxxx 12 17 w g w False\n", - "xxxx 12 18 w c e False\n", - "xxxx 12 19 w h w False\n", - "xxxx 12 20 w d f False\n", - "seq1 13 0 z ! w False\n", - "xxxx 13 1 z g v False\n", - "xxxx 13 2 z h e False\n", - "xxxx 13 3 z d u False\n", - "xxxx 13 4 z d w False\n", - "xxxx 13 5 z a x False\n", - "xxxx 13 6 z g e False\n", - "xxxx 13 7 z e d False\n", - "xxxx 13 8 z e w False\n", - "xxxx 13 9 z d c False\n", - "seq1 13 10 z c z True\n", - "xxxx 13 11 z h y False\n", - "xxxx 13 12 z g h False\n", - "xxxx 13 13 z e g False\n", - "xxxx 13 14 z f z False\n", - "xxxx 13 15 z f x False\n", - "xxxx 13 16 z b w False\n", - "xxxx 13 17 z g e False\n", - "xxxx 13 18 z c w False\n", - "xxxx 13 19 z h f False\n", - "xxxx 13 20 z d z False\n", - "seq1 14 0 y ! v False\n", - "xxxx 14 1 y g e False\n", - "xxxx 14 2 y h u False\n", - "xxxx 14 3 y d w False\n", - "xxxx 14 4 y d x False\n", - "xxxx 14 5 y a e False\n", - "xxxx 14 6 y g d False\n", - "xxxx 14 7 y e w False\n", - "xxxx 14 8 y e c False\n", - "xxxx 14 9 y d z False\n", - "seq1 14 10 y c y True\n", - "seq2 14 11 y h h True\n", - "seq2 14 12 y g g True\n", - "xxxx 14 13 y e z False\n", - "xxxx 14 14 y f x False\n", - "xxxx 14 15 y f w False\n", - "xxxx 14 16 y b e False\n", - "xxxx 14 17 y g w False\n", - "xxxx 14 18 y c f False\n", - "xxxx 14 19 y h z False\n", - "xxxx 14 20 y d f False\n", - "seq1 15 0 z ! e False\n", - "xxxx 15 1 z g u False\n", - "xxxx 15 2 z h w False\n", - "xxxx 15 3 z d x False\n", - "xxxx 15 4 z d e False\n", - "xxxx 15 5 z a d False\n", - "xxxx 15 6 z g w False\n", - "xxxx 15 7 z e c False\n", - "xxxx 15 8 z e z False\n", - "xxxx 15 9 z d y False\n", - "xxxx 15 10 z c h False\n", - "xxxx 15 11 z h g False\n", - "seq1 15 12 z g z True\n", - "xxxx 15 13 z e x False\n", - "xxxx 15 14 z f w False\n", - "xxxx 15 15 z f e False\n", - "xxxx 15 16 z b w False\n", - "xxxx 15 17 z g f False\n", - "xxxx 15 18 z c z False\n", - "xxxx 15 19 z h f False\n", - "xxxx 15 20 z d b False\n", - "seq1 16 0 x ! u False\n", - "xxxx 16 1 x g w False\n", - "xxxx 16 2 x h x False\n", - "xxxx 16 3 x d e False\n", - "xxxx 16 4 x d d False\n", - "xxxx 16 5 x a w False\n", - "xxxx 16 6 x g c False\n", - "xxxx 16 7 x e z False\n", - "xxxx 16 8 x e y False\n", - "xxxx 16 9 x d h False\n", - "xxxx 16 10 x c g False\n", - "xxxx 16 11 x h z False\n", - "seq1 16 12 x g x True\n", - "xxxx 16 13 x e w False\n", - "xxxx 16 14 x f e False\n", - "xxxx 16 15 x f w False\n", - "xxxx 16 16 x b f False\n", - "xxxx 16 17 x g z False\n", - "xxxx 16 18 x c f False\n", - "xxxx 16 19 x h b False\n", - "xxxx 16 20 x d u False\n", - "seq1 17 0 w ! w False\n", - "xxxx 17 1 w g x False\n", - "xxxx 17 2 w h e False\n", - "xxxx 17 3 w d d False\n", - "xxxx 17 4 w d w False\n", - "xxxx 17 5 w a c False\n", - "xxxx 17 6 w g z False\n", - "xxxx 17 7 w e y False\n", - "xxxx 17 8 w e h False\n", - "xxxx 17 9 w d g False\n", - "xxxx 17 10 w c z False\n", - "xxxx 17 11 w h x False\n", - "seq1 17 12 w g w True\n", - "seq2 17 13 w e e True\n", - "xxxx 17 14 w f w False\n", - "xxxx 17 15 w f f False\n", - "xxxx 17 16 w b z False\n", - "xxxx 17 17 w g f False\n", - "xxxx 17 18 w c b False\n", - "xxxx 17 19 w h u False\n", - "xxxx 17 20 w d g False\n", - "seq1 18 0 w ! x False\n", - "xxxx 18 1 w g e False\n", - "xxxx 18 2 w h d False\n", - "xxxx 18 3 w d w False\n", - "xxxx 18 4 w d c False\n", - "xxxx 18 5 w a z False\n", - "xxxx 18 6 w g y False\n", - "xxxx 18 7 w e h False\n", - "xxxx 18 8 w e g False\n", - "xxxx 18 9 w d z False\n", - "xxxx 18 10 w c x False\n", - "xxxx 18 11 w h w False\n", - "xxxx 18 12 w g e False\n", - "seq1 18 13 w e w True\n", - "seq2 18 14 w f f True\n", - "xxxx 18 15 w f z False\n", - "xxxx 18 16 w b f False\n", - "xxxx 18 17 w g b False\n", - "xxxx 18 18 w c u False\n", - "xxxx 18 19 w h g False\n", - "xxxx 18 20 w d c False\n", - "seq1 19 0 z ! e False\n", - "xxxx 19 1 z g d False\n", - "xxxx 19 2 z h w False\n", - "xxxx 19 3 z d c False\n", - "xxxx 19 4 z d z False\n", - "xxxx 19 5 z a y False\n", - "xxxx 19 6 z g h False\n", - "xxxx 19 7 z e g False\n", - "xxxx 19 8 z e z False\n", - "xxxx 19 9 z d x False\n", - "xxxx 19 10 z c w False\n", - "xxxx 19 11 z h e False\n", - "xxxx 19 12 z g w False\n", - "xxxx 19 13 z e f False\n", - "seq1 19 14 z f z True\n", - "seq2 19 15 z f f True\n", - "seq2 19 16 z b b True\n", - "xxxx 19 17 z g u False\n", - "xxxx 19 18 z c g False\n", - "xxxx 19 19 z h c False\n", - "xxxx 19 20 z d h False\n", - "seq1 20 0 u ! d False\n", - "xxxx 20 1 u g w False\n", - "xxxx 20 2 u h c False\n", - "xxxx 20 3 u d z False\n", - "xxxx 20 4 u d y False\n", - "xxxx 20 5 u a h False\n", - "xxxx 20 6 u g g False\n", - "xxxx 20 7 u e z False\n", - "xxxx 20 8 u e x False\n", - "xxxx 20 9 u d w False\n", - "xxxx 20 10 u c e False\n", - "xxxx 20 11 u h w False\n", - "xxxx 20 12 u g f False\n", - "xxxx 20 13 u e z False\n", - "xxxx 20 14 u f f False\n", - "xxxx 20 15 u f b False\n", - "seq1 20 16 u b u True\n", - "seq2 20 17 u g g True\n", - "seq2 20 18 u c c True\n", - "seq2 20 19 u h h True\n", - "seq2 20 20 u d d True\n", - "T . . . . . . . . . . . . . . . . . . . .\n", - "T . . . . . . . . . . . . . . . . . . . .\n", + "seq2 1 1 x c c True\n", + "xxxx 1 2 x a v False\n", + "xxxx 1 3 x f a False\n", + "xxxx 1 4 x e f False\n", + "xxxx 1 5 x h u False\n", + "xxxx 1 6 x b z False\n", + "xxxx 1 7 x h y False\n", + "xxxx 1 8 x f w False\n", + "xxxx 1 9 x d e False\n", + "xxxx 1 10 x c u False\n", + "xxxx 1 11 x c h False\n", + "xxxx 1 12 x f x False\n", + "xxxx 1 13 x a b False\n", + "xxxx 1 14 x e h False\n", + "xxxx 1 15 x e z False\n", + "xxxx 1 16 x b f False\n", + "xxxx 1 17 x c d False\n", + "xxxx 1 18 x g c False\n", + "xxxx 1 19 x e u False\n", + "xxxx 1 20 x b v False\n", + "seq1 2 0 v ! c False\n", + "seq1 2 1 v c v True\n", + "seq2 2 2 v a a True\n", + "seq2 2 3 v f f True\n", + "xxxx 2 4 v e u False\n", + "xxxx 2 5 v h z False\n", + "xxxx 2 6 v b y False\n", + "xxxx 2 7 v h w False\n", + "xxxx 2 8 v f e False\n", + "xxxx 2 9 v d u False\n", + "xxxx 2 10 v c h False\n", + "xxxx 2 11 v c x False\n", + "xxxx 2 12 v f b False\n", + "xxxx 2 13 v a h False\n", + "xxxx 2 14 v e z False\n", + "xxxx 2 15 v e f False\n", + "xxxx 2 16 v b d False\n", + "xxxx 2 17 v c c False\n", + "xxxx 2 18 v g u False\n", + "xxxx 2 19 v e v False\n", + "xxxx 2 20 v b c False\n", + "seq1 3 0 u ! v False\n", + "xxxx 3 1 u c a False\n", + "xxxx 3 2 u a f False\n", + "seq1 3 3 u f u True\n", + "xxxx 3 4 u e z False\n", + "xxxx 3 5 u h y False\n", + "xxxx 3 6 u b w False\n", + "xxxx 3 7 u h e False\n", + "xxxx 3 8 u f u False\n", + "xxxx 3 9 u d h False\n", + "xxxx 3 10 u c x False\n", + "xxxx 3 11 u c b False\n", + "xxxx 3 12 u f h False\n", + "xxxx 3 13 u a z False\n", + "xxxx 3 14 u e f False\n", + "xxxx 3 15 u e d False\n", + "xxxx 3 16 u b c False\n", + "xxxx 3 17 u c u False\n", + "xxxx 3 18 u g v False\n", + "xxxx 3 19 u e c False\n", + "xxxx 3 20 u b f False\n", + "seq1 4 0 z ! a False\n", + "xxxx 4 1 z c f False\n", + "xxxx 4 2 z a u False\n", + "seq1 4 3 z f z True\n", + "xxxx 4 4 z e y False\n", + "xxxx 4 5 z h w False\n", + "xxxx 4 6 z b e False\n", + "xxxx 4 7 z h u False\n", + "xxxx 4 8 z f h False\n", + "xxxx 4 9 z d x False\n", + "xxxx 4 10 z c b False\n", + "xxxx 4 11 z c h False\n", + "xxxx 4 12 z f z False\n", + "xxxx 4 13 z a f False\n", + "xxxx 4 14 z e d False\n", + "xxxx 4 15 z e c False\n", + "xxxx 4 16 z b u False\n", + "xxxx 4 17 z c v False\n", + "xxxx 4 18 z g c False\n", + "xxxx 4 19 z e f False\n", + "xxxx 4 20 z b a False\n", + "seq1 5 0 y ! f False\n", + "xxxx 5 1 y c u False\n", + "xxxx 5 2 y a z False\n", + "seq1 5 3 y f y True\n", + "xxxx 5 4 y e w False\n", + "xxxx 5 5 y h e False\n", + "xxxx 5 6 y b u False\n", + "xxxx 5 7 y h h False\n", + "xxxx 5 8 y f x False\n", + "xxxx 5 9 y d b False\n", + "xxxx 5 10 y c h False\n", + "xxxx 5 11 y c z False\n", + "xxxx 5 12 y f f False\n", + "xxxx 5 13 y a d False\n", + "xxxx 5 14 y e c False\n", + "xxxx 5 15 y e u False\n", + "xxxx 5 16 y b v False\n", + "xxxx 5 17 y c c False\n", + "xxxx 5 18 y g f False\n", + "xxxx 5 19 y e a False\n", + "xxxx 5 20 y b y False\n", + "seq1 6 0 w ! u False\n", + "xxxx 6 1 w c z False\n", + "xxxx 6 2 w a y False\n", + "seq1 6 3 w f w True\n", + "seq2 6 4 w e e True\n", + "xxxx 6 5 w h u False\n", + "xxxx 6 6 w b h False\n", + "xxxx 6 7 w h x False\n", + "xxxx 6 8 w f b False\n", + "xxxx 6 9 w d h False\n", + "xxxx 6 10 w c z False\n", + "xxxx 6 11 w c f False\n", + "xxxx 6 12 w f d False\n", + "xxxx 6 13 w a c False\n", + "xxxx 6 14 w e u False\n", + "xxxx 6 15 w e v False\n", + "xxxx 6 16 w b c False\n", + "xxxx 6 17 w c f False\n", + "xxxx 6 18 w g a False\n", + "xxxx 6 19 w e y False\n", + "xxxx 6 20 w b y False\n", + "seq1 7 0 u ! z False\n", + "xxxx 7 1 u c y False\n", + "xxxx 7 2 u a w False\n", + "xxxx 7 3 u f e False\n", + "seq1 7 4 u e u True\n", + "seq2 7 5 u h h True\n", + "xxxx 7 6 u b x False\n", + "xxxx 7 7 u h b False\n", + "xxxx 7 8 u f h False\n", + "xxxx 7 9 u d z False\n", + "xxxx 7 10 u c f False\n", + "xxxx 7 11 u c d False\n", + "xxxx 7 12 u f c False\n", + "xxxx 7 13 u a u False\n", + "xxxx 7 14 u e v False\n", + "xxxx 7 15 u e c False\n", + "xxxx 7 16 u b f False\n", + "xxxx 7 17 u c a False\n", + "xxxx 7 18 u g y False\n", + "xxxx 7 19 u e y False\n", + "xxxx 7 20 u b y False\n", + "seq1 8 0 x ! y False\n", + "xxxx 8 1 x c w False\n", + "xxxx 8 2 x a e False\n", + "xxxx 8 3 x f u False\n", + "xxxx 8 4 x e h False\n", + "seq1 8 5 x h x True\n", + "seq2 8 6 x b b True\n", + "seq2 8 7 x h h True\n", + "xxxx 8 8 x f z False\n", + "xxxx 8 9 x d f False\n", + "xxxx 8 10 x c d False\n", + "xxxx 8 11 x c c False\n", + "xxxx 8 12 x f u False\n", + "xxxx 8 13 x a v False\n", + "xxxx 8 14 x e c False\n", + "xxxx 8 15 x e f False\n", + "xxxx 8 16 x b a False\n", + "xxxx 8 17 x c y False\n", + "xxxx 8 18 x g y False\n", + "xxxx 8 19 x e y False\n", + "xxxx 8 20 x b u False\n", + "seq1 9 0 z ! w False\n", + "xxxx 9 1 z c e False\n", + "xxxx 9 2 z a u False\n", + "xxxx 9 3 z f h False\n", + "xxxx 9 4 z e x False\n", + "xxxx 9 5 z h b False\n", + "xxxx 9 6 z b h False\n", + "seq1 9 7 z h z True\n", + "seq2 9 8 z f f True\n", + "seq2 9 9 z d d True\n", + "seq2 9 10 z c c True\n", + "xxxx 9 11 z c u False\n", + "xxxx 9 12 z f v False\n", + "xxxx 9 13 z a c False\n", + "xxxx 9 14 z e f False\n", + "xxxx 9 15 z e a False\n", + "xxxx 9 16 z b y False\n", + "xxxx 9 17 z c y False\n", + "xxxx 9 18 z g y False\n", + "xxxx 9 19 z e u False\n", + "xxxx 9 20 z b e False\n", + "seq1 10 0 u ! e False\n", + "xxxx 10 1 u c u False\n", + "xxxx 10 2 u a h False\n", + "xxxx 10 3 u f x False\n", + "xxxx 10 4 u e b False\n", + "xxxx 10 5 u h h False\n", + "xxxx 10 6 u b z False\n", + "xxxx 10 7 u h f False\n", + "xxxx 10 8 u f d False\n", + "xxxx 10 9 u d c False\n", + "seq1 10 10 u c u True\n", + "xxxx 10 11 u c v False\n", + "xxxx 10 12 u f c False\n", + "xxxx 10 13 u a f False\n", + "xxxx 10 14 u e a False\n", + "xxxx 10 15 u e y False\n", + "xxxx 10 16 u b y False\n", + "xxxx 10 17 u c y False\n", + "xxxx 10 18 u g u False\n", + "xxxx 10 19 u e e False\n", + "xxxx 10 20 u b z False\n", + "seq1 11 0 v ! u False\n", + "xxxx 11 1 v c h False\n", + "xxxx 11 2 v a x False\n", + "xxxx 11 3 v f b False\n", + "xxxx 11 4 v e h False\n", + "xxxx 11 5 v h z False\n", + "xxxx 11 6 v b f False\n", + "xxxx 11 7 v h d False\n", + "xxxx 11 8 v f c False\n", + "xxxx 11 9 v d u False\n", + "seq1 11 10 v c v True\n", + "seq2 11 11 v c c True\n", + "seq2 11 12 v f f True\n", + "seq2 11 13 v a a True\n", + "xxxx 11 14 v e y False\n", + "xxxx 11 15 v e y False\n", + "xxxx 11 16 v b y False\n", + "xxxx 11 17 v c u False\n", + "xxxx 11 18 v g e False\n", + "xxxx 11 19 v e z False\n", + "xxxx 11 20 v b e False\n", + "seq1 12 0 y ! h False\n", + "xxxx 12 1 y c x False\n", + "xxxx 12 2 y a b False\n", + "xxxx 12 3 y f h False\n", + "xxxx 12 4 y e z False\n", + "xxxx 12 5 y h f False\n", + "xxxx 12 6 y b d False\n", + "xxxx 12 7 y h c False\n", + "xxxx 12 8 y f u False\n", + "xxxx 12 9 y d v False\n", + "xxxx 12 10 y c c False\n", + "xxxx 12 11 y c f False\n", + "xxxx 12 12 y f a False\n", + "seq1 12 13 y a y True\n", + "xxxx 12 14 y e y False\n", + "xxxx 12 15 y e y False\n", + "xxxx 12 16 y b u False\n", + "xxxx 12 17 y c e False\n", + "xxxx 12 18 y g z False\n", + "xxxx 12 19 y e e False\n", + "xxxx 12 20 y b b False\n", + "seq1 13 0 y ! x False\n", + "xxxx 13 1 y c b False\n", + "xxxx 13 2 y a h False\n", + "xxxx 13 3 y f z False\n", + "xxxx 13 4 y e f False\n", + "xxxx 13 5 y h d False\n", + "xxxx 13 6 y b c False\n", + "xxxx 13 7 y h u False\n", + "xxxx 13 8 y f v False\n", + "xxxx 13 9 y d c False\n", + "xxxx 13 10 y c f False\n", + "xxxx 13 11 y c a False\n", + "xxxx 13 12 y f y False\n", + "seq1 13 13 y a y True\n", + "xxxx 13 14 y e y False\n", + "xxxx 13 15 y e u False\n", + "xxxx 13 16 y b e False\n", + "xxxx 13 17 y c z False\n", + "xxxx 13 18 y g e False\n", + "xxxx 13 19 y e b False\n", + "xxxx 13 20 y b c False\n", + "seq1 14 0 y ! b False\n", + "xxxx 14 1 y c h False\n", + "xxxx 14 2 y a z False\n", + "xxxx 14 3 y f f False\n", + "xxxx 14 4 y e d False\n", + "xxxx 14 5 y h c False\n", + "xxxx 14 6 y b u False\n", + "xxxx 14 7 y h v False\n", + "xxxx 14 8 y f c False\n", + "xxxx 14 9 y d f False\n", + "xxxx 14 10 y c a False\n", + "xxxx 14 11 y c y False\n", + "xxxx 14 12 y f y False\n", + "seq1 14 13 y a y True\n", + "xxxx 14 14 y e u False\n", + "xxxx 14 15 y e e False\n", + "xxxx 14 16 y b z False\n", + "xxxx 14 17 y c e False\n", + "xxxx 14 18 y g b False\n", + "xxxx 14 19 y e c False\n", + "xxxx 14 20 y b g False\n", + "seq1 15 0 u ! h False\n", + "xxxx 15 1 u c z False\n", + "xxxx 15 2 u a f False\n", + "xxxx 15 3 u f d False\n", + "xxxx 15 4 u e c False\n", + "xxxx 15 5 u h u False\n", + "xxxx 15 6 u b v False\n", + "xxxx 15 7 u h c False\n", + "xxxx 15 8 u f f False\n", + "xxxx 15 9 u d a False\n", + "xxxx 15 10 u c y False\n", + "xxxx 15 11 u c y False\n", + "xxxx 15 12 u f y False\n", + "seq1 15 13 u a u True\n", + "seq2 15 14 u e e True\n", + "xxxx 15 15 u e z False\n", + "xxxx 15 16 u b e False\n", + "xxxx 15 17 u c b False\n", + "xxxx 15 18 u g c False\n", + "xxxx 15 19 u e g False\n", + "xxxx 15 20 u b w False\n", + "seq1 16 0 z ! z False\n", + "xxxx 16 1 z c f False\n", + "xxxx 16 2 z a d False\n", + "xxxx 16 3 z f c False\n", + "xxxx 16 4 z e u False\n", + "xxxx 16 5 z h v False\n", + "xxxx 16 6 z b c False\n", + "xxxx 16 7 z h f False\n", + "xxxx 16 8 z f a False\n", + "xxxx 16 9 z d y False\n", + "xxxx 16 10 z c y False\n", + "xxxx 16 11 z c y False\n", + "xxxx 16 12 z f u False\n", + "xxxx 16 13 z a e False\n", + "seq1 16 14 z e z True\n", + "seq2 16 15 z e e True\n", + "seq2 16 16 z b b True\n", + "seq2 16 17 z c c True\n", + "seq2 16 18 z g g True\n", + "xxxx 16 19 z e w False\n", + "xxxx 16 20 z b u False\n", + "seq1 17 0 w ! f False\n", + "xxxx 17 1 w c d False\n", + "xxxx 17 2 w a c False\n", + "xxxx 17 3 w f u False\n", + "xxxx 17 4 w e v False\n", + "xxxx 17 5 w h c False\n", + "xxxx 17 6 w b f False\n", + "xxxx 17 7 w h a False\n", + "xxxx 17 8 w f y False\n", + "xxxx 17 9 w d y False\n", + "xxxx 17 10 w c y False\n", + "xxxx 17 11 w c u False\n", + "xxxx 17 12 w f e False\n", + "xxxx 17 13 w a z False\n", + "xxxx 17 14 w e e False\n", + "xxxx 17 15 w e b False\n", + "xxxx 17 16 w b c False\n", + "xxxx 17 17 w c g False\n", + "seq1 17 18 w g w True\n", + "xxxx 17 19 w e u False\n", + "xxxx 17 20 w b e False\n", + "seq1 18 0 u ! d False\n", + "xxxx 18 1 u c c False\n", + "xxxx 18 2 u a u False\n", + "xxxx 18 3 u f v False\n", + "xxxx 18 4 u e c False\n", + "xxxx 18 5 u h f False\n", + "xxxx 18 6 u b a False\n", + "xxxx 18 7 u h y False\n", + "xxxx 18 8 u f y False\n", + "xxxx 18 9 u d y False\n", + "xxxx 18 10 u c u False\n", + "xxxx 18 11 u c e False\n", + "xxxx 18 12 u f z False\n", + "xxxx 18 13 u a e False\n", + "xxxx 18 14 u e b False\n", + "xxxx 18 15 u e c False\n", + "xxxx 18 16 u b g False\n", + "xxxx 18 17 u c w False\n", + "seq1 18 18 u g u True\n", + "seq2 18 19 u e e True\n", + "xxxx 18 20 u b w False\n", + "seq1 19 0 w ! c False\n", + "xxxx 19 1 w c u False\n", + "xxxx 19 2 w a v False\n", + "xxxx 19 3 w f c False\n", + "xxxx 19 4 w e f False\n", + "xxxx 19 5 w h a False\n", + "xxxx 19 6 w b y False\n", + "xxxx 19 7 w h y False\n", + "xxxx 19 8 w f y False\n", + "xxxx 19 9 w d u False\n", + "xxxx 19 10 w c e False\n", + "xxxx 19 11 w c z False\n", + "xxxx 19 12 w f e False\n", + "xxxx 19 13 w a b False\n", + "xxxx 19 14 w e c False\n", + "xxxx 19 15 w e g False\n", + "xxxx 19 16 w b w False\n", + "xxxx 19 17 w c u False\n", + "xxxx 19 18 w g e False\n", + "seq1 19 19 w e w True\n", + "seq2 19 20 w b b True\n", + "seq1 20 0 y ! u False\n", + "xxxx 20 1 y c v False\n", + "xxxx 20 2 y a c False\n", + "xxxx 20 3 y f f False\n", + "xxxx 20 4 y e a False\n", + "xxxx 20 5 y h y False\n", + "xxxx 20 6 y b y False\n", + "xxxx 20 7 y h y False\n", + "xxxx 20 8 y f u False\n", + "xxxx 20 9 y d e False\n", + "xxxx 20 10 y c z False\n", + "xxxx 20 11 y c e False\n", + "xxxx 20 12 y f b False\n", + "xxxx 20 13 y a c False\n", + "xxxx 20 14 y e g False\n", + "xxxx 20 15 y e w False\n", + "xxxx 20 16 y b u False\n", + "xxxx 20 17 y c e False\n", + "xxxx 20 18 y g w False\n", + "xxxx 20 19 y e b False\n", + "seq1 20 20 y b y True\n", "T . . . . . . . . . . . . . . . . . . . .\n", - "T T T T . . . . . . . . . . . . . . . . .\n", + "T T . . . . . . . . . . . . . . . . . . .\n", + ". T T T . . . . . . . . . . . . . . . . .\n", + ". . . T . . . . . . . . . . . . . . . . .\n", + ". . . T . . . . . . . . . . . . . . . . .\n", ". . . T . . . . . . . . . . . . . . . . .\n", ". . . T T . . . . . . . . . . . . . . . .\n", - ". . . . T T T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T T . . . . . . . . . . . . .\n", - ". . . . . . . T . . . . . . . . . . . . .\n", - ". . . . . . . T . . . . . . . . . . . . .\n", - ". . . . . . . T T T . . . . . . . . . . .\n", - ". . . . . . . . . T T . . . . . . . . . .\n", + ". . . . T T . . . . . . . . . . . . . . .\n", + ". . . . . T T T . . . . . . . . . . . . .\n", + ". . . . . . . T T T T . . . . . . . . . .\n", ". . . . . . . . . . T . . . . . . . . . .\n", - ". . . . . . . . . . T T T . . . . . . . .\n", - ". . . . . . . . . . . . T . . . . . . . .\n", - ". . . . . . . . . . . . T . . . . . . . .\n", - ". . . . . . . . . . . . T T . . . . . . .\n", + ". . . . . . . . . . T T T T . . . . . . .\n", + ". . . . . . . . . . . . . T . . . . . . .\n", + ". . . . . . . . . . . . . T . . . . . . .\n", + ". . . . . . . . . . . . . T . . . . . . .\n", ". . . . . . . . . . . . . T T . . . . . .\n", - ". . . . . . . . . . . . . . T T T . . . .\n", - ". . . . . . . . . . . . . . . . T T T T T\n" + ". . . . . . . . . . . . . . T T T T T . .\n", + ". . . . . . . . . . . . . . . . . . T . .\n", + ". . . . . . . . . . . . . . . . . . T T .\n", + ". . . . . . . . . . . . . . . . . . . T T\n", + ". . . . . . . . . . . . . . . . . . . . T\n" ] } ], @@ -1261,16 +1264,16 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 22, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'XYXghdVXdVagWVeUWXedWcZYhgZXWeWfZfbUgchd'" + "'XcVafUZYWeUhXbhZfdcUVcfaYYYUeZebcgWUeWbY'" ] }, - "execution_count": 23, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -1281,7 +1284,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -1289,27 +1292,27 @@ "output_type": "stream", "text": [ "T . . . . . . . . . . . . . . . . . . . .\n", - "T . . . . . . . . . . . . . . . . . . . .\n", - "T . . . . . . . . . . . . . . . . . . . .\n", - "T T T T . . . . . . . . . . . . . . . . .\n", + "T T . . . . . . . . . . . . . . . . . . .\n", + ". T T T . . . . . . . . . . . . . . . . .\n", + ". . . T . . . . . . . . . . . . . . . . .\n", + ". . . T . . . . . . . . . . . . . . . . .\n", ". . . T . . . . . . . . . . . . . . . . .\n", ". . . T T . . . . . . . . . . . . . . . .\n", - ". . . . T T T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T T . . . . . . . . . . . . .\n", - ". . . . . . . T . . . . . . . . . . . . .\n", - ". . . . . . . T . . . . . . . . . . . . .\n", - ". . . . . . . T T T . . . . . . . . . . .\n", - ". . . . . . . . . T T . . . . . . . . . .\n", + ". . . . T T . . . . . . . . . . . . . . .\n", + ". . . . . T T T . . . . . . . . . . . . .\n", + ". . . . . . . T T T T . . . . . . . . . .\n", ". . . . . . . . . . T . . . . . . . . . .\n", - ". . . . . . . . . . T T T . . . . . . . .\n", - ". . . . . . . . . . . . T . . . . . . . .\n", - ". . . . . . . . . . . . T . . . . . . . .\n", - ". . . . . . . . . . . . T T . . . . . . .\n", + ". . . . . . . . . . T T T T . . . . . . .\n", + ". . . . . . . . . . . . . T . . . . . . .\n", + ". . . . . . . . . . . . . T . . . . . . .\n", + ". . . . . . . . . . . . . T . . . . . . .\n", ". . . . . . . . . . . . . T T . . . . . .\n", - ". . . . . . . . . . . . . . T T T . . . .\n", - ". . . . . . . . . . . . . . . . T T T T T\n", - "XYXghdVXdVagWVeUWXedWcZYhgZXWeWfZfbUgchd\n" + ". . . . . . . . . . . . . . T T T T T . .\n", + ". . . . . . . . . . . . . . . . . . T . .\n", + ". . . . . . . . . . . . . . . . . . T T .\n", + ". . . . . . . . . . . . . . . . . . . T T\n", + ". . . . . . . . . . . . . . . . . . . . T\n", + "XcVafUZYWeUhXbhZfdcUVcfaYYYUeZebcgWUeWbY\n" ] }, { @@ -1318,7 +1321,7 @@ "True" ] }, - "execution_count": 24, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -1332,19 +1335,19 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 24, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "('fahfgbdechbafcbcadcfchhccffhfgeagdhdceebccbhgdefgd',\n", - " 'badbgfaachhhhgghhebahhcbgabcfafeehfcabhbaaccgbcfae',\n", - " 'badfbgfahfgbadecahcbahfhchbchagghhdcefchbahhhcbcgacfbcffhafefgeaegdhfcabhhbdcaaccgebcfebcaecbhgdefgd',\n", + "('fdghaegbegehggbggcgcfecbgfacefhahahdhfafacchafacea',\n", + " 'hdhadgebfeaehhhggbdghgcehabccgbddafeacagbgcahhfefe',\n", + " 'fhdgdhahadgegebfbeegehaegghbhghggcggcfecbgbdgfhagcehabcccgbedfdhahaafeahcdhfaafaccghafbgacceahahfefe',\n", " 100)" ] }, - "execution_count": 25, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -1358,65 +1361,65 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 25, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - "T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - "T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", "T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". T T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". T . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". T . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . T . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . T . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . T . T T T T T T T T . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . T . T . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . T T T T . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . T T . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T T T T T T\n", - "BADfBGFahfgbAdecAhCbaHfHcHbcHaGGHHdcEfchBAhHHCBcGAcfBCfFhAFEfgeaEgdHFCABhHBdcAACCGeBCFebcAEcbhgdefgd\n" + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T T . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", + "fHdgDhaHADGegEBFbeEgehAEggHbHgHgGcgGcfecbgBDGfHaGCEHABcCCGBeDfDhahaAFEAhCdhfaAfaccGhafBGacCeAHaHFEFE\n" ] }, { @@ -1425,7 +1428,7 @@ "True" ] }, - "execution_count": 26, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -1439,14 +1442,14 @@ }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 26, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1000 loops, best of 3: 1.24 ms per loop\n" + "1000 loops, best of 3: 1.4 ms per loop\n" ] } ], @@ -1457,65 +1460,65 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 27, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + "T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + "T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . T . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . T T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . T . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T . T T T . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . T . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . T T T T T T T T T . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . T . . . . T T T T T . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . T T . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T T T . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . T T T . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T T . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - "badFbgfAHFGBaDECaHcBAhFhChBChAgghhDCeFCHbahhHcbCgaCFbcfFHafeFGEAeGDhfcabhHbDCaaccgEbcfEBCaeCBHGDEFGD\n" + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . T T T T T T\n", + "FhDGdhaHAdgEGebfBeEGEHaeGGhBhGhgGCgGCFECBGbdgFhAgcehabccCgbEdFdHAHaAfeaHcDHFaAFACCgHAFbgAcCEahAhfefe\n" ] }, { @@ -1524,7 +1527,7 @@ "True" ] }, - "execution_count": 28, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -1538,7 +1541,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 28, "metadata": {}, "outputs": [ { @@ -1547,7 +1550,7 @@ "True" ] }, - "execution_count": 29, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -1558,16 +1561,16 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 29, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "('gbaehdacgdebgaebecfbefcbehfgcheaccdehbfdfadebhcehd', False, False)" + "('febffabcddaaaeffcdhcdaffgfafafcchfffdcbbbagbdfdbdd', False, False)" ] }, - "execution_count": 30, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -1579,13 +1582,14 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ + "T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", "T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", @@ -1636,7 +1640,6 @@ ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", "\n" ] }, @@ -1646,7 +1649,7 @@ "False" ] }, - "execution_count": 31, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -1660,7 +1663,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 31, "metadata": { "collapsed": true }, @@ -1684,7 +1687,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 32, "metadata": { "collapsed": true }, @@ -1699,7 +1702,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -1708,7 +1711,7 @@ "True" ] }, - "execution_count": 34, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -1719,7 +1722,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -1728,7 +1731,7 @@ "False" ] }, - "execution_count": 35, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -1746,7 +1749,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 35, "metadata": { "collapsed": true }, @@ -1759,7 +1762,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 36, "metadata": { "collapsed": true }, @@ -1785,29 +1788,29 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "0: accbadaadc\n", - "1: bbbbaabada\n", - "2: cdaacacadcddbccacdab\n", - "3: bbcdabbaaabcbcadcaac\n", - "4: accbbabbdbaaabadaadc\n", - "5: acadcdddab\n", - "6: aacccabaddcdaddaabdc\n" + "0: cddcdbbdbc\n", + "1: bdbacbdaaa\n", + "2: bdccbaadcbdbdacacaac\n", + "3: dccaadcdba\n", + "4: dcccaadcdddcdbbbadbc\n", + "5: bcdbddaccbddbbdaabca\n", + "6: cdcccadbaadcddcbcaac\n" ] }, { "data": { "text/plain": [ - "['accbbabbdbaaabadaadc']" + "['bcdbddaccbddbbdaabca']" ] }, - "execution_count": 73, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -1828,27 +1831,27 @@ }, { "cell_type": "code", - "execution_count": 74, + "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "* . . . . . . . . . .\n", - "a . . . . . . . . . .\n", - "c . . . . . . . . . .\n", - "c b b . . . . . . . .\n", - "b b . . . . . . . . .\n", - ". a b b . . . . . . .\n", - ". . . d b a a . . . .\n", - ". . . . a a a b a d a\n", - ". . . . a a . a . a a\n", - ". . . . . . . d a . d\n", - ". . . . . . . . . . c\n", - "ACCbBAbbDbaaAbadaADC\n", - "accbbabbdbaaabadaadc\n", - "*** ** * * ***\n" + "* b . . . . . . . . .\n", + ". c d b . . . . . . .\n", + ". d . d . . . . . . .\n", + ". . . d a c . . . . .\n", + ". . . . c c b d . . .\n", + ". . . . . . d d . . .\n", + ". . . . . . . b . . .\n", + ". . . . . . . b . . .\n", + ". . . . . . . d a a .\n", + ". . . . . . . . . b .\n", + ". . . . . . . . . c a\n", + "bCdbDDacCbdDBBDaaBCa\n", + "bcdbddaccbddbbdaabca\n", + " * ** * **** ** \n" ] }, { @@ -1857,7 +1860,7 @@ "True" ] }, - "execution_count": 74, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -1872,24 +1875,24 @@ }, { "cell_type": "code", - "execution_count": 75, + "execution_count": 39, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "aacccabaddcdaddaabdc\n", - " * ** ** * * * **\n" + "dcccaadcdddcdbbbadbc\n", + " * **** ** ***\n" ] }, { "data": { "text/plain": [ - "6" + "4" ] }, - "execution_count": 75, + "execution_count": 39, "metadata": {}, "output_type": "execute_result" } @@ -1903,7 +1906,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 40, "metadata": {}, "outputs": [ { @@ -1911,19 +1914,19 @@ "output_type": "stream", "text": [ "* . . . . . . . . . .\n", - "b d . . . . . . . . .\n", - ". b c c . . . . . . .\n", - ". . . d . . . . . . .\n", - ". . . c a a . . . . .\n", - ". . . a a a . . . . .\n", - ". . . a a a d a . . .\n", - ". . . a a . a a b a c\n", - ". . . . d a . . . . d\n", - ". . . . . . . . . . d\n", - ". . . . . . . . . . c\n", - "BdBccDCaaAAdaAbacDDC\n", - "bdbccdcaaaadaabacddc\n", - "* * ** ** * ***\n" + "b c d . . . . . . . .\n", + ". d . . . . . . . . .\n", + ". b d d . . . . . . .\n", + ". . . a c . . . . . .\n", + ". . . c c . . . . . .\n", + ". . . . b d . . . . .\n", + ". . . . d d b b d . .\n", + ". . . . . . . . a . .\n", + ". . . . . . . . a b c\n", + ". . . . . . . . . . a\n", + "BcDBddAcCBdDbbdAAbcA\n", + "bcdbddaccbddbbdaabca\n", + "* ** * ** * ** *\n" ] }, { @@ -1932,7 +1935,7 @@ "True" ] }, - "execution_count": 39, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -1947,7 +1950,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 41, "metadata": {}, "outputs": [ { @@ -1975,7 +1978,7 @@ "False" ] }, - "execution_count": 40, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -1990,7 +1993,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -2019,7 +2022,7 @@ "False" ] }, - "execution_count": 41, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -2038,12 +2041,24 @@ "collapsed": true }, "source": [ - "# Make puzzle data" + "# Make puzzle data\n", + "\n", + "## Note to self\n", + "Include some distractors in the test set, such that:\n", + "* subsequence(my_bill, distractor) is true\n", + "* subsequence(friend_bill, distractor) is true\n", + "* interleave(my_bill, friend_bill, distractor) is false\n", + "\n", + "(i.e. characters are shared between my_bill and friend_bill)\n", + "\n", + "Students are taking a greedy approach to subsequence, and saying the interleave is true if both bills are subsequences of the distractor.\n", + "\n", + "i.e. \"aaa\" and \"aab\" are both subsequences of \"aaabbb\", but cannot be interleaved to form \"aaabbb\".\n" ] }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 43, "metadata": { "collapsed": true }, @@ -2064,7 +2079,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 44, "metadata": { "collapsed": true }, @@ -2075,15 +2090,15 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 45, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 3.16 s, sys: 8 ms, total: 3.16 s\n", - "Wall time: 3.17 s\n" + "CPU times: user 3.4 s, sys: 0 ns, total: 3.4 s\n", + "Wall time: 3.4 s\n" ] }, { @@ -2092,7 +2107,7 @@ "[0]" ] }, - "execution_count": 49, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -2103,15 +2118,15 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 46, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 788 ms, sys: 0 ns, total: 788 ms\n", - "Wall time: 789 ms\n" + "CPU times: user 932 ms, sys: 0 ns, total: 932 ms\n", + "Wall time: 932 ms\n" ] }, { @@ -2120,7 +2135,7 @@ "[0]" ] }, - "execution_count": 50, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } @@ -2131,7 +2146,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 47, "metadata": { "collapsed": true }, @@ -2146,6 +2161,208 @@ "# f.write('{}: {}\\n'.format(i, b))" ] }, + { + "cell_type": "code", + "execution_count": 51, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def is_subseq_greedy(s1, s2):\n", + " i = j = 0\n", + " while i < len(s1) and j < len(s2):\n", + " if s1[i] == s2[j]:\n", + " i += 1\n", + " j += 1\n", + " return i == len(s1)" + ] + }, + { + "cell_type": "code", + "execution_count": 94, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def subseq_partition(s1, s2):\n", + " i = j = 0\n", + " remainder = ''\n", + " while i < len(s1) and j < len(s2):\n", + " if s1[i] == s2[j]:\n", + " i += 1\n", + " else:\n", + " remainder += s2[j]\n", + " j += 1\n", + " return i == len(s1), remainder" + ] + }, + { + "cell_type": "code", + "execution_count": 88, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(40, 40, 20, 20)" + ] + }, + "execution_count": 88, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "common = make_string(10)\n", + "padding = make_string(10)\n", + "middle = interleave(common, padding)\n", + "\n", + "pre1 = make_string(5)\n", + "suf1 = make_string(5)\n", + "\n", + "pre2 = make_string(5)\n", + "suf2 = make_string(5)\n", + "\n", + "pre = interleave(pre1, pre2)\n", + "suf = interleave(suf1, suf2)\n", + "\n", + "distractor = pre + middle + suf\n", + "\n", + "sub1 = pre1 + common + suf1\n", + "sub2 = pre2 + common + suf2\n", + "\n", + "valid = interleave(sub1, sub2)\n", + "\n", + "len(distractor), len(valid), len(sub1), len(sub2)" + ] + }, + { + "cell_type": "code", + "execution_count": 89, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(True, True)" + ] + }, + "execution_count": 89, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_subseq_greedy(sub1, distractor), is_subseq_greedy(sub2, distractor)" + ] + }, + { + "cell_type": "code", + "execution_count": 90, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(True, True)" + ] + }, + "execution_count": 90, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_subseq_greedy(sub1, valid), is_subseq_greedy(sub2, valid)" + ] + }, + { + "cell_type": "code", + "execution_count": 91, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(False, True)" + ] + }, + "execution_count": 91, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_interleave(sub1, sub2, distractor), is_interleave(sub1, sub2, valid)" + ] + }, + { + "cell_type": "code", + "execution_count": 93, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('efcfdffcdbcehdffghch',\n", + " 'hhdgeffcdbcehdfhfded',\n", + " 'hhefdcgefdffdhgcdbcdbbeebhdefgfhgfdehdch',\n", + " 'hhdegeffcffcdfdbcefchdfdbchehfddeffghdch')" + ] + }, + "execution_count": 93, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sub1, sub2, distractor, valid" + ] + }, + { + "cell_type": "code", + "execution_count": 96, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 96, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a, b = subseq_partition(sub1, distractor)\n", + "b == sub2" + ] + }, + { + "cell_type": "code", + "execution_count": 98, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "('hhdgeffcdbcehfdhfded', 'hhdgeffcdbcehdfhfded')" + ] + }, + "execution_count": 98, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "a, b = subseq_partition(sub1, valid)\n", + "b, sub2" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/09-resolving-the-bill/resolving-the-bill-solution.ipynb b/09-resolving-the-bill/resolving-the-bill-solution.ipynb index 3d9d63f..ed427e6 100644 --- a/09-resolving-the-bill/resolving-the-bill-solution.ipynb +++ b/09-resolving-the-bill/resolving-the-bill-solution.ipynb @@ -78,7 +78,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 104, "metadata": {}, "outputs": [ { @@ -87,7 +87,7 @@ "148" ] }, - "execution_count": 1, + "execution_count": 104, "metadata": {}, "output_type": "execute_result" } @@ -100,7 +100,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 105, "metadata": { "collapsed": true }, @@ -114,7 +114,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 106, "metadata": { "collapsed": true }, @@ -134,7 +134,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 107, "metadata": { "collapsed": true }, @@ -158,7 +158,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 108, "metadata": { "collapsed": true }, @@ -178,7 +178,24 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 109, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def is_subseq_greedy(s1, s2):\n", + " i = j = 0\n", + " while i < len(s1) and j < len(s2):\n", + " if s1[i] == s2[j]:\n", + " i += 1\n", + " j += 1\n", + " return i == len(s1)" + ] + }, + { + "cell_type": "code", + "execution_count": 110, "metadata": { "collapsed": true }, @@ -233,7 +250,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 111, "metadata": { "collapsed": true }, @@ -284,7 +301,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 112, "metadata": {}, "outputs": [ { @@ -293,7 +310,7 @@ "22" ] }, - "execution_count": 7, + "execution_count": 112, "metadata": {}, "output_type": "execute_result" } @@ -306,7 +323,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 113, "metadata": {}, "outputs": [ { @@ -315,7 +332,7 @@ "22" ] }, - "execution_count": 36, + "execution_count": 113, "metadata": {}, "output_type": "execute_result" } @@ -328,34 +345,36 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 114, "metadata": {}, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 loop, best of 3: 8.02 s per loop\n" - ] + "data": { + "text/plain": [ + "22" + ] + }, + "execution_count": 114, + "metadata": {}, + "output_type": "execute_result" } ], "source": [ - "%%timeit\n", "sum(1 for s in bills\n", " if s != 0\n", - " if is_subseq(bills[0], bills[s]))" + " if is_subseq_greedy(bills[0], bills[s]))" ] }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 12, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 3.04 s per loop\n" + "1 loop, best of 3: 7.07 s per loop\n" ] } ], @@ -363,12 +382,12 @@ "%%timeit\n", "sum(1 for s in bills\n", " if s != 0\n", - " if is_subseq_rows(bills[0], bills[s]))" + " if is_subseq(bills[0], bills[s]))" ] }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 14, "metadata": { "scrolled": true }, @@ -400,7 +419,7 @@ " 146]" ] }, - "execution_count": 9, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -413,15 +432,15 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 15, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 168 ms, sys: 0 ns, total: 168 ms\n", - "Wall time: 166 ms\n" + "CPU times: user 148 ms, sys: 0 ns, total: 148 ms\n", + "Wall time: 148 ms\n" ] }, { @@ -430,7 +449,7 @@ "(True, False)" ] }, - "execution_count": 65, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -441,7 +460,7 @@ }, { "cell_type": "code", - "execution_count": 73, + "execution_count": 16, "metadata": { "collapsed": true }, @@ -452,7 +471,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -679,7 +698,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 18, "metadata": { "collapsed": true }, @@ -703,7 +722,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 19, "metadata": { "collapsed": true }, @@ -779,7 +798,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 20, "metadata": { "collapsed": true }, @@ -852,7 +871,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 21, "metadata": { "collapsed": true }, @@ -932,7 +951,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 22, "metadata": { "collapsed": true }, @@ -956,7 +975,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 23, "metadata": {}, "outputs": [ { @@ -965,7 +984,7 @@ "[30]" ] }, - "execution_count": 44, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -977,7 +996,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 24, "metadata": {}, "outputs": [ { @@ -986,7 +1005,7 @@ "[30]" ] }, - "execution_count": 41, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -998,7 +1017,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 25, "metadata": {}, "outputs": [ { @@ -1007,7 +1026,7 @@ "[30]" ] }, - "execution_count": 48, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -1019,7 +1038,29 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 102, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "[30]" + ] + }, + "execution_count": 102, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "[s for s in bills\n", + " if is_subseq(bills[0], bills[s])\n", + " if is_subseq(bills[1], bills[s])]" + ] + }, + { + "cell_type": "code", + "execution_count": 26, "metadata": {}, "outputs": [ { @@ -1236,7 +1277,7 @@ "True" ] }, - "execution_count": 45, + "execution_count": 26, "metadata": {}, "output_type": "execute_result" } @@ -1250,7 +1291,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 27, "metadata": {}, "outputs": [ { @@ -1259,7 +1300,7 @@ "[30]" ] }, - "execution_count": 48, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -1271,14 +1312,14 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 28, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 2.68 s per loop\n" + "1 loop, best of 3: 2.81 s per loop\n" ] } ], @@ -1290,14 +1331,14 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 29, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 1.06 s per loop\n" + "1 loop, best of 3: 916 ms per loop\n" ] } ], @@ -1309,14 +1350,14 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 30, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 1.56 s per loop\n" + "1 loop, best of 3: 1.45 s per loop\n" ] } ], @@ -1328,14 +1369,14 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 31, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 660 ms per loop\n" + "1 loop, best of 3: 705 ms per loop\n" ] } ], @@ -1362,7 +1403,7 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 32, "metadata": {}, "outputs": [ { @@ -1371,7 +1412,7 @@ "(4.223305555555555, 4, 13, 23.899999999999636)" ] }, - "execution_count": 1, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -1387,7 +1428,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 33, "metadata": {}, "outputs": [ { @@ -1396,7 +1437,7 @@ "(11.13438888888889, 11, 8, 3.8000000000029104)" ] }, - "execution_count": 2, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -1412,7 +1453,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 34, "metadata": {}, "outputs": [ { @@ -1421,7 +1462,7 @@ "(15.36486111111111, 15, 21, 53.5)" ] }, - "execution_count": 3, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -1435,6 +1476,194 @@ ")" ] }, + { + "cell_type": "markdown", + "metadata": { + "collapsed": true + }, + "source": [ + "# Explanations" + ] + }, + { + "cell_type": "code", + "execution_count": 95, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "starget = 'acba'\n", + "swrong = 'cdabcaca'\n", + "sinterleave = 'abcacbba'\n", + "ssubseq = 'aaccabab'" + ] + }, + { + "cell_type": "code", + "execution_count": 84, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def show_subseq_md_table(short, long, table):\n", + " header = '| |' + '|'.join('{}
{}'.format('
'.join(str(long[:i])), i) for i in range(len(long) + 1)) + '|'\n", + " separator = '|:---:' * (len(long) + 2) + '|'\n", + " rows = []\n", + " columns = sorted(set(k[1] for k in table))\n", + " for r in range(len(short) + 1):\n", + " row = '|{}
{}|'.format(r, short[:r])\n", + " row += '|'.join('T' if table[r, c] else '.' for c in columns)\n", + " row += '|'\n", + " rows += [row]\n", + " return '\\n'.join([header] + [separator] + rows)\n", + "# return '\\n'.join(\n", + "# ' '.join('T' if table[i, j] else '.' for j in sorted(set([k[1] for k in table])))\n", + "# for i in sorted(set([k[0] for k in table]))) " + ] + }, + { + "cell_type": "code", + "execution_count": 82, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + ". . . . . . . . .\n", + ". a a c c a b a b\n", + ". . . c c a b a b\n", + ". . . . . . b a b\n", + ". . . . . . . a b\n", + "AcCaBAb\n" + ] + } + ], + "source": [ + "v, bp, t = is_subseq(starget, ssubseq, return_backpointers=True, return_table=True)\n", + "print(show_annotated_table(t, bp))\n", + "print(show_backtrace_s(bp))" + ] + }, + { + "cell_type": "code", + "execution_count": 83, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "T T T T T T T T T\n", + ". T T T T T T T T\n", + ". . . T T T T T T\n", + ". . . . . . T T T\n", + ". . . . . . . T T\n" + ] + } + ], + "source": [ + "print(show_table(t))" + ] + }, + { + "cell_type": "code", + "execution_count": 85, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "| |
0|a
1|a
a
2|a
a
c
3|a
a
c
c
4|a
a
c
c
a
5|a
a
c
c
a
b
6|a
a
c
c
a
b
a
7|a
a
c
c
a
b
a
b
8|\n", + "|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|\n", + "|0
|T|T|T|T|T|T|T|T|T|\n", + "|1
a|.|T|T|T|T|T|T|T|T|\n", + "|2
ac|.|.|.|T|T|T|T|T|T|\n", + "|3
acb|.|.|.|.|.|.|T|T|T|\n", + "|4
acba|.|.|.|.|.|.|.|T|T|\n" + ] + } + ], + "source": [ + "print(show_subseq_md_table(starget, ssubseq, t))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "| |
0|a
1|a
a
2|a
a
c
3|a
a
c
c
4|a
a
c
c
a
5|a
a
c
c
a
b
6|a
a
c
c
a
b
a
7|a
a
c
c
a
b
a
b
8|\n", + "|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|\n", + "|0
|T|T|T|T|T|T|T|T|T|\n", + "|1
a|.|T|T|T|T|T|T|T|T|\n", + "|2
ac|.|.|.|T|T|T|T|T|T|\n", + "|3
acb|.|.|.|.|.|.|T|T|T|\n", + "|4
acba|.|.|.|.|.|.|.|T|T|" + ] + }, + { + "cell_type": "code", + "execution_count": 99, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + ". . . . . . . . .\n", + ". . . a b c a c a\n", + ". . . . . c a c a\n", + ". . . . . . . . .\n", + ". . . . . . . . .\n", + "ACa\n" + ] + } + ], + "source": [ + "v, bp, t = is_subseq(starget, swrong, return_backpointers=True, return_table=True)\n", + "print(show_annotated_table(t, bp))\n", + "print(show_backtrace_s(bp))" + ] + }, + { + "cell_type": "code", + "execution_count": 100, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "| |
0|c
1|c
d
2|c
d
a
3|c
d
a
b
4|c
d
a
b
c
5|c
d
a
b
c
a
6|c
d
a
b
c
a
c
7|c
d
a
b
c
a
c
a
8|\n", + "|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|\n", + "|0
|T|T|T|T|T|T|T|T|T|\n", + "|1
a|.|.|.|T|T|T|T|T|T|\n", + "|2
ac|.|.|.|.|.|T|T|T|T|\n", + "|3
acb|.|.|.|.|.|.|.|.|.|\n", + "|4
acba|.|.|.|.|.|.|.|.|.|\n" + ] + } + ], + "source": [ + "print(show_subseq_md_table(starget, swrong, t))" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "| |
0|c
1|c
d
2|c
d
a
3|c
d
a
b
4|c
d
a
b
c
5|c
d
a
b
c
a
6|c
d
a
b
c
a
c
7|c
d
a
b
c
a
c
a
8|\n", + "|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|\n", + "|0
|T|T|T|T|T|T|T|T|T|\n", + "|1
a|.|.|.|T|T|T|T|T|T|\n", + "|2
ac|.|.|.|.|.|T|T|T|T|\n", + "|3
acb|.|.|.|.|.|.|.|.|.|\n", + "|4
acba|.|.|.|.|.|.|.|.|.|" + ] + }, { "cell_type": "code", "execution_count": null, diff --git a/09-resolving-the-bill/subseq-failure-full.html b/09-resolving-the-bill/subseq-failure-full.html new file mode 100644 index 0000000..55a0249 --- /dev/null +++ b/09-resolving-the-bill/subseq-failure-full.html @@ -0,0 +1,90 @@ + ++++++++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

0
c
1
c
d
2
c
d
a
3
c
d
a
b
4
c
d
a
b
c
5
c
d
a
b
c
a
6
c
d
a
b
c
a
c
7
c
d
a
b
c
a
c
a
8
0
TTTTTTTTT
1
a
...TTTTTT
2
ac
.....TTTT
3
acb
.........
4
acba
.........
diff --git a/09-resolving-the-bill/subseq-failure-full.md b/09-resolving-the-bill/subseq-failure-full.md new file mode 100644 index 0000000..aecdecc --- /dev/null +++ b/09-resolving-the-bill/subseq-failure-full.md @@ -0,0 +1,7 @@ +| |
0|c
1|c
d
2|c
d
a
3|c
d
a
b
4|c
d
a
b
c
5|c
d
a
b
c
a
6|c
d
a
b
c
a
c
7|c
d
a
b
c
a
c
a
8| +|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| +|0
|T|T|T|T|T|T|T|T|T| +|1
a|.|.|.|T|T|T|T|T|T| +|2
ac|.|.|.|.|.|T|T|T|T| +|3
acb|.|.|.|.|.|.|.|.|.| +|4
acba|.|.|.|.|.|.|.|.|.| diff --git a/09-resolving-the-bill/subseq-success-full.html b/09-resolving-the-bill/subseq-success-full.html new file mode 100644 index 0000000..bcf195a --- /dev/null +++ b/09-resolving-the-bill/subseq-success-full.html @@ -0,0 +1,90 @@ + ++++++++++++ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +

0
a
1
a
a
2
a
a
c
3
a
a
c
c
4
a
a
c
c
a
5
a
a
c
c
a
b
6
a
a
c
c
a
b
a
7
a
a
c
c
a
b
a
b
8
0
TTTTTTTTT
1
a
.TTTTTTTT
2
ac
...TTTTTT
3
acb
......TTT
4
acba
.......TT
diff --git a/09-resolving-the-bill/subseq-success-full.md b/09-resolving-the-bill/subseq-success-full.md new file mode 100644 index 0000000..8da38d0 --- /dev/null +++ b/09-resolving-the-bill/subseq-success-full.md @@ -0,0 +1,7 @@ +| |
0|a
1|a
a
2|a
a
c
3|a
a
c
c
4|a
a
c
c
a
5|a
a
c
c
a
b
6|a
a
c
c
a
b
a
7|a
a
c
c
a
b
a
b
8| +|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:|:---:| +|0
|T|T|T|T|T|T|T|T|T| +|1
a|.|T|T|T|T|T|T|T|T| +|2
ac|.|.|.|T|T|T|T|T|T| +|3
acb|.|.|.|.|.|.|T|T|T| +|4
acba|.|.|.|.|.|.|.|T|T|