X-Git-Url: https://git.njae.me.uk/?a=blobdiff_plain;f=08-word-chains%2Fexplore-word-chain-4.ipynb;h=2c9faf720f9f7a35be225a7152fce50bb2c7edc8;hb=2f9c7346690126c33c311b31f2c71d6442753a04;hp=c2bca54e673d7b4e8236f540d5057f7dd72bd263;hpb=295420041326bd9e2d894dac370b17ef3ded5852;p=ou-summer-of-code-2017.git diff --git a/08-word-chains/explore-word-chain-4.ipynb b/08-word-chains/explore-word-chain-4.ipynb index c2bca54..2c9faf7 100644 --- a/08-word-chains/explore-word-chain-4.ipynb +++ b/08-word-chains/explore-word-chain-4.ipynb @@ -2,7 +2,7 @@ "cells": [ { "cell_type": "code", - "execution_count": 1, + "execution_count": 4, "metadata": { "collapsed": true }, @@ -16,10 +16,8 @@ }, { "cell_type": "code", - "execution_count": 2, - "metadata": { - "collapsed": false - }, + "execution_count": 5, + "metadata": {}, "outputs": [ { "data": { @@ -27,22 +25,20 @@ "2336" ] }, - "execution_count": 2, + "execution_count": 5, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "words = [w.strip() for w in open('08-words.txt').readlines()]\n", + "words = [w.strip() for w in open('08-offices.txt').readlines()]\n", "len(words)" ] }, { "cell_type": "code", - "execution_count": 3, - "metadata": { - "collapsed": false - }, + "execution_count": 6, + "metadata": {}, "outputs": [ { "data": { @@ -59,7 +55,7 @@ " 'achy']" ] }, - "execution_count": 3, + "execution_count": 6, "metadata": {}, "output_type": "execute_result" } @@ -70,7 +66,7 @@ }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 7, "metadata": { "collapsed": true }, @@ -87,7 +83,7 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 8, "metadata": { "collapsed": true }, @@ -102,7 +98,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 9, "metadata": { "collapsed": true }, @@ -114,10 +110,8 @@ }, { "cell_type": "code", - "execution_count": 7, - "metadata": { - "collapsed": false - }, + "execution_count": 10, + "metadata": {}, "outputs": [ { "data": { @@ -125,7 +119,7 @@ "['able']" ] }, - "execution_count": 7, + "execution_count": 10, "metadata": {}, "output_type": "execute_result" } @@ -136,10 +130,8 @@ }, { "cell_type": "code", - "execution_count": 8, - "metadata": { - "collapsed": false - }, + "execution_count": 11, + "metadata": {}, "outputs": [ { "data": { @@ -147,7 +139,7 @@ "['axle', 'abbe', 'ably']" ] }, - "execution_count": 8, + "execution_count": 11, "metadata": {}, "output_type": "execute_result" } @@ -158,7 +150,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 12, "metadata": { "collapsed": true }, @@ -171,10 +163,8 @@ }, { "cell_type": "code", - "execution_count": 10, - "metadata": { - "collapsed": false - }, + "execution_count": 13, + "metadata": {}, "outputs": [ { "data": { @@ -182,7 +172,7 @@ "0" ] }, - "execution_count": 10, + "execution_count": 13, "metadata": {}, "output_type": "execute_result" } @@ -193,7 +183,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 14, "metadata": { "collapsed": true }, @@ -210,10 +200,8 @@ }, { "cell_type": "code", - "execution_count": 12, - "metadata": { - "collapsed": false - }, + "execution_count": 15, + "metadata": {}, "outputs": [ { "data": { @@ -221,7 +209,7 @@ "[['abbe', 'able']]" ] }, - "execution_count": 12, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -232,10 +220,8 @@ }, { "cell_type": "code", - "execution_count": 13, - "metadata": { - "collapsed": false - }, + "execution_count": 16, + "metadata": {}, "outputs": [ { "data": { @@ -243,7 +229,7 @@ "[['abbe', 'able', 'axle'], ['abbe', 'able', 'ably']]" ] }, - "execution_count": 13, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -254,10 +240,8 @@ }, { "cell_type": "code", - "execution_count": 14, - "metadata": { - "collapsed": false - }, + "execution_count": 17, + "metadata": {}, "outputs": [ { "data": { @@ -265,7 +249,7 @@ "[['abbe', 'able', 'ably', 'ally']]" ] }, - "execution_count": 14, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -276,7 +260,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 18, "metadata": { "collapsed": true }, @@ -302,7 +286,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 19, "metadata": { "collapsed": true }, @@ -330,10 +314,8 @@ }, { "cell_type": "code", - "execution_count": 17, - "metadata": { - "collapsed": false - }, + "execution_count": 20, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -352,7 +334,7 @@ "['abbe', 'able', 'ably', 'ally']" ] }, - "execution_count": 17, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -363,7 +345,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 21, "metadata": { "collapsed": true }, @@ -389,10 +371,8 @@ }, { "cell_type": "code", - "execution_count": 19, - "metadata": { - "collapsed": false - }, + "execution_count": 22, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -411,7 +391,7 @@ "['abbe', 'able', 'ably', 'ally']" ] }, - "execution_count": 19, + "execution_count": 22, "metadata": {}, "output_type": "execute_result" } @@ -422,10 +402,8 @@ }, { "cell_type": "code", - "execution_count": 20, - "metadata": { - "collapsed": false - }, + "execution_count": 23, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -1567,7 +1545,7 @@ "['cart', 'cant', 'cans', 'vans']" ] }, - "execution_count": 20, + "execution_count": 23, "metadata": {}, "output_type": "execute_result" } @@ -1578,10 +1556,8 @@ }, { "cell_type": "code", - "execution_count": 21, - "metadata": { - "collapsed": false - }, + "execution_count": 24, + "metadata": {}, "outputs": [ { "data": { @@ -1589,7 +1565,7 @@ "['cart', 'cant', 'cane', 'vane']" ] }, - "execution_count": 21, + "execution_count": 24, "metadata": {}, "output_type": "execute_result" } @@ -1600,10 +1576,8 @@ }, { "cell_type": "code", - "execution_count": 22, - "metadata": { - "collapsed": false - }, + "execution_count": 25, + "metadata": {}, "outputs": [ { "data": { @@ -2188,7 +2162,7 @@ " 'vane']" ] }, - "execution_count": 22, + "execution_count": 25, "metadata": {}, "output_type": "execute_result" } @@ -2199,7 +2173,7 @@ }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 26, "metadata": { "collapsed": true }, @@ -2227,10 +2201,8 @@ }, { "cell_type": "code", - "execution_count": 24, - "metadata": { - "collapsed": false - }, + "execution_count": 27, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -2248,7 +2220,7 @@ "['cart', 'cant', 'cane', 'vane']" ] }, - "execution_count": 24, + "execution_count": 27, "metadata": {}, "output_type": "execute_result" } @@ -2259,7 +2231,7 @@ }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 28, "metadata": { "collapsed": true }, @@ -2289,10 +2261,8 @@ }, { "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": false - }, + "execution_count": 29, + "metadata": {}, "outputs": [ { "name": "stdout", @@ -2310,7 +2280,7 @@ "['cart', 'cant', 'cane', 'vane']" ] }, - "execution_count": 26, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -2330,10 +2300,8 @@ }, { "cell_type": "code", - "execution_count": 77, - "metadata": { - "collapsed": false - }, + "execution_count": 30, + "metadata": {}, "outputs": [ { "data": { @@ -2341,7 +2309,7 @@ "94" ] }, - "execution_count": 77, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -2367,10 +2335,8 @@ }, { "cell_type": "code", - "execution_count": 78, - "metadata": { - "collapsed": false - }, + "execution_count": 31, + "metadata": {}, "outputs": [ { "data": { @@ -2378,7 +2344,7 @@ "2204" ] }, - "execution_count": 78, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -2389,10 +2355,8 @@ }, { "cell_type": "code", - "execution_count": 79, - "metadata": { - "collapsed": false - }, + "execution_count": 32, + "metadata": {}, "outputs": [ { "data": { @@ -2400,7 +2364,7 @@ "1" ] }, - "execution_count": 79, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -2411,9 +2375,8 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": 33, "metadata": { - "collapsed": false, "scrolled": true }, "outputs": [ @@ -2423,7 +2386,7 @@ "Counter({1: 75, 2: 6, 3: 7, 4: 2, 5: 2, 6: 1, 2204: 1})" ] }, - "execution_count": 80, + "execution_count": 33, "metadata": {}, "output_type": "execute_result" } @@ -2434,10 +2397,8 @@ }, { "cell_type": "code", - "execution_count": 81, - "metadata": { - "collapsed": false - }, + "execution_count": 34, + "metadata": {}, "outputs": [ { "data": { @@ -2445,7 +2406,7 @@ "[5]" ] }, - "execution_count": 81, + "execution_count": 34, "metadata": {}, "output_type": "execute_result" } @@ -2456,10 +2417,8 @@ }, { "cell_type": "code", - "execution_count": 82, - "metadata": { - "collapsed": false - }, + "execution_count": 35, + "metadata": {}, "outputs": [ { "data": { @@ -2467,7 +2426,7 @@ "[{'abbe', 'able', 'ably', 'ally', 'axle'}]" ] }, - "execution_count": 82, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -2478,10 +2437,8 @@ }, { "cell_type": "code", - "execution_count": 83, - "metadata": { - "collapsed": false - }, + "execution_count": 36, + "metadata": {}, "outputs": [ { "data": { @@ -2489,7 +2446,7 @@ "['buns', 'bunk', 'punk']" ] }, - "execution_count": 83, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -2500,7 +2457,7 @@ }, { "cell_type": "code", - "execution_count": 84, + "execution_count": 37, "metadata": { "collapsed": true }, @@ -2515,7 +2472,7 @@ }, { "cell_type": "code", - "execution_count": 85, + "execution_count": 38, "metadata": { "collapsed": true }, @@ -2538,7 +2495,7 @@ }, { "cell_type": "code", - "execution_count": 86, + "execution_count": 39, "metadata": { "collapsed": true }, @@ -2549,35 +2506,33 @@ }, { "cell_type": "code", - "execution_count": 87, - "metadata": { - "collapsed": false - }, + "execution_count": 40, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "['late', 'lats', 'lets', 'leas', 'seas', 'seam', 'swam', 'sway']\n", - "['leap', 'heap', 'hear', 'dear', 'deer']\n", - "['peel', 'peek', 'perk', 'park', 'nark']\n", - "['sing', 'sang', 'sand', 'said', 'sail', 'hail', 'haul']\n", - "['vats', 'bats', 'bets', 'bees', 'been', 'teen', 'then', 'thin', 'this', 'thus', 'thud']\n", - "['sues', 'sees', 'seen', 'sewn', 'hewn']\n", - "['rash', 'bash', 'bast', 'bait', 'bail', 'hail', 'hair', 'heir']\n", - "['apex', 'aped', 'sped', 'seed', 'deed', 'dead', 'deal', 'veal']\n", - "['gulf', 'golf', 'gold', 'bold', 'bond', 'bony', 'tony']\n", - "['snag', 'shag', 'shat', 'seat', 'peat', 'pent', 'pint', 'mint']\n", - "['rife', 'rime', 'rims', 'rums', 'cums', 'cuss']\n", - "['diss', 'kiss', 'kits']\n", - "['gyps', 'gaps', 'gads', 'wads', 'wade', 'wide', 'tide']\n", - "['bilk', 'bill', 'bell', 'tell', 'teal', 'tear', 'tzar']\n", - "['logo', 'loge', 'lode', 'lade', 'jade', 'jape']\n", - "['hunt', 'bunt', 'buns', 'nuns', 'nubs']\n", - "['glow', 'glop', 'plop', 'prop', 'prep', 'peep', 'keep']\n", - "['iamb', 'lamb', 'lams', 'laps', 'lips', 'pips']\n", - "['pain', 'lain', 'laid', 'land', 'lend', 'vend', 'veld']\n", - "['fake', 'bake', 'bare', 'bars', 'ears', 'errs', 'ergs', 'eggs', 'egos']\n" + "['bops', 'bogs', 'begs', 'bees', 'byes', 'eyes', 'eyed']\n", + "['foal', 'foil', 'fail']\n", + "['bush', 'bash', 'base', 'bale', 'ball', 'boll']\n", + "['rift', 'lift', 'life', 'live', 'give', 'gave']\n", + "['club', 'clue', 'flue', 'flee', 'fled', 'pled', 'pied', 'lied', 'lien', 'mien']\n", + "['rung', 'dung', 'ding', 'dins', 'dies', 'lies', 'lien']\n", + "['baas', 'bags', 'bugs', 'bums', 'sums', 'sumo']\n", + "['fits', 'bits', 'bins', 'bind']\n", + "['lids', 'bids', 'bias', 'boas', 'boat', 'boot', 'soot', 'snot', 'snob']\n", + "['cake', 'came', 'cams', 'caws', 'cows', 'tows']\n", + "['tort', 'toot', 'trot', 'troy', 'tray', 'tram', 'cram']\n", + "['sews', 'pews', 'pees', 'peed', 'pied']\n", + "['lack', 'hack', 'hawk', 'haws', 'hows', 'tows']\n", + "['dots', 'dons', 'dens', 'dent', 'pent', 'pest', 'peso']\n", + "['ekes', 'eyes', 'byes', 'bees', 'beet', 'bent', 'lent', 'lept']\n", + "['ruin', 'rain', 'gain', 'grin', 'grid', 'arid', 'acid', 'aced', 'iced']\n", + "['sing', 'sins', 'bins', 'bias', 'bras', 'bray', 'tray', 'trap']\n", + "['lira', 'lire', 'wire', 'wise', 'wish']\n", + "['gash', 'cash', 'case', 'cape', 'rape']\n", + "['crop', 'coop', 'coot', 'loot', 'loft']\n" ] } ], @@ -2589,10 +2544,8 @@ }, { "cell_type": "code", - "execution_count": 38, - "metadata": { - "collapsed": false - }, + "execution_count": 41, + "metadata": {}, "outputs": [ { "data": { @@ -2600,7 +2553,7 @@ "['cops', 'coos', 'coon', 'coin', 'chin', 'thin', 'this', 'thus', 'thug']" ] }, - "execution_count": 38, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -2611,10 +2564,8 @@ }, { "cell_type": "code", - "execution_count": 39, - "metadata": { - "collapsed": false - }, + "execution_count": 42, + "metadata": {}, "outputs": [ { "data": { @@ -2622,7 +2573,7 @@ "[2204]" ] }, - "execution_count": 39, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -2633,91 +2584,75 @@ }, { "cell_type": "code", - "execution_count": 40, - "metadata": { - "collapsed": false - }, + "execution_count": 73, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['hate', 'have', 'hove', 'love']" + "[2204]" ] }, - "execution_count": 40, + "execution_count": 73, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "astar_search('hate', 'love')" + "[len(r) for r in reachables if 'stay' in r ]" ] }, { "cell_type": "code", - "execution_count": 41, - "metadata": { - "collapsed": false - }, + "execution_count": 43, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['wars', 'ware', 'wave', 'wove', 'love']" + "['hate', 'have', 'hove', 'love']" ] }, - "execution_count": 41, + "execution_count": 43, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "astar_search('wars', 'love')" + "astar_search('hate', 'love')" ] }, { "cell_type": "code", - "execution_count": 61, - "metadata": { - "collapsed": false - }, + "execution_count": 44, + "metadata": {}, "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n", - "Wall time: 210 µs\n" - ] - }, { "data": { "text/plain": [ - "5" + "['wars', 'ware', 'wave', 'wove', 'love']" ] }, - "execution_count": 61, + "execution_count": 44, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "%time len(astar_search('wars', 'love'))" + "astar_search('wars', 'love')" ] }, { "cell_type": "code", - "execution_count": 62, - "metadata": { - "collapsed": false - }, + "execution_count": 45, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n", - "Wall time: 252 µs\n" + "Wall time: 850 µs\n" ] }, { @@ -2726,111 +2661,93 @@ "5" ] }, - "execution_count": 62, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "%time len(astar_search_closed('wars', 'love'))" + "%time len(astar_search('wars', 'love'))" ] }, { "cell_type": "code", - "execution_count": 63, - "metadata": { - "collapsed": false - }, + "execution_count": 46, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 24 ms, sys: 0 ns, total: 24 ms\n", - "Wall time: 24.2 ms\n" + "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n", + "Wall time: 353 µs\n" ] }, { "data": { "text/plain": [ - "404" + "5" ] }, - "execution_count": 63, + "execution_count": 46, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "%time len(dfs_search('wars', 'love'))" + "%time len(astar_search_closed('wars', 'love'))" ] }, { "cell_type": "code", - "execution_count": 64, - "metadata": { - "collapsed": false - }, + "execution_count": 47, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 5min 20s, sys: 76 ms, total: 5min 20s\n", - "Wall time: 5min 20s\n" + "CPU times: user 76 ms, sys: 0 ns, total: 76 ms\n", + "Wall time: 75.1 ms\n" ] }, { "data": { "text/plain": [ - "5" + "404" ] }, - "execution_count": 64, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "%time len(bfs_search('wars', 'love'))" + "%time len(dfs_search('wars', 'love'))" ] }, { "cell_type": "code", - "execution_count": 65, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "name": "stdout", - "output_type": "stream", - "text": [ - "CPU times: user 1.44 s, sys: 0 ns, total: 1.44 s\n", - "Wall time: 1.43 s\n" - ] - }, - { - "data": { - "text/plain": [ - "5" - ] - }, - "execution_count": 65, - "metadata": {}, - "output_type": "execute_result" - } - ], + "execution_count": null, + "metadata": {}, + "outputs": [], + "source": [ + "# %time len(bfs_search('wars', 'love'))" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": {}, + "outputs": [], "source": [ "%time len(bfs_search_closed('wars', 'love'))" ] }, { "cell_type": "code", - "execution_count": 42, - "metadata": { - "collapsed": false - }, + "execution_count": 50, + "metadata": {}, "outputs": [ { "data": { @@ -2838,7 +2755,7 @@ "['fear', 'feat', 'fest', 'lest', 'lost', 'lose', 'love']" ] }, - "execution_count": 42, + "execution_count": 50, "metadata": {}, "output_type": "execute_result" } @@ -2849,10 +2766,8 @@ }, { "cell_type": "code", - "execution_count": 43, - "metadata": { - "collapsed": false - }, + "execution_count": 51, + "metadata": {}, "outputs": [ { "data": { @@ -2860,7 +2775,7 @@ "['fail', 'fall', 'pall', 'pals', 'pass']" ] }, - "execution_count": 43, + "execution_count": 51, "metadata": {}, "output_type": "execute_result" } @@ -2871,10 +2786,8 @@ }, { "cell_type": "code", - "execution_count": 44, - "metadata": { - "collapsed": false - }, + "execution_count": 52, + "metadata": {}, "outputs": [ { "data": { @@ -2882,7 +2795,7 @@ "['star', 'soar', 'boar', 'boor', 'boon', 'born']" ] }, - "execution_count": 44, + "execution_count": 52, "metadata": {}, "output_type": "execute_result" } @@ -2893,10 +2806,8 @@ }, { "cell_type": "code", - "execution_count": 45, - "metadata": { - "collapsed": false - }, + "execution_count": 53, + "metadata": {}, "outputs": [ { "data": { @@ -2914,7 +2825,7 @@ " 'pass']" ] }, - "execution_count": 45, + "execution_count": 53, "metadata": {}, "output_type": "execute_result" } @@ -2925,10 +2836,8 @@ }, { "cell_type": "code", - "execution_count": 46, - "metadata": { - "collapsed": false - }, + "execution_count": 54, + "metadata": {}, "outputs": [ { "data": { @@ -2949,7 +2858,7 @@ " 'past']" ] }, - "execution_count": 46, + "execution_count": 54, "metadata": {}, "output_type": "execute_result" } @@ -2960,10 +2869,8 @@ }, { "cell_type": "code", - "execution_count": 47, - "metadata": { - "collapsed": false - }, + "execution_count": 55, + "metadata": {}, "outputs": [ { "data": { @@ -2971,7 +2878,7 @@ "[1]" ] }, - "execution_count": 47, + "execution_count": 55, "metadata": {}, "output_type": "execute_result" } @@ -2982,10 +2889,8 @@ }, { "cell_type": "code", - "execution_count": 48, - "metadata": { - "collapsed": false - }, + "execution_count": 56, + "metadata": {}, "outputs": [ { "data": { @@ -2993,7 +2898,7 @@ "[2204]" ] }, - "execution_count": 48, + "execution_count": 56, "metadata": {}, "output_type": "execute_result" } @@ -3004,16 +2909,14 @@ }, { "cell_type": "code", - "execution_count": 49, - "metadata": { - "collapsed": false - }, + "execution_count": 57, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 7.9 s per loop\n" + "1 loop, best of 3: 12.3 s per loop\n" ] } ], @@ -3024,16 +2927,14 @@ }, { "cell_type": "code", - "execution_count": 50, - "metadata": { - "collapsed": false - }, + "execution_count": 58, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "10 loops, best of 3: 141 ms per loop\n" + "1 loop, best of 3: 200 ms per loop\n" ] } ], @@ -3044,10 +2945,8 @@ }, { "cell_type": "code", - "execution_count": 51, - "metadata": { - "collapsed": false - }, + "execution_count": 59, + "metadata": {}, "outputs": [ { "data": { @@ -3064,7 +2963,7 @@ " 'exit']" ] }, - "execution_count": 51, + "execution_count": 59, "metadata": {}, "output_type": "execute_result" } @@ -3075,31 +2974,29 @@ }, { "cell_type": "code", - "execution_count": 88, - "metadata": { - "collapsed": false - }, + "execution_count": 60, + "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "{2: [['heel', 'keel'], ['wane', 'wave'], ['cell', 'sell'], ['cons', 'cobs']],\n", - " 3: [['hank', 'haws'], ['bars', 'bets'], ['rats', 'paws'], ['lock', 'hack']],\n", - " 4: [['rule', 'sore'], ['wavy', 'rape'], ['peas', 'ping'], ['bond', 'toll']],\n", - " 5: [['cope', 'yowl'], ['lose', 'loci'], ['rump', 'dash'], ['four', 'dyes']],\n", - " 6: [['boon', 'sell'], ['lots', 'pomp'], ['cola', 'turn'], ['boos', 'laid']],\n", - " 7: [['eave', 'inns'], ['meek', 'mere'], ['keys', 'wily'], ['slam', 'yore']],\n", - " 8: [['hack', 'flip'], ['crag', 'huge'], ['flux', 'gill'], ['play', 'busy']],\n", - " 9: [['lacy', 'whey'], ['wren', 'rook'], ['lire', 'drip'], ['grab', 'lame']],\n", - " 10: [['over', 'turn'], ['worn', 'anew'], ['stow', 'elks'], ['ergo', 'rich']],\n", - " 11: [['bask', 'idea'], ['gabs', 'thud'], ['idea', 'clod'], ['mark', 'ibis']],\n", - " 12: [['umps', 'torn'], ['futz', 'shun'], ['abut', 'face'], ['slug', 'open']],\n", - " 13: [['umps', 'skin'], ['chum', 'rats'], ['fury', 'chum'], ['omen', 'zany']],\n", - " 14: [['chug', 'gaff'], ['atom', 'fizz']],\n", - " 15: [['chug', 'oxen']]}" + "{2: [['exes', 'exec'], ['rush', 'tush'], ['wile', 'wily'], ['shoo', 'shot']],\n", + " 3: [['bins', 'fink'], ['waft', 'wand'], ['heel', 'jell'], ['tent', 'west']],\n", + " 4: [['yore', 'polo'], ['hale', 'case'], ['horn', 'look'], ['tang', 'nuns']],\n", + " 5: [['crab', 'baas'], ['yens', 'dead'], ['work', 'paps'], ['tune', 'zaps']],\n", + " 6: [['mist', 'sold'], ['bats', 'sort'], ['leek', 'mads'], ['loop', 'dome']],\n", + " 7: [['rime', 'hoof'], ['grim', 'reed'], ['lies', 'eave'], ['ties', 'whiz']],\n", + " 8: [['drag', 'lied'], ['ages', 'yawl'], ['earl', 'deal'], ['gins', 'scab']],\n", + " 9: [['tyre', 'swum'], ['dike', 'flux'], ['hour', 'laze'], ['trek', 'bait']],\n", + " 10: [['ides', 'rasp'], ['egos', 'racy'], ['shim', 'ills'], ['bark', 'arty']],\n", + " 11: [['ergo', 'apex'], ['whey', 'owns'], ['anew', 'rapt'], ['thug', 'bate']],\n", + " 12: [['ream', 'imps'], ['meat', 'umps'], ['daze', 'knee'], ['clay', 'over']],\n", + " 13: [['oxen', 'blab'], ['blip', 'omen'], ['twig', 'ibis'], ['chew', 'umps']],\n", + " 14: [['amen', 'blip'], ['umps', 'futz'], ['amps', 'glib'], ['chum', 'whys']],\n", + " 15: [['thug', 'ibis']]}" ] }, - "execution_count": 88, + "execution_count": 60, "metadata": {}, "output_type": "execute_result" } @@ -3123,7 +3020,7 @@ }, { "cell_type": "code", - "execution_count": 91, + "execution_count": 64, "metadata": { "collapsed": true }, @@ -3148,38 +3045,14 @@ }, { "cell_type": "code", - "execution_count": 54, - "metadata": { - "collapsed": false - }, - "outputs": [ - { - "data": { - "text/plain": [ - "[('amen', 'doff', 15), ('chug', 'jinn', 14), ('amen', 'flog', 14)]" - ] - }, - "execution_count": 54, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "[(s[0], s[-1], len(s)) for s in solutions if len(s) >= 14]" - ] - }, - { - "cell_type": "code", - "execution_count": 55, - "metadata": { - "collapsed": false - }, + "execution_count": 66, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 360 ms per loop\n" + "1 loop, best of 3: 487 ms per loop\n" ] } ], @@ -3190,17 +3063,15 @@ }, { "cell_type": "code", - "execution_count": 56, - "metadata": { - "collapsed": false - }, + "execution_count": 67, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 384 ms, sys: 0 ns, total: 384 ms\n", - "Wall time: 385 ms\n" + "CPU times: user 768 ms, sys: 0 ns, total: 768 ms\n", + "Wall time: 768 ms\n" ] }, { @@ -3209,7 +3080,7 @@ "14" ] }, - "execution_count": 56, + "execution_count": 67, "metadata": {}, "output_type": "execute_result" } @@ -3220,17 +3091,15 @@ }, { "cell_type": "code", - "execution_count": 57, - "metadata": { - "collapsed": false - }, + "execution_count": 68, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 124 ms, sys: 0 ns, total: 124 ms\n", - "Wall time: 121 ms\n" + "CPU times: user 176 ms, sys: 0 ns, total: 176 ms\n", + "Wall time: 176 ms\n" ] }, { @@ -3239,7 +3108,7 @@ "15" ] }, - "execution_count": 57, + "execution_count": 68, "metadata": {}, "output_type": "execute_result" } @@ -3250,17 +3119,15 @@ }, { "cell_type": "code", - "execution_count": 58, - "metadata": { - "collapsed": false - }, + "execution_count": 69, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 32 ms, sys: 0 ns, total: 32 ms\n", - "Wall time: 32.4 ms\n" + "CPU times: user 72 ms, sys: 0 ns, total: 72 ms\n", + "Wall time: 70.6 ms\n" ] }, { @@ -3269,7 +3136,7 @@ "14" ] }, - "execution_count": 58, + "execution_count": 69, "metadata": {}, "output_type": "execute_result" } @@ -3280,17 +3147,15 @@ }, { "cell_type": "code", - "execution_count": 59, - "metadata": { - "collapsed": false - }, + "execution_count": 70, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 16 ms, sys: 0 ns, total: 16 ms\n", - "Wall time: 17.1 ms\n" + "CPU times: user 32 ms, sys: 0 ns, total: 32 ms\n", + "Wall time: 35.7 ms\n" ] }, { @@ -3299,7 +3164,7 @@ "14" ] }, - "execution_count": 59, + "execution_count": 70, "metadata": {}, "output_type": "execute_result" } @@ -3310,17 +3175,15 @@ }, { "cell_type": "code", - "execution_count": 73, - "metadata": { - "collapsed": false - }, + "execution_count": 71, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 268 ms, sys: 4 ms, total: 272 ms\n", - "Wall time: 272 ms\n" + "CPU times: user 376 ms, sys: 4 ms, total: 380 ms\n", + "Wall time: 382 ms\n" ] }, { @@ -3329,7 +3192,7 @@ "14" ] }, - "execution_count": 73, + "execution_count": 71, "metadata": {}, "output_type": "execute_result" } @@ -3340,17 +3203,15 @@ }, { "cell_type": "code", - "execution_count": 74, - "metadata": { - "collapsed": false - }, + "execution_count": 72, + "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 64 ms, sys: 0 ns, total: 64 ms\n", - "Wall time: 64.1 ms\n" + "CPU times: user 72 ms, sys: 4 ms, total: 76 ms\n", + "Wall time: 76.9 ms\n" ] }, { @@ -3359,7 +3220,7 @@ "14" ] }, - "execution_count": 74, + "execution_count": 72, "metadata": {}, "output_type": "execute_result" } @@ -3394,7 +3255,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2" + "version": "3.5.2+" } }, "nbformat": 4,