Fixed a bug in search, added other word files
[ou-summer-of-code-2017.git] / 08-word-chains / explore-word-chain-4.ipynb
index d16966dde3f6f16f187a052b47daf216403462c0..5449951bf02476cc6fbebe11cb07a34d507e683f 100644 (file)
@@ -16,7 +16,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 3,
+   "execution_count": 2,
    "metadata": {},
    "outputs": [
     {
@@ -25,7 +25,7 @@
        "2336"
       ]
      },
-     "execution_count": 3,
+     "execution_count": 2,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -37,7 +37,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 4,
+   "execution_count": 3,
    "metadata": {},
    "outputs": [
     {
@@ -55,7 +55,7 @@
        " 'achy']"
       ]
      },
-     "execution_count": 4,
+     "execution_count": 3,
      "metadata": {},
      "output_type": "execute_result"
     }
@@ -66,7 +66,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 5,
+   "execution_count": 4,
    "metadata": {
     "collapsed": true
    },
@@ -83,7 +83,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
+   "execution_count": 5,
    "metadata": {
     "collapsed": true
    },
@@ -98,7 +98,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 6,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 7,
    "metadata": {},
    "outputs": [
     {
        "['able']"
       ]
      },
-     "execution_count": 8,
+     "execution_count": 7,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 8,
    "metadata": {},
    "outputs": [
     {
        "['axle', 'abbe', 'ably']"
       ]
      },
-     "execution_count": 9,
+     "execution_count": 8,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 9,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 10,
    "metadata": {},
    "outputs": [
     {
        "0"
       ]
      },
-     "execution_count": 11,
+     "execution_count": 10,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 11,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
+   "execution_count": 12,
    "metadata": {},
    "outputs": [
     {
        "[['abbe', 'able']]"
       ]
      },
-     "execution_count": 13,
+     "execution_count": 12,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": 13,
    "metadata": {},
    "outputs": [
     {
        "[['abbe', 'able', 'axle'], ['abbe', 'able', 'ably']]"
       ]
      },
-     "execution_count": 14,
+     "execution_count": 13,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 15,
+   "execution_count": 14,
    "metadata": {},
    "outputs": [
     {
        "[['abbe', 'able', 'ably', 'ally']]"
       ]
      },
-     "execution_count": 15,
+     "execution_count": 14,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
+   "execution_count": 15,
    "metadata": {
     "collapsed": true
    },
     "        else:\n",
     "            successors = extend(current)\n",
     "            agenda = agenda[1:] + successors\n",
