From 2f750972c876ebbb88e1af96be1ce74b4d3558f8 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Wed, 28 Jun 2017 14:49:55 +0100 Subject: [PATCH] Renumbered day 9 to day 8 --- .../08-words.txt | 0 .../build-word-lists.ipynb | 0 .../explore-word-chain-4.ipynb | 225 ++++++++++++------ .../word-chain-solution.ipynb | 204 ++++++++++------ 4 files changed, 283 insertions(+), 146 deletions(-) rename 09-word-chains/09-words.txt => 08-word-chains/08-words.txt (100%) rename {09-word-chains => 08-word-chains}/build-word-lists.ipynb (100%) rename {09-word-chains => 08-word-chains}/explore-word-chain-4.ipynb (97%) rename {09-word-chains => 08-word-chains}/word-chain-solution.ipynb (61%) diff --git a/09-word-chains/09-words.txt b/08-word-chains/08-words.txt similarity index 100% rename from 09-word-chains/09-words.txt rename to 08-word-chains/08-words.txt diff --git a/09-word-chains/build-word-lists.ipynb b/08-word-chains/build-word-lists.ipynb similarity index 100% rename from 09-word-chains/build-word-lists.ipynb rename to 08-word-chains/build-word-lists.ipynb diff --git a/09-word-chains/explore-word-chain-4.ipynb b/08-word-chains/explore-word-chain-4.ipynb similarity index 97% rename from 09-word-chains/explore-word-chain-4.ipynb rename to 08-word-chains/explore-word-chain-4.ipynb index 5f624fd..c2bca54 100644 --- a/09-word-chains/explore-word-chain-4.ipynb +++ b/08-word-chains/explore-word-chain-4.ipynb @@ -17,7 +17,9 @@ { "cell_type": "code", "execution_count": 2, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -31,14 +33,16 @@ } ], "source": [ - "words = [w.strip() for w in open('words4.txt').readlines()]\n", + "words = [w.strip() for w in open('08-words.txt').readlines()]\n", "len(words)" ] }, { "cell_type": "code", "execution_count": 3, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -111,7 +115,9 @@ { "cell_type": "code", "execution_count": 7, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -131,7 +137,9 @@ { "cell_type": "code", "execution_count": 8, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -164,7 +172,9 @@ { "cell_type": "code", "execution_count": 10, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -201,7 +211,9 @@ { "cell_type": "code", "execution_count": 12, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -221,7 +233,9 @@ { "cell_type": "code", "execution_count": 13, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -241,7 +255,9 @@ { "cell_type": "code", "execution_count": 14, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -315,7 +331,9 @@ { "cell_type": "code", "execution_count": 17, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -372,7 +390,9 @@ { "cell_type": "code", "execution_count": 19, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -403,7 +423,9 @@ { "cell_type": "code", "execution_count": 20, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -857,13 +879,7 @@ "['cart', 'mart', 'tart', 'wart']\n", "['cart', 'mart', 'tart', 'tort']\n", "['cart', 'mart', 'tart', 'tact']\n", - "['cart', 'mart', 'tart', 'taut']\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ + "['cart', 'mart', 'tart', 'taut']\n", "['cart', 'mart', 'tart', 'tare']\n", "['cart', 'mart', 'tart', 'taro']\n", "['cart', 'mart', 'tart', 'tarp']\n", @@ -1348,13 +1364,7 @@ "['cart', 'wart', 'ware', 'wire']\n", "['cart', 'wart', 'ware', 'wore']\n", "['cart', 'wart', 'ware', 'wade']\n", - "['cart', 'wart', 'ware', 'wage']\n" - ] - }, - { - "name": "stdout", - "output_type": "stream", - "text": [ + "['cart', 'wart', 'ware', 'wage']\n", "['cart', 'wart', 'ware', 'wake']\n", "['cart', 'wart', 'ware', 'wale']\n", "['cart', 'wart', 'ware', 'wane']\n", @@ -1569,7 +1579,9 @@ { "cell_type": "code", "execution_count": 21, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -1589,7 +1601,9 @@ { "cell_type": "code", "execution_count": 22, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2214,7 +2228,9 @@ { "cell_type": "code", "execution_count": 24, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2274,7 +2290,9 @@ { "cell_type": "code", "execution_count": 26, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2313,7 +2331,9 @@ { "cell_type": "code", "execution_count": 77, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2348,7 +2368,9 @@ { "cell_type": "code", "execution_count": 78, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2368,7 +2390,9 @@ { "cell_type": "code", "execution_count": 79, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2389,6 +2413,7 @@ "cell_type": "code", "execution_count": 80, "metadata": { + "collapsed": false, "scrolled": true }, "outputs": [ @@ -2410,7 +2435,9 @@ { "cell_type": "code", "execution_count": 81, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2430,7 +2457,9 @@ { "cell_type": "code", "execution_count": 82, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2450,7 +2479,9 @@ { "cell_type": "code", "execution_count": 83, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2519,7 +2550,9 @@ { "cell_type": "code", "execution_count": 87, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2557,7 +2590,9 @@ { "cell_type": "code", "execution_count": 38, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2577,7 +2612,9 @@ { "cell_type": "code", "execution_count": 39, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2597,7 +2634,9 @@ { "cell_type": "code", "execution_count": 40, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2617,7 +2656,9 @@ { "cell_type": "code", "execution_count": 41, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2637,7 +2678,9 @@ { "cell_type": "code", "execution_count": 61, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2665,7 +2708,9 @@ { "cell_type": "code", "execution_count": 62, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2693,7 +2738,9 @@ { "cell_type": "code", "execution_count": 63, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2721,7 +2768,9 @@ { "cell_type": "code", "execution_count": 64, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2749,7 +2798,9 @@ { "cell_type": "code", "execution_count": 65, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2777,7 +2828,9 @@ { "cell_type": "code", "execution_count": 42, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2797,7 +2850,9 @@ { "cell_type": "code", "execution_count": 43, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2817,7 +2872,9 @@ { "cell_type": "code", "execution_count": 44, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2837,7 +2894,9 @@ { "cell_type": "code", "execution_count": 45, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2867,7 +2926,9 @@ { "cell_type": "code", "execution_count": 46, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2900,7 +2961,9 @@ { "cell_type": "code", "execution_count": 47, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2920,7 +2983,9 @@ { "cell_type": "code", "execution_count": 48, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -2940,7 +3005,9 @@ { "cell_type": "code", "execution_count": 49, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2958,7 +3025,9 @@ { "cell_type": "code", "execution_count": 50, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -2976,7 +3045,9 @@ { "cell_type": "code", "execution_count": 51, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -3005,7 +3076,9 @@ { "cell_type": "code", "execution_count": 88, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -3051,7 +3124,9 @@ { "cell_type": "code", "execution_count": 91, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "solutions = {2: [['heel', 'keel'], ['wane', 'wave'], ['cell', 'sell'], ['cons', 'cobs']],\n", @@ -3074,7 +3149,9 @@ { "cell_type": "code", "execution_count": 54, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -3094,7 +3171,9 @@ { "cell_type": "code", "execution_count": 55, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -3112,7 +3191,9 @@ { "cell_type": "code", "execution_count": 56, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -3140,7 +3221,9 @@ { "cell_type": "code", "execution_count": 57, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -3168,7 +3251,9 @@ { "cell_type": "code", "execution_count": 58, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -3196,7 +3281,9 @@ { "cell_type": "code", "execution_count": 59, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -3224,7 +3311,9 @@ { "cell_type": "code", "execution_count": 73, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -3252,7 +3341,9 @@ { "cell_type": "code", "execution_count": 74, - "metadata": {}, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", @@ -3303,7 +3394,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2+" + "version": "3.5.2" } }, "nbformat": 4, diff --git a/09-word-chains/word-chain-solution.ipynb b/08-word-chains/word-chain-solution.ipynb similarity index 61% rename from 09-word-chains/word-chain-solution.ipynb rename to 08-word-chains/word-chain-solution.ipynb index 7346623..038b3c4 100644 --- a/09-word-chains/word-chain-solution.ipynb +++ b/08-word-chains/word-chain-solution.ipynb @@ -27,7 +27,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 1, "metadata": { "collapsed": true }, @@ -39,8 +39,10 @@ }, { "cell_type": "code", - "execution_count": 4, - "metadata": {}, + "execution_count": 2, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -48,19 +50,19 @@ "2336" ] }, - "execution_count": 4, + "execution_count": 2, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "words = [w.strip() for w in open('09-words.txt').readlines()]\n", + "words = [w.strip() for w in open('08-words.txt').readlines()]\n", "len(words)" ] }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 3, "metadata": { "collapsed": true }, @@ -75,7 +77,7 @@ }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 4, "metadata": { "collapsed": true }, @@ -87,7 +89,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 5, "metadata": { "collapsed": true }, @@ -100,7 +102,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 6, "metadata": { "collapsed": true }, @@ -113,7 +115,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 7, "metadata": { "collapsed": true }, @@ -130,7 +132,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 8, "metadata": { "collapsed": true }, @@ -144,7 +146,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 9, "metadata": { "collapsed": true }, @@ -170,7 +172,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 10, "metadata": { "collapsed": true }, @@ -198,7 +200,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 11, "metadata": { "collapsed": true }, @@ -224,7 +226,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 12, "metadata": { "collapsed": true }, @@ -252,7 +254,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 13, "metadata": { "collapsed": true }, @@ -281,7 +283,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 14, "metadata": { "collapsed": true }, @@ -311,8 +313,10 @@ }, { "cell_type": "code", - "execution_count": 17, - "metadata": {}, + "execution_count": 15, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -320,7 +324,7 @@ "['vice', 'dice', 'dire', 'dare', 'ware', 'wars']" ] }, - "execution_count": 17, + "execution_count": 15, "metadata": {}, "output_type": "execute_result" } @@ -331,8 +335,10 @@ }, { "cell_type": "code", - "execution_count": 18, - "metadata": {}, + "execution_count": 16, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -340,7 +346,7 @@ "['vice', 'dice', 'dire', 'dare', 'ware', 'wars']" ] }, - "execution_count": 18, + "execution_count": 16, "metadata": {}, "output_type": "execute_result" } @@ -351,8 +357,10 @@ }, { "cell_type": "code", - "execution_count": 19, - "metadata": {}, + "execution_count": 17, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -360,7 +368,7 @@ "6" ] }, - "execution_count": 19, + "execution_count": 17, "metadata": {}, "output_type": "execute_result" } @@ -371,18 +379,22 @@ }, { "cell_type": "code", - "execution_count": 20, - "metadata": {}, + "execution_count": 18, + "metadata": { + "collapsed": false + }, "outputs": [ { - "data": { - "text/plain": [ - "6" - ] - }, - "execution_count": 20, - "metadata": {}, - "output_type": "execute_result" + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mbfs_search\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'vice'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m'wars'\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m\u001b[0m in \u001b[0;36mbfs_search\u001b[0;34m(start, goal, debug)\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0msuccessors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mextend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcurrent\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 12\u001b[0;31m \u001b[0magenda\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0magenda\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0msuccessors\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 13\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0magenda\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mcurrent\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyboardInterrupt\u001b[0m: " + ] } ], "source": [ @@ -391,8 +403,10 @@ }, { "cell_type": "code", - "execution_count": 21, - "metadata": {}, + "execution_count": 19, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -400,7 +414,7 @@ "6" ] }, - "execution_count": 21, + "execution_count": 19, "metadata": {}, "output_type": "execute_result" } @@ -411,8 +425,10 @@ }, { "cell_type": "code", - "execution_count": 22, - "metadata": {}, + "execution_count": 20, + "metadata": { + "collapsed": false + }, "outputs": [ { "data": { @@ -420,7 +436,7 @@ "793" ] }, - "execution_count": 22, + "execution_count": 20, "metadata": {}, "output_type": "execute_result" } @@ -431,14 +447,16 @@ }, { "cell_type": "code", - "execution_count": 23, - "metadata": {}, + "execution_count": 21, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "10000 loops, best of 3: 157 µs per loop\n" + "1000 loops, best of 3: 225 µs per loop\n" ] } ], @@ -449,14 +467,16 @@ }, { "cell_type": "code", - "execution_count": 24, - "metadata": {}, + "execution_count": 22, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "100 loops, best of 3: 15.8 ms per loop\n" + "10 loops, best of 3: 22.1 ms per loop\n" ] } ], @@ -467,14 +487,16 @@ }, { "cell_type": "code", - "execution_count": 25, - "metadata": {}, + "execution_count": 23, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "10000 loops, best of 3: 170 µs per loop\n" + "1000 loops, best of 3: 280 µs per loop\n" ] } ], @@ -485,14 +507,27 @@ }, { "cell_type": "code", - "execution_count": 26, - "metadata": {}, + "execution_count": 24, + "metadata": { + "collapsed": false + }, "outputs": [ { - "name": "stdout", - "output_type": "stream", - "text": [ - "1 loop, best of 3: 1min 42s per loop\n" + "ename": "KeyboardInterrupt", + "evalue": "", + "output_type": "error", + "traceback": [ + "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m", + "\u001b[0;31mKeyboardInterrupt\u001b[0m Traceback (most recent call last)", + "\u001b[0;32m\u001b[0m in \u001b[0;36m\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mget_ipython\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mrun_cell_magic\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m'timeit'\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m''\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m\"bfs_search('vice', 'wars')\"\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m", + "\u001b[0;32m/usr/local/lib/python3.5/dist-packages/IPython/core/interactiveshell.py\u001b[0m in \u001b[0;36mrun_cell_magic\u001b[0;34m(self, magic_name, line, cell)\u001b[0m\n\u001b[1;32m 2113\u001b[0m \u001b[0mmagic_arg_s\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mvar_expand\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mline\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mstack_depth\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2114\u001b[0m \u001b[0;32mwith\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mbuiltin_trap\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 2115\u001b[0;31m \u001b[0mresult\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfn\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mmagic_arg_s\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mcell\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 2116\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mresult\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 2117\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36mtimeit\u001b[0;34m(self, line, cell)\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.5/dist-packages/IPython/core/magic.py\u001b[0m in \u001b[0;36m\u001b[0;34m(f, *a, **k)\u001b[0m\n\u001b[1;32m 186\u001b[0m \u001b[0;31m# but it's overkill for just that one bit of state.\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 187\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mmagic_deco\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 188\u001b[0;31m \u001b[0mcall\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;32mlambda\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m:\u001b[0m \u001b[0mf\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m*\u001b[0m\u001b[0ma\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;34m**\u001b[0m\u001b[0mk\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 189\u001b[0m \u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 190\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mcallable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0marg\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.5/dist-packages/IPython/core/magics/execution.py\u001b[0m in \u001b[0;36mtimeit\u001b[0;34m(self, line, cell)\u001b[0m\n\u001b[1;32m 1042\u001b[0m \u001b[0mnumber\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;36m1\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1043\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0m_\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m10\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m-> 1044\u001b[0;31m \u001b[0mtime_number\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mtimer\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtimeit\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mnumber\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 1045\u001b[0m \u001b[0mworst_tuning\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mmax\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mworst_tuning\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mtime_number\u001b[0m \u001b[0;34m/\u001b[0m \u001b[0mnumber\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 1046\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mtime_number\u001b[0m \u001b[0;34m>=\u001b[0m \u001b[0;36m0.2\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m/usr/local/lib/python3.5/dist-packages/IPython/core/magics/execution.py\u001b[0m in \u001b[0;36mtimeit\u001b[0;34m(self, number)\u001b[0m\n\u001b[1;32m 137\u001b[0m \u001b[0mgc\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mdisable\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 138\u001b[0m \u001b[0;32mtry\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m--> 139\u001b[0;31m \u001b[0mtiming\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0minner\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mit\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mself\u001b[0m\u001b[0;34m.\u001b[0m\u001b[0mtimer\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 140\u001b[0m \u001b[0;32mfinally\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 141\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0mgcold\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36minner\u001b[0;34m(_it, _timer)\u001b[0m\n", + "\u001b[0;32m\u001b[0m in \u001b[0;36mbfs_search\u001b[0;34m(start, goal, debug)\u001b[0m\n\u001b[1;32m 10\u001b[0m \u001b[0;32melse\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 11\u001b[0m \u001b[0msuccessors\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mextend\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mcurrent\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 12\u001b[0;31m \u001b[0magenda\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0magenda\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m1\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0msuccessors\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m 13\u001b[0m \u001b[0;32mif\u001b[0m \u001b[0magenda\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m 14\u001b[0m \u001b[0;32mreturn\u001b[0m \u001b[0mcurrent\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n", + "\u001b[0;31mKeyboardInterrupt\u001b[0m: " ] } ], @@ -503,14 +538,16 @@ }, { "cell_type": "code", - "execution_count": 27, - "metadata": {}, + "execution_count": 25, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 557 ms per loop\n" + "1 loop, best of 3: 1.12 s per loop\n" ] } ], @@ -521,14 +558,16 @@ }, { "cell_type": "code", - "execution_count": 28, - "metadata": {}, + "execution_count": 26, + "metadata": { + "collapsed": false + }, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "10 loops, best of 3: 87.9 ms per loop\n" + "10 loops, best of 3: 127 ms per loop\n" ] } ], @@ -555,7 +594,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 27, "metadata": { "collapsed": true }, @@ -577,8 +616,9 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 28, "metadata": { + "collapsed": false, "scrolled": true }, "outputs": [ @@ -589,7 +629,7 @@ " '`bash`, `cash`, `dash`, `gash`, `hash`, `lash`, `mash`, `rasp`, `rush`, `sash`, `wash`')" ] }, - "execution_count": 30, + "execution_count": 28, "metadata": {}, "output_type": "execute_result" } @@ -600,8 +640,9 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 29, "metadata": { + "collapsed": false, "scrolled": true }, "outputs": [ @@ -612,7 +653,7 @@ " '`base`, `bash`, `bask`, `bass`, `bast`, `bath`, `bosh`, `bush`, `case`, `cash`, `cask`, `cast`, `dash`, `dish`, `gash`, `gasp`, `gosh`, `gush`, `hash`, `hasp`, `hath`, `hush`, `lash`, `lass`, `last`, `lath`, `lush`, `mash`, `mask`, `mass`, `mast`, `math`, `mesh`, `mush`, `push`, `ramp`, `rasp`, `ruse`, `rush`, `rusk`, `rust`, `sash`, `sass`, `tush`, `wash`, `wasp`, `wish`')" ] }, - "execution_count": 31, + "execution_count": 29, "metadata": {}, "output_type": "execute_result" } @@ -623,8 +664,9 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 30, "metadata": { + "collapsed": false, "scrolled": true }, "outputs": [ @@ -634,7 +676,7 @@ "180" ] }, - "execution_count": 32, + "execution_count": 30, "metadata": {}, "output_type": "execute_result" } @@ -645,8 +687,9 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 31, "metadata": { + "collapsed": false, "scrolled": true }, "outputs": [ @@ -656,7 +699,7 @@ "2195" ] }, - "execution_count": 33, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } @@ -667,8 +710,9 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 32, "metadata": { + "collapsed": false, "scrolled": true }, "outputs": [ @@ -678,7 +722,7 @@ "2192" ] }, - "execution_count": 34, + "execution_count": 32, "metadata": {}, "output_type": "execute_result" } @@ -689,8 +733,9 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 33, "metadata": { + "collapsed": false, "scrolled": true }, "outputs": [ @@ -698,7 +743,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "100 loops, best of 3: 6.01 ms per loop\n" + "100 loops, best of 3: 9.26 ms per loop\n" ] } ], @@ -709,8 +754,9 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 34, "metadata": { + "collapsed": false, "scrolled": true }, "outputs": [ @@ -718,7 +764,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "100 loops, best of 3: 2.92 ms per loop\n" + "100 loops, best of 3: 3.64 ms per loop\n" ] } ], @@ -753,7 +799,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2+" + "version": "3.5.2" } }, "nbformat": 4, -- 2.34.1