From 690b9aa61348310a072473b58ebbbd424dce2b45 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Thu, 29 Jun 2017 22:49:51 +0100 Subject: [PATCH] Added recursive solutions --- 09-resolving-the-bill/interleaving.ipynb | 1420 ++++++++++++---------- 09-resolving-the-bill/subsequence.ipynb | 430 +++++-- 2 files changed, 1098 insertions(+), 752 deletions(-) diff --git a/09-resolving-the-bill/interleaving.ipynb b/09-resolving-the-bill/interleaving.ipynb index 26ebb46..c1c4bed 100644 --- a/09-resolving-the-bill/interleaving.ipynb +++ b/09-resolving-the-bill/interleaving.ipynb @@ -651,7 +651,7 @@ { "data": { "text/plain": [ - "'gbbdffedehgebaaeghbggcfeegfaccdhaaaachhdhhchfcfdfb'" + "'fgcebagebfhfbadbgggacgeebbfceffhbhbgdfhhbahgbchbhe'" ] }, "execution_count": 18, @@ -713,51 +713,54 @@ "name": "stdout", "output_type": "stream", "text": [ - "0 0 0 adding u\n", + "0 0 0 adding y\n", "0 1 -1 adding a\n", - "1 1 0 adding c\n", - "2 1 1 adding v\n", - "2 2 0 adding h\n", - "3 2 1 adding e\n", - "4 2 2 adding v\n", - "4 3 1 adding e\n", - "5 3 2 adding u\n", - "5 4 1 adding f\n", - "6 4 2 adding u\n", - "6 5 1 adding v\n", + "1 1 0 adding z\n", + "1 2 -1 adding v\n", + "1 3 -2 adding x\n", + "1 4 -3 adding z\n", + "1 5 -4 adding w\n", + "1 6 -5 adding e\n", + "2 6 -4 adding h\n", + "3 6 -3 adding b\n", + "4 6 -2 adding a\n", + "5 6 -1 adding b\n", "6 6 0 adding u\n", "6 7 -1 adding x\n", - "6 8 -2 adding z\n", - "6 9 -3 adding u\n", - "6 10 -4 adding a\n", - "7 10 -3 adding e\n", - "8 10 -2 adding d\n", - "9 10 -1 adding h\n", - "10 10 0 adding v\n", - "10 11 -1 adding u\n", - "10 12 -2 adding h\n", - "11 12 -1 adding g\n", - "12 12 0 adding x\n", - "12 13 -1 adding e\n", - "13 13 0 adding f\n", - "14 13 1 adding w\n", - "14 14 0 adding y\n", - "14 15 -1 adding u\n", - "14 16 -2 adding d\n", - "15 16 -1 adding g\n", - "16 16 0 adding h\n", - "17 16 1 adding g\n", - "18 16 2 adding g\n", - "19 16 3 adding g\n", - "20 16 4 remaining s2 yyuz\n" + "6 8 -2 adding e\n", + "7 8 -1 adding y\n", + "7 9 -2 adding x\n", + "7 10 -3 adding x\n", + "7 11 -4 adding x\n", + "7 12 -5 adding e\n", + "8 12 -4 adding e\n", + "9 12 -3 adding z\n", + "9 13 -4 adding z\n", + "9 14 -5 adding a\n", + "10 14 -4 adding c\n", + "11 14 -3 adding y\n", + "11 15 -4 adding d\n", + "12 15 -3 adding g\n", + "13 15 -2 adding g\n", + "14 15 -1 adding c\n", + "15 15 0 adding x\n", + "15 16 -1 adding e\n", + "16 16 0 adding f\n", + "17 16 1 adding w\n", + "17 17 0 adding w\n", + "17 18 -1 adding v\n", + "17 19 -2 adding f\n", + "18 19 -1 adding a\n", + "19 19 0 adding g\n", + "20 19 1 remaining s2 z\n" ] }, { "data": { "text/plain": [ - "('acheefaedhhgefdghggg',\n", - " 'uvvuuvuxzuvuxwyuyyuz',\n", - " 'uacvheveufuvuxzuaedhvuhgxefwyudghgggyyuz',\n", + "('aehbabeeeacdggceffag',\n", + " 'yzvxzwuxyxxxzzyxwwvz',\n", + " 'yazvxzwehbabuxeyxxxeezzacydggcxefwwvfagz',\n", " 40)" ] }, @@ -783,466 +786,472 @@ "output_type": "stream", "text": [ "xxxx 0 0 ! ! ! True\n", - "seq2 0 1 ! a u False\n", - "seq2 0 2 ! c a False\n", - "seq2 0 3 ! h c False\n", - "seq2 0 4 ! e v False\n", - "seq2 0 5 ! e h False\n", - "seq2 0 6 ! f e False\n", - "seq2 0 7 ! a v False\n", + "seq2 0 1 ! a y False\n", + "seq2 0 2 ! e a False\n", + "seq2 0 3 ! h z False\n", + "seq2 0 4 ! b v False\n", + "seq2 0 5 ! a x False\n", + "seq2 0 6 ! b z False\n", + "seq2 0 7 ! e w False\n", "seq2 0 8 ! e e False\n", - "seq2 0 9 ! d u False\n", - "seq2 0 10 ! h f False\n", - "seq2 0 11 ! h u False\n", - "seq2 0 12 ! g v False\n", - "seq2 0 13 ! e u False\n", - "seq2 0 14 ! f x False\n", - "seq2 0 15 ! d z False\n", - "seq2 0 16 ! g u False\n", - "seq2 0 17 ! h a False\n", - "seq2 0 18 ! g e False\n", - "seq2 0 19 ! g d False\n", - "seq2 0 20 ! g h False\n", - "seq1 1 0 u ! u True\n", - "seq2 1 1 u a a True\n", - "seq2 1 2 u c c True\n", - "xxxx 1 3 u h v False\n", - "xxxx 1 4 u e h False\n", - "xxxx 1 5 u e e False\n", - "xxxx 1 6 u f v False\n", - "xxxx 1 7 u a e False\n", - "xxxx 1 8 u e u False\n", - "xxxx 1 9 u d f False\n", - "xxxx 1 10 u h u False\n", - "xxxx 1 11 u h v False\n", - "xxxx 1 12 u g u False\n", - "xxxx 1 13 u e x False\n", - "xxxx 1 14 u f z False\n", - "xxxx 1 15 u d u False\n", - "xxxx 1 16 u g a False\n", - "xxxx 1 17 u h e False\n", - "xxxx 1 18 u g d False\n", - "xxxx 1 19 u g h False\n", - "xxxx 1 20 u g v False\n", - "seq1 2 0 v ! a False\n", - "xxxx 2 1 v a c False\n", - "seq1 2 2 v c v True\n", - "seq2 2 3 v h h True\n", - "seq2 2 4 v e e True\n", - "xxxx 2 5 v e v False\n", - "xxxx 2 6 v f e False\n", - "xxxx 2 7 v a u False\n", - "xxxx 2 8 v e f False\n", - "xxxx 2 9 v d u False\n", - "xxxx 2 10 v h v False\n", - "xxxx 2 11 v h u False\n", - "xxxx 2 12 v g x False\n", - "xxxx 2 13 v e z False\n", - "xxxx 2 14 v f u False\n", - "xxxx 2 15 v d a False\n", - "xxxx 2 16 v g e False\n", - "xxxx 2 17 v h d False\n", - "xxxx 2 18 v g h False\n", - "xxxx 2 19 v g v False\n", - "xxxx 2 20 v g u False\n", - "seq1 3 0 v ! c False\n", - "xxxx 3 1 v a v False\n", - "xxxx 3 2 v c h False\n", - "xxxx 3 3 v h e False\n", - "seq1 3 4 v e v True\n", - "seq2 3 5 v e e True\n", - "xxxx 3 6 v f u False\n", - "xxxx 3 7 v a f False\n", - "xxxx 3 8 v e u False\n", - "xxxx 3 9 v d v False\n", - "xxxx 3 10 v h u False\n", - "xxxx 3 11 v h x False\n", - "xxxx 3 12 v g z False\n", - "xxxx 3 13 v e u False\n", - "xxxx 3 14 v f a False\n", - "xxxx 3 15 v d e False\n", - "xxxx 3 16 v g d False\n", - "xxxx 3 17 v h h False\n", - "xxxx 3 18 v g v False\n", - "xxxx 3 19 v g u False\n", - "xxxx 3 20 v g h False\n", - "seq1 4 0 u ! v False\n", - "xxxx 4 1 u a h False\n", - "xxxx 4 2 u c e False\n", - "xxxx 4 3 u h v False\n", - "xxxx 4 4 u e e False\n", - "seq1 4 5 u e u True\n", - "seq2 4 6 u f f True\n", - "xxxx 4 7 u a u False\n", - "xxxx 4 8 u e v False\n", - "xxxx 4 9 u d u False\n", - "xxxx 4 10 u h x False\n", - "xxxx 4 11 u h z False\n", - "xxxx 4 12 u g u False\n", - "xxxx 4 13 u e a False\n", - "xxxx 4 14 u f e False\n", - "xxxx 4 15 u d d False\n", - "xxxx 4 16 u g h False\n", - "xxxx 4 17 u h v False\n", - "xxxx 4 18 u g u False\n", - "xxxx 4 19 u g h False\n", - "xxxx 4 20 u g g False\n", - "seq1 5 0 u ! h False\n", - "xxxx 5 1 u a e False\n", - "xxxx 5 2 u c v False\n", - "xxxx 5 3 u h e False\n", - "xxxx 5 4 u e u False\n", - "xxxx 5 5 u e f False\n", - "seq1 5 6 u f u True\n", - "xxxx 5 7 u a v False\n", - "xxxx 5 8 u e u False\n", - "xxxx 5 9 u d x False\n", - "xxxx 5 10 u h z False\n", - "xxxx 5 11 u h u False\n", - "xxxx 5 12 u g a False\n", - "xxxx 5 13 u e e False\n", - "xxxx 5 14 u f d False\n", - "xxxx 5 15 u d h False\n", - "xxxx 5 16 u g v False\n", - "xxxx 5 17 u h u False\n", - "xxxx 5 18 u g h False\n", - "xxxx 5 19 u g g False\n", - "xxxx 5 20 u g x False\n", - "seq1 6 0 v ! e False\n", - "xxxx 6 1 v a v False\n", - "xxxx 6 2 v c e False\n", - "xxxx 6 3 v h u False\n", - "xxxx 6 4 v e f False\n", - "xxxx 6 5 v e u False\n", - "seq1 6 6 v f v True\n", - "xxxx 6 7 v a u False\n", - "xxxx 6 8 v e x False\n", - "xxxx 6 9 v d z False\n", - "xxxx 6 10 v h u False\n", - "xxxx 6 11 v h a False\n", - "xxxx 6 12 v g e False\n", - "xxxx 6 13 v e d False\n", - "xxxx 6 14 v f h False\n", - "xxxx 6 15 v d v False\n", - "xxxx 6 16 v g u False\n", - "xxxx 6 17 v h h False\n", - "xxxx 6 18 v g g False\n", - "xxxx 6 19 v g x False\n", - "xxxx 6 20 v g e False\n", - "seq1 7 0 u ! v False\n", + "seq2 0 9 ! e h False\n", + "seq2 0 10 ! a b False\n", + "seq2 0 11 ! c a False\n", + "seq2 0 12 ! d b False\n", + "seq2 0 13 ! g u False\n", + "seq2 0 14 ! g x False\n", + "seq2 0 15 ! c e False\n", + "seq2 0 16 ! e y False\n", + "seq2 0 17 ! f x False\n", + "seq2 0 18 ! f x False\n", + "seq2 0 19 ! a x False\n", + "seq2 0 20 ! g e False\n", + "seq1 1 0 y ! y True\n", + "seq2 1 1 y a a True\n", + "xxxx 1 2 y e z False\n", + "xxxx 1 3 y h v False\n", + "xxxx 1 4 y b x False\n", + "xxxx 1 5 y a z False\n", + "xxxx 1 6 y b w False\n", + "xxxx 1 7 y e e False\n", + "xxxx 1 8 y e h False\n", + "xxxx 1 9 y e b False\n", + "xxxx 1 10 y a a False\n", + "xxxx 1 11 y c b False\n", + "xxxx 1 12 y d u False\n", + "xxxx 1 13 y g x False\n", + "xxxx 1 14 y g e False\n", + "xxxx 1 15 y c y False\n", + "xxxx 1 16 y e x False\n", + "xxxx 1 17 y f x False\n", + "xxxx 1 18 y f x False\n", + "xxxx 1 19 y a e False\n", + "xxxx 1 20 y g e False\n", + "seq1 2 0 z ! a False\n", + "seq1 2 1 z a z True\n", + "xxxx 2 2 z e v False\n", + "xxxx 2 3 z h x False\n", + "xxxx 2 4 z b z False\n", + "xxxx 2 5 z a w False\n", + "xxxx 2 6 z b e False\n", + "xxxx 2 7 z e h False\n", + "xxxx 2 8 z e b False\n", + "xxxx 2 9 z e a False\n", + "xxxx 2 10 z a b False\n", + "xxxx 2 11 z c u False\n", + "xxxx 2 12 z d x False\n", + "xxxx 2 13 z g e False\n", + "xxxx 2 14 z g y False\n", + "xxxx 2 15 z c x False\n", + "xxxx 2 16 z e x False\n", + "xxxx 2 17 z f x False\n", + "xxxx 2 18 z f e False\n", + "xxxx 2 19 z a e False\n", + "xxxx 2 20 z g z False\n", + "seq1 3 0 v ! z False\n", + "seq1 3 1 v a v True\n", + "xxxx 3 2 v e x False\n", + "xxxx 3 3 v h z False\n", + "xxxx 3 4 v b w False\n", + "xxxx 3 5 v a e False\n", + "xxxx 3 6 v b h False\n", + "xxxx 3 7 v e b False\n", + "xxxx 3 8 v e a False\n", + "xxxx 3 9 v e b False\n", + "xxxx 3 10 v a u False\n", + "xxxx 3 11 v c x False\n", + "xxxx 3 12 v d e False\n", + "xxxx 3 13 v g y False\n", + "xxxx 3 14 v g x False\n", + "xxxx 3 15 v c x False\n", + "xxxx 3 16 v e x False\n", + "xxxx 3 17 v f e False\n", + "xxxx 3 18 v f e False\n", + "xxxx 3 19 v a z False\n", + "xxxx 3 20 v g z False\n", + "seq1 4 0 x ! v False\n", + "seq1 4 1 x a x True\n", + "xxxx 4 2 x e z False\n", + "xxxx 4 3 x h w False\n", + "xxxx 4 4 x b e False\n", + "xxxx 4 5 x a h False\n", + "xxxx 4 6 x b b False\n", + "xxxx 4 7 x e a False\n", + "xxxx 4 8 x e b False\n", + "xxxx 4 9 x e u False\n", + "xxxx 4 10 x a x False\n", + "xxxx 4 11 x c e False\n", + "xxxx 4 12 x d y False\n", + "xxxx 4 13 x g x False\n", + "xxxx 4 14 x g x False\n", + "xxxx 4 15 x c x False\n", + "xxxx 4 16 x e e False\n", + "xxxx 4 17 x f e False\n", + "xxxx 4 18 x f z False\n", + "xxxx 4 19 x a z False\n", + "xxxx 4 20 x g a False\n", + "seq1 5 0 z ! x False\n", + "seq1 5 1 z a z True\n", + "xxxx 5 2 z e w False\n", + "xxxx 5 3 z h e False\n", + "xxxx 5 4 z b h False\n", + "xxxx 5 5 z a b False\n", + "xxxx 5 6 z b a False\n", + "xxxx 5 7 z e b False\n", + "xxxx 5 8 z e u False\n", + "xxxx 5 9 z e x False\n", + "xxxx 5 10 z a e False\n", + "xxxx 5 11 z c y False\n", + "xxxx 5 12 z d x False\n", + "xxxx 5 13 z g x False\n", + "xxxx 5 14 z g x False\n", + "xxxx 5 15 z c e False\n", + "xxxx 5 16 z e e False\n", + "xxxx 5 17 z f z False\n", + "xxxx 5 18 z f z False\n", + "xxxx 5 19 z a a False\n", + "xxxx 5 20 z g c False\n", + "seq1 6 0 w ! z False\n", + "seq1 6 1 w a w True\n", + "seq2 6 2 w e e True\n", + "seq2 6 3 w h h True\n", + "seq2 6 4 w b b True\n", + "seq2 6 5 w a a True\n", + "seq2 6 6 w b b True\n", + "xxxx 6 7 w e u False\n", + "xxxx 6 8 w e x False\n", + "xxxx 6 9 w e e False\n", + "xxxx 6 10 w a y False\n", + "xxxx 6 11 w c x False\n", + "xxxx 6 12 w d x False\n", + "xxxx 6 13 w g x False\n", + "xxxx 6 14 w g e False\n", + "xxxx 6 15 w c e False\n", + "xxxx 6 16 w e z False\n", + "xxxx 6 17 w f z False\n", + "xxxx 6 18 w f a False\n", + "xxxx 6 19 w a c False\n", + "xxxx 6 20 w g y False\n", + "seq1 7 0 u ! w False\n", "xxxx 7 1 u a e False\n", - "xxxx 7 2 u c u False\n", - "xxxx 7 3 u h f False\n", - "xxxx 7 4 u e u False\n", - "xxxx 7 5 u e v False\n", - "seq1 7 6 u f u True\n", - "xxxx 7 7 u a x False\n", - "xxxx 7 8 u e z False\n", - "xxxx 7 9 u d u False\n", - "xxxx 7 10 u h a False\n", - "xxxx 7 11 u h e False\n", - "xxxx 7 12 u g d False\n", - "xxxx 7 13 u e h False\n", - "xxxx 7 14 u f v False\n", - "xxxx 7 15 u d u False\n", - "xxxx 7 16 u g h False\n", - "xxxx 7 17 u h g False\n", - "xxxx 7 18 u g x False\n", - "xxxx 7 19 u g e False\n", - "xxxx 7 20 u g f False\n", + "xxxx 7 2 u e h False\n", + "xxxx 7 3 u h b False\n", + "xxxx 7 4 u b a False\n", + "xxxx 7 5 u a b False\n", + "seq1 7 6 u b u True\n", + "xxxx 7 7 u e x False\n", + "xxxx 7 8 u e e False\n", + "xxxx 7 9 u e y False\n", + "xxxx 7 10 u a x False\n", + "xxxx 7 11 u c x False\n", + "xxxx 7 12 u d x False\n", + "xxxx 7 13 u g e False\n", + "xxxx 7 14 u g e False\n", + "xxxx 7 15 u c z False\n", + "xxxx 7 16 u e z False\n", + "xxxx 7 17 u f a False\n", + "xxxx 7 18 u f c False\n", + "xxxx 7 19 u a y False\n", + "xxxx 7 20 u g d False\n", "seq1 8 0 x ! e False\n", - "xxxx 8 1 x a u False\n", - "xxxx 8 2 x c f False\n", - "xxxx 8 3 x h u False\n", - "xxxx 8 4 x e v False\n", - "xxxx 8 5 x e u False\n", - "seq1 8 6 x f x True\n", - "xxxx 8 7 x a z False\n", - "xxxx 8 8 x e u False\n", - "xxxx 8 9 x d a False\n", - "xxxx 8 10 x h e False\n", - "xxxx 8 11 x h d False\n", - "xxxx 8 12 x g h False\n", - "xxxx 8 13 x e v False\n", - "xxxx 8 14 x f u False\n", - "xxxx 8 15 x d h False\n", - "xxxx 8 16 x g g False\n", - "xxxx 8 17 x h x False\n", - "xxxx 8 18 x g e False\n", - "xxxx 8 19 x g f False\n", - "xxxx 8 20 x g w False\n", - "seq1 9 0 z ! u False\n", - "xxxx 9 1 z a f False\n", - "xxxx 9 2 z c u False\n", - "xxxx 9 3 z h v False\n", - "xxxx 9 4 z e u False\n", - "xxxx 9 5 z e x False\n", - "seq1 9 6 z f z True\n", - "xxxx 9 7 z a u False\n", - "xxxx 9 8 z e a False\n", - "xxxx 9 9 z d e False\n", - "xxxx 9 10 z h d False\n", - "xxxx 9 11 z h h False\n", - "xxxx 9 12 z g v False\n", - "xxxx 9 13 z e u False\n", - "xxxx 9 14 z f h False\n", - "xxxx 9 15 z d g False\n", - "xxxx 9 16 z g x False\n", - "xxxx 9 17 z h e False\n", - "xxxx 9 18 z g f False\n", - "xxxx 9 19 z g w False\n", - "xxxx 9 20 z g y False\n", - "seq1 10 0 u ! f False\n", - "xxxx 10 1 u a u False\n", - "xxxx 10 2 u c v False\n", - "xxxx 10 3 u h u False\n", - "xxxx 10 4 u e x False\n", - "xxxx 10 5 u e z False\n", - "seq1 10 6 u f u True\n", - "seq2 10 7 u a a True\n", - "seq2 10 8 u e e True\n", - "seq2 10 9 u d d True\n", - "seq2 10 10 u h h True\n", - "xxxx 10 11 u h v False\n", - "xxxx 10 12 u g u False\n", - "xxxx 10 13 u e h False\n", - "xxxx 10 14 u f g False\n", - "xxxx 10 15 u d x False\n", - "xxxx 10 16 u g e False\n", - "xxxx 10 17 u h f False\n", - "xxxx 10 18 u g w False\n", - "xxxx 10 19 u g y False\n", - "xxxx 10 20 u g u False\n", - "seq1 11 0 v ! u False\n", - "xxxx 11 1 v a v False\n", - "xxxx 11 2 v c u False\n", - "xxxx 11 3 v h x False\n", - "xxxx 11 4 v e z False\n", - "xxxx 11 5 v e u False\n", - "xxxx 11 6 v f a False\n", - "xxxx 11 7 v a e False\n", - "xxxx 11 8 v e d False\n", - "xxxx 11 9 v d h False\n", - "seq1 11 10 v h v True\n", - "xxxx 11 11 v h u False\n", - "xxxx 11 12 v g h False\n", - "xxxx 11 13 v e g False\n", - "xxxx 11 14 v f x False\n", - "xxxx 11 15 v d e False\n", - "xxxx 11 16 v g f False\n", - "xxxx 11 17 v h w False\n", - "xxxx 11 18 v g y False\n", - "xxxx 11 19 v g u False\n", - "xxxx 11 20 v g d False\n", - "seq1 12 0 u ! v False\n", - "xxxx 12 1 u a u False\n", - "xxxx 12 2 u c x False\n", - "xxxx 12 3 u h z False\n", - "xxxx 12 4 u e u False\n", - "xxxx 12 5 u e a False\n", - "xxxx 12 6 u f e False\n", - "xxxx 12 7 u a d False\n", - "xxxx 12 8 u e h False\n", - "xxxx 12 9 u d v False\n", - "seq1 12 10 u h u True\n", - "seq2 12 11 u h h True\n", - "seq2 12 12 u g g True\n", - "xxxx 12 13 u e x False\n", - "xxxx 12 14 u f e False\n", - "xxxx 12 15 u d f False\n", - "xxxx 12 16 u g w False\n", - "xxxx 12 17 u h y False\n", - "xxxx 12 18 u g u False\n", - "xxxx 12 19 u g d False\n", - "xxxx 12 20 u g g False\n", - "seq1 13 0 x ! u False\n", - "xxxx 13 1 x a x False\n", - "xxxx 13 2 x c z False\n", - "xxxx 13 3 x h u False\n", - "xxxx 13 4 x e a False\n", - "xxxx 13 5 x e e False\n", - "xxxx 13 6 x f d False\n", - "xxxx 13 7 x a h False\n", - "xxxx 13 8 x e v False\n", - "xxxx 13 9 x d u False\n", - "xxxx 13 10 x h h False\n", - "xxxx 13 11 x h g False\n", - "seq1 13 12 x g x True\n", - "seq2 13 13 x e e True\n", - "seq2 13 14 x f f True\n", - "xxxx 13 15 x d w False\n", - "xxxx 13 16 x g y False\n", - "xxxx 13 17 x h u False\n", - "xxxx 13 18 x g d False\n", - "xxxx 13 19 x g g False\n", - "xxxx 13 20 x g h False\n", - "seq1 14 0 w ! x False\n", - "xxxx 14 1 w a z False\n", - "xxxx 14 2 w c u False\n", - "xxxx 14 3 w h a False\n", - "xxxx 14 4 w e e False\n", - "xxxx 14 5 w e d False\n", - "xxxx 14 6 w f h False\n", - "xxxx 14 7 w a v False\n", - "xxxx 14 8 w e u False\n", - "xxxx 14 9 w d h False\n", - "xxxx 14 10 w h g False\n", - "xxxx 14 11 w h x False\n", - "xxxx 14 12 w g e False\n", - "xxxx 14 13 w e f False\n", - "seq1 14 14 w f w True\n", - "xxxx 14 15 w d y False\n", - "xxxx 14 16 w g u False\n", - "xxxx 14 17 w h d False\n", - "xxxx 14 18 w g g False\n", - "xxxx 14 19 w g h False\n", - "xxxx 14 20 w g g False\n", - "seq1 15 0 y ! z False\n", - "xxxx 15 1 y a u False\n", - "xxxx 15 2 y c a False\n", - "xxxx 15 3 y h e False\n", - "xxxx 15 4 y e d False\n", - "xxxx 15 5 y e h False\n", - "xxxx 15 6 y f v False\n", - "xxxx 15 7 y a u False\n", - "xxxx 15 8 y e h False\n", - "xxxx 15 9 y d g False\n", - "xxxx 15 10 y h x False\n", - "xxxx 15 11 y h e False\n", - "xxxx 15 12 y g f False\n", - "xxxx 15 13 y e w False\n", - "seq1 15 14 y f y True\n", - "xxxx 15 15 y d u False\n", - "xxxx 15 16 y g d False\n", - "xxxx 15 17 y h g False\n", - "xxxx 15 18 y g h False\n", - "xxxx 15 19 y g g False\n", - "xxxx 15 20 y g g False\n", - "seq1 16 0 u ! u False\n", - "xxxx 16 1 u a a False\n", - "xxxx 16 2 u c e False\n", - "xxxx 16 3 u h d False\n", - "xxxx 16 4 u e h False\n", - "xxxx 16 5 u e v False\n", - "xxxx 16 6 u f u False\n", - "xxxx 16 7 u a h False\n", - "xxxx 16 8 u e g False\n", - "xxxx 16 9 u d x False\n", - "xxxx 16 10 u h e False\n", - "xxxx 16 11 u h f False\n", - "xxxx 16 12 u g w False\n", - "xxxx 16 13 u e y False\n", - "seq1 16 14 u f u True\n", - "seq2 16 15 u d d True\n", - "seq2 16 16 u g g True\n", - "seq2 16 17 u h h True\n", - "seq2 16 18 u g g True\n", - "seq2 16 19 u g g True\n", - "seq2 16 20 u g g True\n", - "seq1 17 0 y ! a False\n", - "xxxx 17 1 y a e False\n", - "xxxx 17 2 y c d False\n", - "xxxx 17 3 y h h False\n", - "xxxx 17 4 y e v False\n", - "xxxx 17 5 y e u False\n", - "xxxx 17 6 y f h False\n", - "xxxx 17 7 y a g False\n", - "xxxx 17 8 y e x False\n", - "xxxx 17 9 y d e False\n", - "xxxx 17 10 y h f False\n", - "xxxx 17 11 y h w False\n", - "xxxx 17 12 y g y False\n", - "xxxx 17 13 y e u False\n", - "xxxx 17 14 y f d False\n", - "xxxx 17 15 y d g False\n", - "xxxx 17 16 y g h False\n", - "xxxx 17 17 y h g False\n", - "xxxx 17 18 y g g False\n", - "xxxx 17 19 y g g False\n", - "seq1 17 20 y g y True\n", - "seq1 18 0 y ! e False\n", - "xxxx 18 1 y a d False\n", - "xxxx 18 2 y c h False\n", - "xxxx 18 3 y h v False\n", - "xxxx 18 4 y e u False\n", - "xxxx 18 5 y e h False\n", - "xxxx 18 6 y f g False\n", - "xxxx 18 7 y a x False\n", - "xxxx 18 8 y e e False\n", - "xxxx 18 9 y d f False\n", - "xxxx 18 10 y h w False\n", - "xxxx 18 11 y h y False\n", - "xxxx 18 12 y g u False\n", - "xxxx 18 13 y e d False\n", - "xxxx 18 14 y f g False\n", - "xxxx 18 15 y d h False\n", - "xxxx 18 16 y g g False\n", - "xxxx 18 17 y h g False\n", - "xxxx 18 18 y g g False\n", - "xxxx 18 19 y g y False\n", - "seq1 18 20 y g y True\n", - "seq1 19 0 u ! d False\n", - "xxxx 19 1 u a h False\n", - "xxxx 19 2 u c v False\n", - "xxxx 19 3 u h u False\n", - "xxxx 19 4 u e h False\n", - "xxxx 19 5 u e g False\n", - "xxxx 19 6 u f x False\n", - "xxxx 19 7 u a e False\n", - "xxxx 19 8 u e f False\n", - "xxxx 19 9 u d w False\n", - "xxxx 19 10 u h y False\n", - "xxxx 19 11 u h u False\n", - "xxxx 19 12 u g d False\n", - "xxxx 19 13 u e g False\n", - "xxxx 19 14 u f h False\n", - "xxxx 19 15 u d g False\n", - "xxxx 19 16 u g g False\n", - "xxxx 19 17 u h g False\n", - "xxxx 19 18 u g y False\n", - "xxxx 19 19 u g y False\n", - "seq1 19 20 u g u True\n", - "seq1 20 0 z ! h False\n", - "xxxx 20 1 z a v False\n", - "xxxx 20 2 z c u False\n", - "xxxx 20 3 z h h False\n", - "xxxx 20 4 z e g False\n", - "xxxx 20 5 z e x False\n", - "xxxx 20 6 z f e False\n", - "xxxx 20 7 z a f False\n", - "xxxx 20 8 z e w False\n", - "xxxx 20 9 z d y False\n", - "xxxx 20 10 z h u False\n", - "xxxx 20 11 z h d False\n", - "xxxx 20 12 z g g False\n", - "xxxx 20 13 z e h False\n", - "xxxx 20 14 z f g False\n", - "xxxx 20 15 z d g False\n", - "xxxx 20 16 z g g False\n", - "xxxx 20 17 z h y False\n", - "xxxx 20 18 z g y False\n", - "xxxx 20 19 z g u False\n", + "xxxx 8 1 x a h False\n", + "xxxx 8 2 x e b False\n", + "xxxx 8 3 x h a False\n", + "xxxx 8 4 x b b False\n", + "xxxx 8 5 x a u False\n", + "seq1 8 6 x b x True\n", + "seq2 8 7 x e e True\n", + "xxxx 8 8 x e y False\n", + "xxxx 8 9 x e x False\n", + "xxxx 8 10 x a x False\n", + "xxxx 8 11 x c x False\n", + "xxxx 8 12 x d e False\n", + "xxxx 8 13 x g e False\n", + "xxxx 8 14 x g z False\n", + "xxxx 8 15 x c z False\n", + "xxxx 8 16 x e a False\n", + "xxxx 8 17 x f c False\n", + "xxxx 8 18 x f y False\n", + "xxxx 8 19 x a d False\n", + "xxxx 8 20 x g g False\n", + "seq1 9 0 y ! h False\n", + "xxxx 9 1 y a b False\n", + "xxxx 9 2 y e a False\n", + "xxxx 9 3 y h b False\n", + "xxxx 9 4 y b u False\n", + "xxxx 9 5 y a x False\n", + "xxxx 9 6 y b e False\n", + "seq1 9 7 y e y True\n", + "xxxx 9 8 y e x False\n", + "xxxx 9 9 y e x False\n", + "xxxx 9 10 y a x False\n", + "xxxx 9 11 y c e False\n", + "xxxx 9 12 y d e False\n", + "xxxx 9 13 y g z False\n", + "xxxx 9 14 y g z False\n", + "xxxx 9 15 y c a False\n", + "xxxx 9 16 y e c False\n", + "xxxx 9 17 y f y False\n", + "xxxx 9 18 y f d False\n", + "xxxx 9 19 y a g False\n", + "xxxx 9 20 y g g False\n", + "seq1 10 0 x ! b False\n", + "xxxx 10 1 x a a False\n", + "xxxx 10 2 x e b False\n", + "xxxx 10 3 x h u False\n", + "xxxx 10 4 x b x False\n", + "xxxx 10 5 x a e False\n", + "xxxx 10 6 x b y False\n", + "seq1 10 7 x e x True\n", + "xxxx 10 8 x e x False\n", + "xxxx 10 9 x e x False\n", + "xxxx 10 10 x a e False\n", + "xxxx 10 11 x c e False\n", + "xxxx 10 12 x d z False\n", + "xxxx 10 13 x g z False\n", + "xxxx 10 14 x g a False\n", + "xxxx 10 15 x c c False\n", + "xxxx 10 16 x e y False\n", + "xxxx 10 17 x f d False\n", + "xxxx 10 18 x f g False\n", + "xxxx 10 19 x a g False\n", + "xxxx 10 20 x g c False\n", + "seq1 11 0 x ! a False\n", + "xxxx 11 1 x a b False\n", + "xxxx 11 2 x e u False\n", + "xxxx 11 3 x h x False\n", + "xxxx 11 4 x b e False\n", + "xxxx 11 5 x a y False\n", + "xxxx 11 6 x b x False\n", + "seq1 11 7 x e x True\n", + "xxxx 11 8 x e x False\n", + "xxxx 11 9 x e e False\n", + "xxxx 11 10 x a e False\n", + "xxxx 11 11 x c z False\n", + "xxxx 11 12 x d z False\n", + "xxxx 11 13 x g a False\n", + "xxxx 11 14 x g c False\n", + "xxxx 11 15 x c y False\n", + "xxxx 11 16 x e d False\n", + "xxxx 11 17 x f g False\n", + "xxxx 11 18 x f g False\n", + "xxxx 11 19 x a c False\n", + "xxxx 11 20 x g x False\n", + "seq1 12 0 x ! b False\n", + "xxxx 12 1 x a u False\n", + "xxxx 12 2 x e x False\n", + "xxxx 12 3 x h e False\n", + "xxxx 12 4 x b y False\n", + "xxxx 12 5 x a x False\n", + "xxxx 12 6 x b x False\n", + "seq1 12 7 x e x True\n", + "seq2 12 8 x e e True\n", + "seq2 12 9 x e e True\n", + "xxxx 12 10 x a z False\n", + "xxxx 12 11 x c z False\n", + "xxxx 12 12 x d a False\n", + "xxxx 12 13 x g c False\n", + "xxxx 12 14 x g y False\n", + "xxxx 12 15 x c d False\n", + "xxxx 12 16 x e g False\n", + "xxxx 12 17 x f g False\n", + "xxxx 12 18 x f c False\n", + "xxxx 12 19 x a x False\n", + "xxxx 12 20 x g e False\n", + "seq1 13 0 z ! u False\n", + "xxxx 13 1 z a x False\n", + "xxxx 13 2 z e e False\n", + "xxxx 13 3 z h y False\n", + "xxxx 13 4 z b x False\n", + "xxxx 13 5 z a x False\n", + "xxxx 13 6 z b x False\n", + "xxxx 13 7 z e e False\n", + "xxxx 13 8 z e e False\n", + "seq1 13 9 z e z True\n", + "xxxx 13 10 z a z False\n", + "xxxx 13 11 z c a False\n", + "xxxx 13 12 z d c False\n", + "xxxx 13 13 z g y False\n", + "xxxx 13 14 z g d False\n", + "xxxx 13 15 z c g False\n", + "xxxx 13 16 z e g False\n", + "xxxx 13 17 z f c False\n", + "xxxx 13 18 z f x False\n", + "xxxx 13 19 z a e False\n", + "xxxx 13 20 z g f False\n", + "seq1 14 0 z ! x False\n", + "xxxx 14 1 z a e False\n", + "xxxx 14 2 z e y False\n", + "xxxx 14 3 z h x False\n", + "xxxx 14 4 z b x False\n", + "xxxx 14 5 z a x False\n", + "xxxx 14 6 z b e False\n", + "xxxx 14 7 z e e False\n", + "xxxx 14 8 z e z False\n", + "seq1 14 9 z e z True\n", + "seq2 14 10 z a a True\n", + "seq2 14 11 z c c True\n", + "xxxx 14 12 z d y False\n", + "xxxx 14 13 z g d False\n", + "xxxx 14 14 z g g False\n", + "xxxx 14 15 z c g False\n", + "xxxx 14 16 z e c False\n", + "xxxx 14 17 z f x False\n", + "xxxx 14 18 z f e False\n", + "xxxx 14 19 z a f False\n", + "xxxx 14 20 z g w False\n", + "seq1 15 0 y ! e False\n", + "xxxx 15 1 y a y False\n", + "xxxx 15 2 y e x False\n", + "xxxx 15 3 y h x False\n", + "xxxx 15 4 y b x False\n", + "xxxx 15 5 y a e False\n", + "xxxx 15 6 y b e False\n", + "xxxx 15 7 y e z False\n", + "xxxx 15 8 y e z False\n", + "xxxx 15 9 y e a False\n", + "xxxx 15 10 y a c False\n", + "seq1 15 11 y c y True\n", + "seq2 15 12 y d d True\n", + "seq2 15 13 y g g True\n", + "seq2 15 14 y g g True\n", + "seq2 15 15 y c c True\n", + "xxxx 15 16 y e x False\n", + "xxxx 15 17 y f e False\n", + "xxxx 15 18 y f f False\n", + "xxxx 15 19 y a w False\n", + "xxxx 15 20 y g w False\n", + "seq1 16 0 x ! y False\n", + "xxxx 16 1 x a x False\n", + "xxxx 16 2 x e x False\n", + "xxxx 16 3 x h x False\n", + "xxxx 16 4 x b e False\n", + "xxxx 16 5 x a e False\n", + "xxxx 16 6 x b z False\n", + "xxxx 16 7 x e z False\n", + "xxxx 16 8 x e a False\n", + "xxxx 16 9 x e c False\n", + "xxxx 16 10 x a y False\n", + "xxxx 16 11 x c d False\n", + "xxxx 16 12 x d g False\n", + "xxxx 16 13 x g g False\n", + "xxxx 16 14 x g c False\n", + "seq1 16 15 x c x True\n", + "seq2 16 16 x e e True\n", + "seq2 16 17 x f f True\n", + "xxxx 16 18 x f w False\n", + "xxxx 16 19 x a w False\n", + "xxxx 16 20 x g v False\n", + "seq1 17 0 w ! x False\n", + "xxxx 17 1 w a x False\n", + "xxxx 17 2 w e x False\n", + "xxxx 17 3 w h e False\n", + "xxxx 17 4 w b e False\n", + "xxxx 17 5 w a z False\n", + "xxxx 17 6 w b z False\n", + "xxxx 17 7 w e a False\n", + "xxxx 17 8 w e c False\n", + "xxxx 17 9 w e y False\n", + "xxxx 17 10 w a d False\n", + "xxxx 17 11 w c g False\n", + "xxxx 17 12 w d g False\n", + "xxxx 17 13 w g c False\n", + "xxxx 17 14 w g x False\n", + "xxxx 17 15 w c e False\n", + "xxxx 17 16 w e f False\n", + "seq1 17 17 w f w True\n", + "xxxx 17 18 w f w False\n", + "xxxx 17 19 w a v False\n", + "xxxx 17 20 w g f False\n", + "seq1 18 0 w ! x False\n" + ] + }, + { + "name": "stdout", + "output_type": "stream", + "text": [ + "xxxx 18 1 w a x False\n", + "xxxx 18 2 w e e False\n", + "xxxx 18 3 w h e False\n", + "xxxx 18 4 w b z False\n", + "xxxx 18 5 w a z False\n", + "xxxx 18 6 w b a False\n", + "xxxx 18 7 w e c False\n", + "xxxx 18 8 w e y False\n", + "xxxx 18 9 w e d False\n", + "xxxx 18 10 w a g False\n", + "xxxx 18 11 w c g False\n", + "xxxx 18 12 w d c False\n", + "xxxx 18 13 w g x False\n", + "xxxx 18 14 w g e False\n", + "xxxx 18 15 w c f False\n", + "xxxx 18 16 w e w False\n", + "seq1 18 17 w f w True\n", + "xxxx 18 18 w f v False\n", + "xxxx 18 19 w a f False\n", + "xxxx 18 20 w g a False\n", + "seq1 19 0 v ! x False\n", + "xxxx 19 1 v a e False\n", + "xxxx 19 2 v e e False\n", + "xxxx 19 3 v h z False\n", + "xxxx 19 4 v b z False\n", + "xxxx 19 5 v a a False\n", + "xxxx 19 6 v b c False\n", + "xxxx 19 7 v e y False\n", + "xxxx 19 8 v e d False\n", + "xxxx 19 9 v e g False\n", + "xxxx 19 10 v a g False\n", + "xxxx 19 11 v c c False\n", + "xxxx 19 12 v d x False\n", + "xxxx 19 13 v g e False\n", + "xxxx 19 14 v g f False\n", + "xxxx 19 15 v c w False\n", + "xxxx 19 16 v e w False\n", + "seq1 19 17 v f v True\n", + "seq2 19 18 v f f True\n", + "seq2 19 19 v a a True\n", + "seq2 19 20 v g g True\n", + "seq1 20 0 z ! e False\n", + "xxxx 20 1 z a e False\n", + "xxxx 20 2 z e z False\n", + "xxxx 20 3 z h z False\n", + "xxxx 20 4 z b a False\n", + "xxxx 20 5 z a c False\n", + "xxxx 20 6 z b y False\n", + "xxxx 20 7 z e d False\n", + "xxxx 20 8 z e g False\n", + "xxxx 20 9 z e g False\n", + "xxxx 20 10 z a c False\n", + "xxxx 20 11 z c x False\n", + "xxxx 20 12 z d e False\n", + "xxxx 20 13 z g f False\n", + "xxxx 20 14 z g w False\n", + "xxxx 20 15 z c w False\n", + "xxxx 20 16 z e v False\n", + "xxxx 20 17 z f f False\n", + "xxxx 20 18 z f a False\n", + "xxxx 20 19 z a g False\n", "seq1 20 20 z g z True\n", "T . . . . . . . . . . . . . . . . . . . .\n", - "T T T . . . . . . . . . . . . . . . . . .\n", - ". . T T T . . . . . . . . . . . . . . . .\n", - ". . . . T T . . . . . . . . . . . . . . .\n", - ". . . . . T T . . . . . . . . . . . . . .\n", + "T T . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . .\n", + ". T T T T T T . . . . . . . . . . . . . .\n", ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T T T T T . . . . . . . . . .\n", - ". . . . . . . . . . T . . . . . . . . . .\n", - ". . . . . . . . . . T T T . . . . . . . .\n", - ". . . . . . . . . . . . T T T . . . . . .\n", - ". . . . . . . . . . . . . . T . . . . . .\n", - ". . . . . . . . . . . . . . T . . . . . .\n", - ". . . . . . . . . . . . . . T T T T T T T\n", - ". . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . T\n", + ". . . . . . T T . . . . . . . . . . . . .\n", + ". . . . . . . T . . . . . . . . . . . . .\n", + ". . . . . . . T . . . . . . . . . . . . .\n", + ". . . . . . . T . . . . . . . . . . . . .\n", + ". . . . . . . T T T . . . . . . . . . . .\n", + ". . . . . . . . . T . . . . . . . . . . .\n", + ". . . . . . . . . T T T . . . . . . . . .\n", + ". . . . . . . . . . . T T T T T . . . . .\n", + ". . . . . . . . . . . . . . . T T T . . .\n", + ". . . . . . . . . . . . . . . . . T . . .\n", + ". . . . . . . . . . . . . . . . . T . . .\n", + ". . . . . . . . . . . . . . . . . T T T T\n", ". . . . . . . . . . . . . . . . . . . . T\n" ] } @@ -1260,7 +1269,7 @@ { "data": { "text/plain": [ - "'UacVheVeUfUVUXZUaedhVUhgXefWYUdghgggYYUZ'" + "'YaZVXZWehbabUXeYXXXeeZZacYdggcXefWWVfagZ'" ] }, "execution_count": 22, @@ -1282,27 +1291,27 @@ "output_type": "stream", "text": [ "T . . . . . . . . . . . . . . . . . . . .\n", - "T T T . . . . . . . . . . . . . . . . . .\n", - ". . T T T . . . . . . . . . . . . . . . .\n", - ". . . . T T . . . . . . . . . . . . . . .\n", - ". . . . . T T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", + "T T . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . .\n", + ". T T T T T T . . . . . . . . . . . . . .\n", ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T . . . . . . . . . . . . . .\n", - ". . . . . . T T T T T . . . . . . . . . .\n", - ". . . . . . . . . . T . . . . . . . . . .\n", - ". . . . . . . . . . T T T . . . . . . . .\n", - ". . . . . . . . . . . . T T T . . . . . .\n", - ". . . . . . . . . . . . . . T . . . . . .\n", - ". . . . . . . . . . . . . . T . . . . . .\n", - ". . . . . . . . . . . . . . T T T T T T T\n", - ". . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . T\n", + ". . . . . . T T . . . . . . . . . . . . .\n", + ". . . . . . . T . . . . . . . . . . . . .\n", + ". . . . . . . T . . . . . . . . . . . . .\n", + ". . . . . . . T . . . . . . . . . . . . .\n", + ". . . . . . . T T T . . . . . . . . . . .\n", + ". . . . . . . . . T . . . . . . . . . . .\n", + ". . . . . . . . . T T T . . . . . . . . .\n", + ". . . . . . . . . . . T T T T T . . . . .\n", + ". . . . . . . . . . . . . . . T T T . . .\n", + ". . . . . . . . . . . . . . . . . T . . .\n", + ". . . . . . . . . . . . . . . . . T . . .\n", + ". . . . . . . . . . . . . . . . . T T T T\n", ". . . . . . . . . . . . . . . . . . . . T\n", - ". . . . . . . . . . . . . . . . . . . . T\n", - "UacVheVeUfUVUXZUaedhVUhgXefWYUdghgggYYUZ\n" + "YaZVXZWehbabUXeYXXXeeZZacYdggcXefWWVfagZ\n" ] }, { @@ -1331,9 +1340,9 @@ { "data": { "text/plain": [ - "('gfccbgegegaccfcgeehbgcafchgbfdfbggbcachfdfaccfbffb',\n", - " 'accfcfbdaabcabbbegdfffhcgcefbddegghgfdgcgdcffcfdcd',\n", - " 'acgcfcffbdcacbabcagbbbegegegadcfcffcgfeehbgchacfchggcbefbfddfbdggbegcgachhfgfdfdgcgdacccfbffcffbfdcd',\n", + "('ehcceddeafddffefgffdfbbedabhbadebdchfabhhbfghdggcd',\n", + " 'hdahagaefhadaaaeehdhfaeafgcgcdfbegehdfchbfecgbgfbe',\n", + " 'hehcdahceddageaaefddfffefgfhafddaafaebbehedhdfabaeahbadfgcgecbddcfbhfegeahbhdhbfcfhgbfhdgecgbgcgdfbe',\n", " 100)" ] }, @@ -1359,57 +1368,57 @@ "output_type": "stream", "text": [ "T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - "T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - "T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". T . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . T 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 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . T T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . T . . T T T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . T . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . T T T T T . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . T T T T . . . . . . . . . . . . . . .\n", + "T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . T T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . T . . T T T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . T . T . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . T . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T T T .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . T T . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . T\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . T T\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T\n", - "ACgCFCfFBDcAcbABCAgBBBegegEGaDcFcfFcgFeehbgcHaCfchgGCbEFBfdDfbDggbEGcGachHfGFdfDGCGDaccCfbFFCffbFDCD\n" + "HehcDAHceddAGeaAEfddffFefgfHAfdDAAfAEbbEHeDHdFabAEAhbadFGCGeCbdDcFBhfEGEaHbhDhbFCfHgBFhdgECGBgcGdFBE\n" ] }, { @@ -1457,58 +1466,58 @@ "name": "stdout", "output_type": "stream", "text": [ - "T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . T T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . T . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . T T . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + "T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . T T T 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 T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . T . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . T . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . T . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . T . T T T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . T . T T T . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . T T T T T . . . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T . . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T T . . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . T T . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . T . . . .\n", - ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T\n", - "acGcfcfFbdCaCBabcaGbbbegEGEGAdCfCfFCGfEEHBGChAcFCHgGcBefbFdDFBdGGBegCgAChHFgfDFdgcgdAcCCFBffcFFBfdcd\n" + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . T T . . . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . . . . . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T T T . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T . T . . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T . . .\n", + ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . T T T T\n", + "hEHCdahCEDDagEaAeFDDfFFEFGFhaFdDaaFaeBBehEdhDfABaeaHBADfgcgEcBdDCfbHFegeAhBHdHBfcFhGbfHDGecgbGCgDfbe\n" ] }, { @@ -1557,7 +1566,7 @@ { "data": { "text/plain": [ - "('adadhfgacgbahfchffghdfffcfcdccchedahggdffhgbacghbe', False, False)" + "('ahgafgaagdgccegafedggefddeaabhffchdgeabcfaacahcgge', False, False)" ] }, "execution_count": 29, @@ -1579,7 +1588,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "T T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", + "T . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", @@ -1630,7 +1639,7 @@ ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", ". . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .\n", - "a\n" + "\n" ] }, { @@ -1651,6 +1660,85 @@ "v" ] }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def is_interleave_recursive(s1, s2, s3):\n", + " if not s1:\n", + " return s2 == s3\n", + " elif not s2:\n", + " return s1 == s3\n", + " else:\n", + " if s1[-1] == s2[-1] and s1[-1] == s3[-1]:\n", + " return is_interleave_recursive(s1[:-1], s2, s3[:-1]) or is_interleave(s1, s2[:-1], s3[:-1])\n", + " elif s1[-1] == s3[-1]:\n", + " return is_interleave_recursive(s1[:-1], s2, s3[:-1])\n", + " elif s2[-1] == s3[-1]:\n", + " return is_interleave(s1, s2[:-1], s3[:-1])\n", + " else:\n", + " return False" + ] + }, + { + "cell_type": "code", + "execution_count": 48, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "s1 = make_string(500)\n", + "s2 = make_string(500)\n", + "s3 = make_string(500)\n", + "s12 = interleave(s1, s2)\n", + "s23 = interleave(s2, s3)" + ] + }, + { + "cell_type": "code", + "execution_count": 49, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 49, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_interleave_recursive(s1, s2, s12)" + ] + }, + { + "cell_type": "code", + "execution_count": 50, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 50, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_interleave_recursive(s1, s2, s23)" + ] + }, { "cell_type": "markdown", "metadata": {}, @@ -1660,7 +1748,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 32, "metadata": { "collapsed": true }, @@ -1673,7 +1761,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 33, "metadata": { "collapsed": true }, @@ -1699,16 +1787,16 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 34, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "('badbbdcadc', 'bdaadcadab', 'bdabaadbdcbadcaddacb', 20)" + "('acabcbccaa', 'cabcadddca', 'acabcbcccaaabcadddca', 20)" ] }, - "execution_count": 33, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -1723,27 +1811,27 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 35, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "* b d a . . . . . . .\n", - "b . . b a . . . . . .\n", - ". . . a a d . . . . .\n", - ". . . . d . . . . . .\n", - ". . . . b d c . . . .\n", - ". . . . . . b a d . .\n", - ". . . . . . . d . . .\n", - ". . . . . . . c . . .\n", - ". . . . . . . a d . .\n", - ". . . . . . . d d a .\n", - ". . . . . . . . . c b\n", - "bdaBaADBdcBaDCAdDaCb\n", - "bdabaadbdcbadcaddacb\n", - " * *** * *** * * \n" + "* . . . . . . . . . .\n", + "a c a b c . . . . . .\n", + "c . . c . . . . . . .\n", + "a . . . . . . . . . .\n", + "b c . . . . . . . . .\n", + "c . . . . . . . . . .\n", + "b c . . . . . . . . .\n", + "c c . . . . . . . . .\n", + "c c a . . . . . . . .\n", + ". a a . . . . . . . .\n", + ". a a b c a d d d c a\n", + "ACABCBcCCaAAbcadddca\n", + "acabcbcccaaabcadddca\n", + "****** ** ** \n" ] }, { @@ -1752,7 +1840,7 @@ "True" ] }, - "execution_count": 34, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -1767,27 +1855,27 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 36, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "* b . . . . . . . . .\n", - "b . . . . . . . . . .\n", - "d . . . . . . . . . .\n", - "a b a . . . . . . . .\n", - ". a a d b . . . . . .\n", - ". . d . d . . . . . .\n", - ". . . . c b . . . . .\n", - ". . . . . a d c a d .\n", - ". . . . . d . . d d .\n", - ". . . . . . . . . a c\n", - ". . . . . . . . . . b\n", - "BDAbaAdbDCbAdcadDAcB\n", - "bdabaadbdcbadcaddacb\n", - "*** * ** * ** *\n" + "* a c a b c b c c . .\n", + ". c . . c . c c c a a\n", + ". a . . . . . . a a a\n", + ". b c . . . . . . . b\n", + ". c . . . . . . . . c\n", + ". . . . . . . . . . a\n", + ". . . . . . . . . . d\n", + ". . . . . . . . . . d\n", + ". . . . . . . . . . d\n", + ". . . . . . . . . . c\n", + ". . . . . . . . . . a\n", + "acabcbccCaaABCADDDCA\n", + "acabcbcccaaabcadddca\n", + " * *********\n" ] }, { @@ -1796,7 +1884,7 @@ "True" ] }, - "execution_count": 35, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -1811,27 +1899,26 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 37, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "* . . . . . . . . . .\n", + "* a . . . . . . . . .\n", + "a . . . . . . . . . .\n", + "c a . . . . . . . . .\n", + "a . . . . . . . . . .\n", "b . . . . . . . . . .\n", + "c . . . . . . . . . .\n", + "b . . . . . . . . . .\n", + "c . . . . . . . . . .\n", + "c . . . . . . . . . .\n", ". . . . . . . . . . .\n", ". . . . . . . . . . .\n", - ". . . . . . . . . . .\n", - ". . . . . . . . . . .\n", - ". . . . . . . . . . .\n", - ". . . . . . . . . . .\n", - ". . . . . . . . . . .\n", - ". . . . . . . . . . .\n", - ". . . . . . . . . . .\n", - "B\n", - "b\n", - "*\n" + "\n", + "\n" ] }, { @@ -1840,7 +1927,7 @@ "False" ] }, - "execution_count": 36, + "execution_count": 37, "metadata": {}, "output_type": "execute_result" } @@ -1855,26 +1942,27 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 38, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "* . . . . . . . . . .\n", - "b . . . . . . . . . .\n", - "d a . . . . . . . . .\n", - "a . . . . . . . . . .\n", - ". . . . . . . . . . .\n", + "* a . . . . . . . . .\n", + ". c . . . . . . . . .\n", + ". a . . . . . . . . .\n", + ". b . . . . . . . . .\n", + ". c . . . . . . . . .\n", ". . . . . . . . . . .\n", ". . . . . . . . . . .\n", ". . . . . . . . . . .\n", ". . . . . . . . . . .\n", ". . . . . . . . . . .\n", ". . . . . . . . . . .\n", - "\n", - "\n" + "aCABC\n", + "acabc\n", + " ****\n" ] }, { @@ -1883,7 +1971,7 @@ "False" ] }, - "execution_count": 37, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } diff --git a/09-resolving-the-bill/subsequence.ipynb b/09-resolving-the-bill/subsequence.ipynb index 4484bfb..79d837f 100644 --- a/09-resolving-the-bill/subsequence.ipynb +++ b/09-resolving-the-bill/subsequence.ipynb @@ -19,7 +19,18 @@ }, { "cell_type": "code", - "execution_count": 1, + "execution_count": 33, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "import random" + ] + }, + { + "cell_type": "code", + "execution_count": 3, "metadata": { "collapsed": true }, @@ -41,7 +52,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 4, "metadata": { "scrolled": true }, @@ -117,7 +128,7 @@ " (5, 10): False}" ] }, - "execution_count": 2, + "execution_count": 4, "metadata": {}, "output_type": "execute_result" } @@ -131,7 +142,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 5, "metadata": { "collapsed": true }, @@ -145,7 +156,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 6, "metadata": {}, "outputs": [ { @@ -167,7 +178,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 7, "metadata": {}, "outputs": [ { @@ -244,7 +255,7 @@ " (4, 7): (4, 6, 'b', 's2')}" ] }, - "execution_count": 5, + "execution_count": 7, "metadata": {}, "output_type": "execute_result" } @@ -288,7 +299,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 8, "metadata": { "collapsed": true }, @@ -312,7 +323,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 9, "metadata": {}, "outputs": [ { @@ -321,7 +332,7 @@ "'AAAbAbb'" ] }, - "execution_count": 7, + "execution_count": 9, "metadata": {}, "output_type": "execute_result" } @@ -332,8 +343,67 @@ }, { "cell_type": "code", - "execution_count": 28, - "metadata": {}, + "execution_count": 11, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def is_subseq(seq1, seq2, return_backpointers=False, return_table=False, debug=False):\n", + " \"\"\"Return true if seq1 is a subsequence of seq2.\n", + " If return_backpointers, also return the set of backpointers to\n", + " reconstruct the subsequence\"\"\"\n", + " \n", + " # dp_table[i, j] is True if first i characters of seq1 can\n", + " # be found in the first j characters of seq2\n", + " \n", + " dp_table = {(i, j): False\n", + " for i in range(len(seq1)+1)\n", + " for j in range(len(seq2)+1)}\n", + "\n", + " backpointers = {}\n", + " \n", + " for i in range(len(seq1)+1):\n", + " for j in range(i, len(seq2)+1):\n", + " if i == 0 or j == 0:\n", + " dp_table[i, j] = True\n", + " if debug: print('aa', i, j, '!', '!', dp_table[i, j])\n", + " else:\n", + " # extend by character from s2\n", + " if dp_table[i, j-1]:\n", + " dp_table[i, j] = True\n", + " backpointers[i, j] = (i, j-1, seq2[j-1], 's2')\n", + " if debug: print('s2', i, j, seq1[i-1], seq2[j-1], dp_table[i, j]) \n", + " # extend by character from s1\n", + " if dp_table[i-1, j-1] and seq1[i-1] == seq2[j-1]:\n", + " dp_table[i, j] = True\n", + " backpointers[i, j] = (i-1, j-1, seq1[i-1], 's1') \n", + " if debug: print('s1', i, j, seq1[i-1], seq2[j-1], dp_table[i, j])\n", + " if not dp_table[i, j]:\n", + " if debug: print('xx', i, j, seq1[i-1], seq2[j-1], dp_table[i, j]) \n", + " \n", + "# if return_backpointers:\n", + "# return dp_table[len(seq1), len(seq2)], backpointers\n", + "# else:\n", + "# return dp_table[len(seq1), len(seq2)]\n", + " \n", + " if return_backpointers or return_table:\n", + " retval = [dp_table[len(seq1), len(seq2)]]\n", + " if return_backpointers:\n", + " retval += [backpointers]\n", + " if return_table:\n", + " retval += [dp_table]\n", + " return tuple(retval)\n", + " else:\n", + " return dp_table[len(seq1), len(seq2)]" + ] + }, + { + "cell_type": "code", + "execution_count": 12, + "metadata": { + "scrolled": true + }, "outputs": [ { "name": "stdout", @@ -398,7 +468,7 @@ "True" ] }, - "execution_count": 28, + "execution_count": 12, "metadata": {}, "output_type": "execute_result" } @@ -409,64 +479,7 @@ }, { "cell_type": "code", - "execution_count": 27, - "metadata": { - "collapsed": true - }, - "outputs": [], - "source": [ - "def is_subseq(seq1, seq2, return_backpointers=False, return_table=False, debug=False):\n", - " \"\"\"Return true if seq1 is a subsequence of seq2.\n", - " If return_backpointers, also return the set of backpointers to\n", - " reconstruct the subsequence\"\"\"\n", - " \n", - " # dp_table[i, j] is True if first i characters of seq1 can\n", - " # be found in the first j characters of seq2\n", - " \n", - " dp_table = {(i, j): False\n", - " for i in range(len(seq1)+1)\n", - " for j in range(len(seq2)+1)}\n", - "\n", - " backpointers = {}\n", - " \n", - " for i in range(len(seq1)+1):\n", - " for j in range(i, len(seq2)+1):\n", - " if i == 0 or j == 0:\n", - " dp_table[i, j] = True\n", - " if debug: print('aa', i, j, '!', '!', dp_table[i, j])\n", - " else:\n", - " # extend by character from s2\n", - " if dp_table[i, j-1]:\n", - " dp_table[i, j] = True\n", - " backpointers[i, j] = (i, j-1, seq2[j-1], 's2')\n", - " if debug: print('s2', i, j, seq1[i-1], seq2[j-1], dp_table[i, j]) \n", - " # extend by character from s1\n", - " if dp_table[i-1, j-1] and seq1[i-1] == seq2[j-1]:\n", - " dp_table[i, j] = True\n", - " backpointers[i, j] = (i-1, j-1, seq1[i-1], 's1') \n", - " if debug: print('s1', i, j, seq1[i-1], seq2[j-1], dp_table[i, j])\n", - " if not dp_table[i, j]:\n", - " if debug: print('xx', i, j, seq1[i-1], seq2[j-1], dp_table[i, j]) \n", - " \n", - "# if return_backpointers:\n", - "# return dp_table[len(seq1), len(seq2)], backpointers\n", - "# else:\n", - "# return dp_table[len(seq1), len(seq2)]\n", - " \n", - " if return_backpointers or return_table:\n", - " retval = [dp_table[len(seq1), len(seq2)]]\n", - " if return_backpointers:\n", - " retval += [backpointers]\n", - " if return_table:\n", - " retval += [dp_table]\n", - " return tuple(retval)\n", - " else:\n", - " return dp_table[len(seq1), len(seq2)]" - ] - }, - { - "cell_type": "code", - "execution_count": 37, + "execution_count": 13, "metadata": { "collapsed": true }, @@ -479,7 +492,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 14, "metadata": {}, "outputs": [ { @@ -488,7 +501,7 @@ "True" ] }, - "execution_count": 29, + "execution_count": 14, "metadata": {}, "output_type": "execute_result" } @@ -500,7 +513,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 15, "metadata": {}, "outputs": [ { @@ -509,7 +522,7 @@ "'AbAAbcAcb'" ] }, - "execution_count": 20, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -520,7 +533,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 16, "metadata": {}, "outputs": [ { @@ -541,7 +554,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 17, "metadata": {}, "outputs": [ { @@ -562,7 +575,7 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 18, "metadata": {}, "outputs": [ { @@ -571,7 +584,7 @@ "False" ] }, - "execution_count": 21, + "execution_count": 18, "metadata": {}, "output_type": "execute_result" } @@ -582,7 +595,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 19, "metadata": {}, "outputs": [ { @@ -591,7 +604,7 @@ "('aaaa', 'dabaabcacb')" ] }, - "execution_count": 24, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -602,7 +615,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 20, "metadata": {}, "outputs": [ { @@ -635,7 +648,7 @@ " (4, 10): (4, 9, 'b', 's2')}" ] }, - "execution_count": 23, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -646,20 +659,265 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 21, "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 21, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "is_subseq(s1, s2f)" ] }, + { + "cell_type": "code", + "execution_count": 22, + "metadata": { + "scrolled": true + }, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "aa 0 0 ! ! True\n", + "aa 0 1 ! ! True\n", + "aa 0 2 ! ! True\n", + "aa 0 3 ! ! True\n", + "aa 0 4 ! ! True\n", + "aa 0 5 ! ! True\n", + "aa 0 6 ! ! True\n", + "aa 0 7 ! ! True\n", + "s1 1 1 a a True\n", + "s2 1 2 a a True\n", + "s1 1 2 a a True\n", + "s2 1 3 a a True\n", + "s1 1 3 a a True\n", + "s2 1 4 a b True\n", + "s2 1 5 a a True\n", + "s1 1 5 a a True\n", + "s2 1 6 a b True\n", + "s2 1 7 a b True\n", + "s1 2 2 a a True\n", + "s2 2 3 a a True\n", + "s1 2 3 a a True\n", + "s2 2 4 a b True\n", + "s2 2 5 a a True\n", + "s1 2 5 a a True\n", + "s2 2 6 a b True\n", + "s2 2 7 a b True\n", + "s1 3 3 a a True\n", + "s2 3 4 a b True\n", + "s2 3 5 a a True\n", + "s1 3 5 a a True\n", + "s2 3 6 a b True\n", + "s2 3 7 a b True\n", + "xx 4 4 a b False\n", + "s1 4 5 a a True\n", + "s2 4 6 a b True\n", + "s2 4 7 a b True\n" + ] + }, + { + "data": { + "text/plain": [ + "(True,\n", + " {(1, 1): (0, 0, 'a', 's1'),\n", + " (1, 2): (0, 1, 'a', 's1'),\n", + " (1, 3): (0, 2, 'a', 's1'),\n", + " (1, 4): (1, 3, 'b', 's2'),\n", + " (1, 5): (0, 4, 'a', 's1'),\n", + " (1, 6): (1, 5, 'b', 's2'),\n", + " (1, 7): (1, 6, 'b', 's2'),\n", + " (2, 2): (1, 1, 'a', 's1'),\n", + " (2, 3): (1, 2, 'a', 's1'),\n", + " (2, 4): (2, 3, 'b', 's2'),\n", + " (2, 5): (1, 4, 'a', 's1'),\n", + " (2, 6): (2, 5, 'b', 's2'),\n", + " (2, 7): (2, 6, 'b', 's2'),\n", + " (3, 3): (2, 2, 'a', 's1'),\n", + " (3, 4): (3, 3, 'b', 's2'),\n", + " (3, 5): (2, 4, 'a', 's1'),\n", + " (3, 6): (3, 5, 'b', 's2'),\n", + " (3, 7): (3, 6, 'b', 's2'),\n", + " (4, 5): (3, 4, 'a', 's1'),\n", + " (4, 6): (4, 5, 'b', 's2'),\n", + " (4, 7): (4, 6, 'b', 's2')})" + ] + }, + "execution_count": 22, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_subseq('aaaa', 'aaababb', return_backpointers=True, debug=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 27, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def is_subseq_recursive(s1, s2):\n", + " if not s1:\n", + " return True\n", + " elif len(s1) > len(s2):\n", + " return False\n", + " else:\n", + " if s1[-1] == s2[-1]:\n", + " return is_subseq_recursive(s1[:-1], s2[:-1]) or is_subseq_recursive(s1, s2[:-1])\n", + " else:\n", + " return is_subseq_recursive(s1, s2[:-1])" + ] + }, + { + "cell_type": "code", + "execution_count": 29, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "True" + ] + }, + "execution_count": 29, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_subseq_recursive(s1, s2t)" + ] + }, + { + "cell_type": "code", + "execution_count": 28, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "False" + ] + }, + "execution_count": 28, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_subseq_recursive(s1, s2f)" + ] + }, + { + "cell_type": "code", + "execution_count": 30, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def make_string(length, alphabet=None):\n", + " if not alphabet:\n", + " alphabet = 'abcdefgh'\n", + " return ''.join(random.choice(alphabet) for _ in range(length)) " + ] + }, + { + "cell_type": "code", + "execution_count": 31, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def interleave(s1, s2, wander_limit=10, debug=False):\n", + " i1 = i2 = wander = 0\n", + " interleaved = []\n", + " while i1 <= len(s1) and i2 <= len(s2):\n", + " if i1 == len(s1):\n", + " if debug: print(i1, i2, wander, 'remaining s2', s2[i2:])\n", + " interleaved += s2[i2:]\n", + " i2 = len(s2) + 1\n", + " elif i2 == len(s2):\n", + " if debug: print(i1, i2, wander, 'remaining s1', s1[i1:])\n", + " interleaved += s1[i1:]\n", + " i1 = len(s1) + 1\n", + " else:\n", + " if wander == wander_limit:\n", + " step = -1\n", + " elif wander == -wander_limit:\n", + " step = +1\n", + " else:\n", + " step = random.choice([+1, -1])\n", + " if step == +1:\n", + " if debug: print(i1, i2, wander, 'adding', s1[i1])\n", + " interleaved += s1[i1]\n", + " i1 += 1\n", + " wander += 1\n", + " else:\n", + " if debug: print(i1, i2, wander, 'adding', s2[i2])\n", + " interleaved += s2[i2]\n", + " i2 += 1\n", + " wander -= 1\n", + " return ''.join(interleaved)" + ] + }, + { + "cell_type": "code", + "execution_count": 40, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "sl1 = make_string(200)\n", + "sl2 = make_string(200)\n", + "sl3 = make_string(200)\n", + "sl12 = interleave(sl1, sl2)\n", + "sl23 = interleave(sl2, sl3)" + ] + }, + { + "cell_type": "code", + "execution_count": 41, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(True, False)" + ] + }, + "execution_count": 41, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "is_subseq(sl1, sl12), is_subseq(sl1, sl23)" + ] + }, { "cell_type": "code", "execution_count": null, "metadata": {}, "outputs": [], "source": [ - "is_subseq('aaaa', 'aaababb', return_backpointers=True, debug=True)" + "is_subseq_recursive(sl1, sl12), is_subseq_recursive(sl1, sl23)" ] }, { -- 2.34.1