-    "    if agenda:\n",
+    "    if finished:\n",
     "        return current\n",
     "    else:\n",
     "        return None        "
   },
   {
    "cell_type": "code",
-   "execution_count": 17,
+   "execution_count": 16,
    "metadata": {
     "collapsed": true
    },
     "            closed.add(current[-1])\n",
     "            successors = extend(current, closed)\n",
     "            agenda = agenda[1:] + successors\n",
-    "    if agenda:\n",
+    "    if finished:\n",
     "        return current\n",
     "    else:\n",
     "        return None        "
   },
   {
    "cell_type": "code",
-   "execution_count": 18,
+   "execution_count": 17,
    "metadata": {},
    "outputs": [
     {
        "['abbe', 'able', 'ably', 'ally']"
       ]
      },
-     "execution_count": 18,
+     "execution_count": 17,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 19,
+   "execution_count": 18,
    "metadata": {
     "collapsed": true
    },
     "        else:\n",
     "            successors = extend(current)\n",
     "            agenda = successors + agenda[1:]\n",
-    "    if agenda:\n",
+    "    if finished:\n",
     "        return current\n",
     "    else:\n",
     "        return None        "
   },
   {
    "cell_type": "code",
-   "execution_count": 20,
+   "execution_count": 19,
    "metadata": {},
    "outputs": [
     {
        "['abbe', 'able', 'ably', 'ally']"
       ]
      },
-     "execution_count": 20,
+     "execution_count": 19,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 21,
+   "execution_count": 20,
    "metadata": {},
    "outputs": [
     {
       "['cart', 'mart', 'mare', 'mire']\n",
       "['cart', 'mart', 'mare', 'more']\n",
       "['cart', 'mart', 'mare', 'mace']\n",
-      "['cart', 'mart', 'mare', 'made']\n",
+      "['cart', 'mart', 'mare', 'made']\n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
       "['cart', 'mart', 'mare', 'make']\n",
       "['cart', 'mart', 'mare', 'male']\n",
       "['cart', 'mart', 'mare', 'mane']\n",
       "['cart', 'part', 'park', 'pars']\n",
       "['cart', 'part', 'pars', 'bars']\n",
       "['cart', 'part', 'pars', 'cars']\n",
-      "['cart', 'part', 'pars', 'ears']\n"
-     ]
-    },
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
+      "['cart', 'part', 'pars', 'ears']\n",
       "['cart', 'part', 'pars', 'jars']\n",
       "['cart', 'part', 'pars', 'mars']\n",
       "['cart', 'part', 'pars', 'oars']\n",
       "['cart', 'cant', 'rant', 'raft']\n",
       "['cart', 'cant', 'rant', 'rapt']\n",
       "['cart', 'cant', 'rant', 'rang']\n",
-      "['cart', 'cant', 'rant', 'rank']\n",
+      "['cart', 'cant', 'rant', 'rank']\n"
+     ]
+    },
+    {
+     "name": "stdout",
+     "output_type": "stream",
+     "text": [
       "['cart', 'cant', 'want', 'pant']\n",
       "['cart', 'cant', 'want', 'rant']\n",
       "['cart', 'cant', 'want', 'went']\n",
        "['cart', 'cant', 'cans', 'vans']"
       ]
      },
-     "execution_count": 21,
+     "execution_count": 20,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 22,
+   "execution_count": 21,
    "metadata": {},
    "outputs": [
     {
        "['cart', 'cant', 'cane', 'vane']"
       ]
      },
-     "execution_count": 22,
+     "execution_count": 21,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 23,
+   "execution_count": 22,
    "metadata": {},
    "outputs": [
     {
        " 'vane']"
       ]
      },
-     "execution_count": 23,
+     "execution_count": 22,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 24,
+   "execution_count": 23,
    "metadata": {
     "collapsed": true
    },
     "            successors = extend(current)\n",
     "            for s in successors:\n",
     "                heapq.heappush(agenda, (len(current) + distance(s[-1], goal) - 1, s))\n",
-    "    if agenda:\n",
+    "    if finished:\n",
     "        return current\n",
     "    else:\n",
     "        return None        "
   },
   {
    "cell_type": "code",
-   "execution_count": 25,
+   "execution_count": 24,
    "metadata": {},
    "outputs": [
     {
        "['cart', 'cant', 'cane', 'vane']"
       ]
      },
-     "execution_count": 25,
+     "execution_count": 24,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 26,
+   "execution_count": 81,
    "metadata": {
     "collapsed": true
    },
     "            successors = extend(current, closed)\n",
     "            for s in successors:\n",
     "                heapq.heappush(agenda, (len(current) + distance(s[-1], goal) - 1, s))\n",
-    "    if agenda:\n",
+    "    if finished:\n",
     "        return current\n",
     "    else:\n",
     "        return None        "
   },
   {
    "cell_type": "code",
-   "execution_count": 27,
+   "execution_count": 26,
    "metadata": {},
    "outputs": [
     {
        "['cart', 'cant', 'cane', 'vane']"
       ]
      },
-     "execution_count": 27,
+     "execution_count": 26,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 28,
+   "execution_count": 27,
    "metadata": {},
    "outputs": [
     {
        "94"
       ]
      },
-     "execution_count": 28,
+     "execution_count": 27,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 29,
+   "execution_count": 28,
    "metadata": {},
    "outputs": [
     {
        "2204"
       ]
      },
-     "execution_count": 29,
+     "execution_count": 28,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 30,
+   "execution_count": 29,
    "metadata": {},
    "outputs": [
     {
        "1"
       ]
      },
-     "execution_count": 30,
+     "execution_count": 29,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 31,
+   "execution_count": 30,
    "metadata": {
     "scrolled": true
    },
        "Counter({1: 75, 2: 6, 3: 7, 4: 2, 5: 2, 6: 1, 2204: 1})"
       ]
      },
-     "execution_count": 31,
+     "execution_count": 30,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 32,
+   "execution_count": 31,
    "metadata": {},
    "outputs": [
     {
        "[5]"
       ]
      },
-     "execution_count": 32,
+     "execution_count": 31,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 33,
+   "execution_count": 32,
    "metadata": {},
    "outputs": [
     {
        "[{'abbe', 'able', 'ably', 'ally', 'axle'}]"
       ]
      },
-     "execution_count": 33,
+     "execution_count": 32,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 34,
+   "execution_count": 76,
+   "metadata": {
+    "scrolled": true
+   },
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "[{'demo', 'memo'},\n",
+       " {'thou', 'thru'},\n",
+       " {'crud', 'crux'},\n",
+       " {'bevy', 'levy'},\n",
+       " {'ogle', 'ogre'},\n",
+       " {'idol', 'idyl'},\n",
+       " {'also', 'alto', 'auto'},\n",
+       " {'used', 'user', 'uses'},\n",
+       " {'idle', 'idly', 'isle'},\n",
+       " {'eddy', 'edge', 'edgy'},\n",
+       " {'opal', 'oral', 'oval'},\n",
+       " {'icon', 'ikon', 'iron'},\n",
+       " {'afar', 'agar', 'ajar'},\n",
+       " {'each', 'etch', 'inch', 'itch'},\n",
+       " {'high', 'nigh', 'sigh', 'sign'},\n",
+       " {'abbe', 'able', 'ably', 'ally', 'axle'},\n",
+       " {'info', 'into', 'onto', 'undo', 'unto'},\n",
+       " {'ache', 'achy', 'acme', 'acne', 'acre', 'ashy'}]"
+      ]
+     },
+     "execution_count": 76,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "sorted((r for r in reachables if len(r) > 1 if len(r) < 10), key=len)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 80,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'adze; agog; ague; ahoy; alga; ammo; amok; anal; ankh; apse; aqua; aura; avow; awol; bozo; ebbs; echo; ecru; emus; ends; envy; epee; epic; espy; euro; evil; exam; expo; guru; hymn; ibex; iffy; imam; iota; isms; judo; kiwi; liar; luau; lynx; mayo; meow; myna; nova; obey; oboe; odor; ohms; okra; oleo; once; onyx; orgy; ovum; rely; rhea; semi; sexy; stye; sync; taxi; tofu; tuft; tutu; twos; ugly; ulna; upon; urge; uric; urns; void; wiki; yeti; zebu'"
+      ]
+     },
+     "execution_count": 80,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "'; '.join(sorted(list(r)[0] for r in reachables if len(r) == 1))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 33,
    "metadata": {},
    "outputs": [
     {
        "['buns', 'bunk', 'punk']"
       ]
      },
-     "execution_count": 34,
+     "execution_count": 33,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 35,
+   "execution_count": 34,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 36,
+   "execution_count": 35,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 37,
+   "execution_count": 36,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 38,
+   "execution_count": 37,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "['drip', 'grip', 'grit', 'gait', 'bait', 'bast', 'base', 'babe']\n",
-      "['cape', 'cope', 'dope', 'dole', 'dolt']\n",
-      "['laze', 'late', 'lats', 'pats']\n",
-      "['zest', 'best', 'bust', 'buss', 'buds', 'suds']\n",
-      "['gape', 'gaps', 'paps', 'peps', 'pees', 'peel']\n",
-      "['yogi', 'yoga', 'toga', 'togs', 'tors', 'tore']\n",
-      "['flux', 'flex', 'fled', 'feed', 'fees', 'foes', 'toes', 'toys']\n",
-      "['bike', 'bake', 'base', 'bast', 'best', 'beet', 'feet']\n",
-      "['tows', 'lows', 'laws', 'lams', 'lame']\n",
-      "['jock', 'pock', 'pork', 'pore', 'pure']\n",
-      "['tabu', 'tabs', 'cabs', 'caws', 'cows', 'cowl', 'coil', 'coif']\n",
-      "['reek', 'week', 'wees', 'weds', 'wads', 'wadi']\n",
-      "['gene', 'gone', 'gong', 'song']\n",
-      "['mete', 'mate', 'bate', 'bats', 'baas', 'bras', 'brag', 'crag', 'cram']\n",
-      "['gnus', 'anus', 'ants', 'acts', 'aces', 'ayes', 'byes', 'bees', 'been', 'teen']\n",
-      "['comb', 'come', 'core', 'corn', 'torn', 'tern']\n",
-      "['ouch', 'much', 'muck', 'buck', 'beck', 'beak', 'beat', 'teat', 'that', 'than', 'khan']\n",
-      "['rids', 'reds', 'reps', 'peps', 'peas', 'peal', 'deal']\n",
-      "['calm', 'balm', 'bald', 'bold', 'bolt', 'bout', 'tout']\n",
-      "['toed', 'toad', 'goad', 'grad', 'gray', 'grey', 'grew']\n"
+      "['army', 'arms', 'aims', 'aids', 'bids', 'bias', 'boas', 'boat', 'goat', 'gnat', 'gnaw']\n",
+      "['hoes', 'toes', 'toms', 'tams', 'tame']\n",
+      "['vane', 'vine', 'wine', 'wire', 'wiry', 'airy', 'awry', 'away']\n",
+      "['mate', 'late', 'lane', 'land', 'laid', 'lain']\n",
+      "['heal', 'head', 'bead', 'bend', 'bond', 'bone']\n",
+      "['dune', 'dine', 'dins', 'dies', 'died', 'tied']\n",
+      "['ions', 'dons', 'does', 'hoes', 'hoed', 'heed']\n",
+      "['puck', 'pick', 'pink', 'mink', 'mine']\n",
+      "['need', 'deed', 'died', 'dies', 'dims', 'dams', 'days', 'drys']\n",
+      "['pore', 'core', 'code', 'cods', 'cuds']\n",
+      "['mote', 'mite', 'mile', 'wile', 'wise']\n",
+      "['wait', 'wail', 'mail', 'mall', 'male']\n",
+      "['wail', 'bail', 'ball', 'boll', 'bolt', 'boot', 'boom', 'zoom']\n",
+      "['beat', 'beet', 'bees', 'bets', 'bats', 'cats']\n",
+      "['tore', 'tire', 'tile', 'vile', 'vise', 'visa']\n",
+      "['went', 'pent', 'pant']\n",
+      "['lick', 'sick', 'sics', 'sips', 'sops', 'oops']\n",
+      "['womb', 'tomb', 'toms', 'toes', 'does', 'dyes', 'ayes', 'apes', 'aped']\n",
+      "['cure', 'sure']\n",
+      "['cute', 'cuts', 'guts', 'guys', 'gays']\n"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 39,
+   "execution_count": 38,
    "metadata": {},
    "outputs": [
     {
        "['cops', 'coos', 'coon', 'coin', 'chin', 'thin', 'this', 'thus', 'thug']"
       ]
      },
-     "execution_count": 39,
+     "execution_count": 38,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 40,
+   "execution_count": 39,
    "metadata": {},
    "outputs": [
     {
        "[2204]"
       ]
      },
-     "execution_count": 40,
+     "execution_count": 39,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 41,
+   "execution_count": 40,
    "metadata": {},
    "outputs": [
     {
        "[2204]"
       ]
      },
-     "execution_count": 41,
+     "execution_count": 40,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 42,
+   "execution_count": 41,
    "metadata": {},
    "outputs": [
     {
        "['hate', 'have', 'hove', 'love']"
       ]
      },
-     "execution_count": 42,
+     "execution_count": 41,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 43,
+   "execution_count": 42,
    "metadata": {},
    "outputs": [
     {
        "['wars', 'ware', 'wave', 'wove', 'love']"
       ]
      },
-     "execution_count": 43,
+     "execution_count": 42,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 44,
+   "execution_count": 43,
    "metadata": {},
    "outputs": [
     {
      "output_type": "stream",
      "text": [
       "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n",
-      "Wall time: 212 Âµs\n"
+      "Wall time: 185 Âµs\n"
      ]
     },
     {
        "5"
       ]
      },
-     "execution_count": 44,
+     "execution_count": 43,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 45,
+   "execution_count": 44,
    "metadata": {},
    "outputs": [
     {
      "output_type": "stream",
      "text": [
       "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n",
-      "Wall time: 203 Âµs\n"
+      "Wall time: 398 Âµs\n"
      ]
     },
     {
        "5"
       ]
      },
-     "execution_count": 45,
+     "execution_count": 44,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 46,
+   "execution_count": 45,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "CPU times: user 24 ms, sys: 0 ns, total: 24 ms\n",
-      "Wall time: 23.2 ms\n"
+      "CPU times: user 32 ms, sys: 0 ns, total: 32 ms\n",
+      "Wall time: 32.3 ms\n"
      ]
     },
     {
        "404"
       ]
      },
-     "execution_count": 46,
+     "execution_count": 45,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 47,
+   "execution_count": 46,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 48,
+   "execution_count": 47,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "CPU times: user 332 ms, sys: 0 ns, total: 332 ms\n",
-      "Wall time: 331 ms\n"
+      "CPU times: user 212 ms, sys: 0 ns, total: 212 ms\n",
+      "Wall time: 213 ms\n"
      ]
     },
     {
        "5"
       ]
      },
-     "execution_count": 48,
+     "execution_count": 47,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 49,
+   "execution_count": 48,
    "metadata": {},
    "outputs": [
     {
        "['fear', 'feat', 'fest', 'lest', 'lost', 'lose', 'love']"
       ]
      },
-     "execution_count": 49,
+     "execution_count": 48,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 50,
+   "execution_count": 49,
    "metadata": {},
    "outputs": [
     {
        "['fail', 'fall', 'pall', 'pals', 'pass']"
       ]
      },
-     "execution_count": 50,
+     "execution_count": 49,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 51,
+   "execution_count": 50,
    "metadata": {},
    "outputs": [
     {
        "['star', 'soar', 'boar', 'boor', 'boon', 'born']"
       ]
      },
-     "execution_count": 51,
+     "execution_count": 50,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 52,
+   "execution_count": 51,
    "metadata": {},
    "outputs": [
     {
        " 'pass']"
       ]
      },
-     "execution_count": 52,
+     "execution_count": 51,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 53,
+   "execution_count": 52,
    "metadata": {},
    "outputs": [
     {
        " 'past']"
       ]
      },
-     "execution_count": 53,
+     "execution_count": 52,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 54,
+   "execution_count": 53,
    "metadata": {},
    "outputs": [
     {
        "[1]"
       ]
      },
-     "execution_count": 54,
+     "execution_count": 53,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 55,
+   "execution_count": 54,
    "metadata": {},
    "outputs": [
     {
        "[2204]"
       ]
      },
-     "execution_count": 55,
+     "execution_count": 54,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 56,
+   "execution_count": 55,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "1 loop, best of 3: 8.08 s per loop\n"
+      "1 loop, best of 3: 8.21 s per loop\n"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 57,
+   "execution_count": 56,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "10 loops, best of 3: 131 ms per loop\n"
+      "10 loops, best of 3: 145 ms per loop\n"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 58,
+   "execution_count": 57,
    "metadata": {},
    "outputs": [
     {
        " 'exit']"
       ]
      },
-     "execution_count": 58,
+     "execution_count": 57,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 68,
-   "metadata": {},
+   "execution_count": 58,
+   "metadata": {
+    "collapsed": true
+   },
    "outputs": [],
    "source": [
     "# solutions = {}\n",
   },
   {
    "cell_type": "code",
-   "execution_count": 60,
+   "execution_count": 59,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 61,
+   "execution_count": 60,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "1 loop, best of 3: 352 ms per loop\n"
+      "1 loop, best of 3: 334 ms per loop\n"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 62,
+   "execution_count": 61,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "CPU times: user 452 ms, sys: 0 ns, total: 452 ms\n",
-      "Wall time: 449 ms\n"
+      "CPU times: user 344 ms, sys: 0 ns, total: 344 ms\n",
+      "Wall time: 342 ms\n"
      ]
     },
     {
        "14"
       ]
      },
-     "execution_count": 62,
+     "execution_count": 61,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 63,
+   "execution_count": 62,
    "metadata": {},
    "outputs": [
     {
      "output_type": "stream",
      "text": [
       "CPU times: user 92 ms, sys: 0 ns, total: 92 ms\n",
-      "Wall time: 91.5 ms\n"
+      "Wall time: 93.7 ms\n"
      ]
     },
     {
        "15"
       ]
      },
-     "execution_count": 63,
+     "execution_count": 62,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 64,
+   "execution_count": 63,
    "metadata": {},
    "outputs": [
     {
      "output_type": "stream",
      "text": [
       "CPU times: user 32 ms, sys: 0 ns, total: 32 ms\n",
-      "Wall time: 31.4 ms\n"
+      "Wall time: 32.8 ms\n"
      ]
     },
     {
        "14"
       ]
      },
-     "execution_count": 64,
+     "execution_count": 63,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 65,
+   "execution_count": 64,
    "metadata": {},
    "outputs": [
     {
      "output_type": "stream",
      "text": [
       "CPU times: user 16 ms, sys: 0 ns, total: 16 ms\n",
-      "Wall time: 17.2 ms\n"
+      "Wall time: 16.4 ms\n"
      ]
     },
     {
        "14"
       ]
      },
-     "execution_count": 65,
+     "execution_count": 64,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 66,
+   "execution_count": 65,
    "metadata": {},
    "outputs": [
     {
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "CPU times: user 296 ms, sys: 4 ms, total: 300 ms\n",
-      "Wall time: 299 ms\n"
+      "CPU times: user 256 ms, sys: 0 ns, total: 256 ms\n",
+      "Wall time: 253 ms\n"
      ]
     },
     {
        "14"
       ]
      },
-     "execution_count": 66,
+     "execution_count": 65,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 67,
+   "execution_count": 66,
    "metadata": {},
    "outputs": [
     {
      "output_type": "stream",
      "text": [
       "CPU times: user 36 ms, sys: 0 ns, total: 36 ms\n",
-      "Wall time: 34.5 ms\n"
+      "Wall time: 34.2 ms\n"
      ]
     },
     {
        "14"
       ]
      },
-     "execution_count": 67,
+     "execution_count": 66,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 90,
+   "execution_count": 67,
    "metadata": {},
    "outputs": [
     {
        "2"
       ]
      },
-     "execution_count": 90,
+     "execution_count": 67,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 91,
+   "execution_count": 68,
    "metadata": {},
    "outputs": [
     {
        "['gush', 'hush', 'lush', 'mush', 'push', 'tush', 'bosh']"
       ]
      },
-     "execution_count": 91,
+     "execution_count": 68,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 89,
+   "execution_count": 69,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "('gibe', 2)"
+       "('nose', 2)"
       ]
      },
-     "execution_count": 89,
+     "execution_count": 69,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 88,
+   "execution_count": 70,
    "metadata": {},
    "outputs": [
     {
      "data": {
       "text/plain": [
-       "'memo'"
+       "'grew'"
       ]
      },
-     "execution_count": 88,
+     "execution_count": 70,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 76,
+   "execution_count": 71,
    "metadata": {},
    "outputs": [
     {
        "{'bash', 'rush'}"
       ]
      },
-     "execution_count": 76,
+     "execution_count": 71,
      "metadata": {},
      "output_type": "execute_result"
     }