From: Neil Smith Date: Thu, 7 Sep 2017 08:39:26 +0000 (+0100) Subject: Added notes for day 8 X-Git-Url: https://git.njae.me.uk/?a=commitdiff_plain;h=9ede4bf9d49e541ea5a98d2549800d4667839707;p=ou-summer-of-code-2017.git Added notes for day 8 --- diff --git a/08-word-chains/explore-word-chain-4.ipynb b/08-word-chains/explore-word-chain-4.ipynb index 5449951..d18dc5f 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": 30, "metadata": { "collapsed": true }, @@ -16,7 +16,7 @@ }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 31, "metadata": {}, "outputs": [ { @@ -25,48 +25,19 @@ "2336" ] }, - "execution_count": 2, + "execution_count": 31, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "words = [w.strip() for w in open('08-rooms.txt').readlines()]\n", + "words = frozenset(w.strip() for w in open('08-rooms.txt').readlines())\n", "len(words)" ] }, { "cell_type": "code", - "execution_count": 3, - "metadata": {}, - "outputs": [ - { - "data": { - "text/plain": [ - "['abbe',\n", - " 'abed',\n", - " 'abet',\n", - " 'able',\n", - " 'ably',\n", - " 'abut',\n", - " 'aced',\n", - " 'aces',\n", - " 'ache',\n", - " 'achy']" - ] - }, - "execution_count": 3, - "metadata": {}, - "output_type": "execute_result" - } - ], - "source": [ - "words[:10]" - ] - }, - { - "cell_type": "code", - "execution_count": 4, + "execution_count": 32, "metadata": { "collapsed": true }, @@ -83,43 +54,41 @@ }, { "cell_type": "code", - "execution_count": 5, + "execution_count": 33, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def adjacents(word):\n", - " return [word[0:i] + l + word[i+1:]\n", + " return frozenset(word[0:i] + l + word[i+1:]\n", " for i in range(len(word))\n", " for l in string.ascii_lowercase\n", - " if l != word[i]]" + " if l != word[i])" ] }, { "cell_type": "code", - "execution_count": 6, - "metadata": { - "collapsed": true - }, + "execution_count": 34, + "metadata": {}, "outputs": [], "source": [ - "neighbours = {w: [n for n in adjacents(w) if n in words]\n", + "neighbours = {w: frozenset(n for n in adjacents(w) if n in words)\n", " for w in words}" ] }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 35, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['able']" + "frozenset({'able'})" ] }, - "execution_count": 7, + "execution_count": 35, "metadata": {}, "output_type": "execute_result" } @@ -130,16 +99,16 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 36, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['axle', 'abbe', 'ably']" + "frozenset({'abbe', 'ably', 'axle'})" ] }, - "execution_count": 8, + "execution_count": 36, "metadata": {}, "output_type": "execute_result" } @@ -150,7 +119,7 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 37, "metadata": { "collapsed": true }, @@ -163,7 +132,7 @@ }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 38, "metadata": {}, "outputs": [ { @@ -172,7 +141,7 @@ "0" ] }, - "execution_count": 10, + "execution_count": 38, "metadata": {}, "output_type": "execute_result" } @@ -183,7 +152,7 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 39, "metadata": { "collapsed": true }, @@ -200,7 +169,7 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 40, "metadata": {}, "outputs": [ { @@ -209,7 +178,7 @@ "[['abbe', 'able']]" ] }, - "execution_count": 12, + "execution_count": 40, "metadata": {}, "output_type": "execute_result" } @@ -220,16 +189,16 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 41, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[['abbe', 'able', 'axle'], ['abbe', 'able', 'ably']]" + "[['abbe', 'able', 'ably'], ['abbe', 'able', 'axle']]" ] }, - "execution_count": 13, + "execution_count": 41, "metadata": {}, "output_type": "execute_result" } @@ -240,7 +209,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 42, "metadata": {}, "outputs": [ { @@ -249,7 +218,7 @@ "[['abbe', 'able', 'ably', 'ally']]" ] }, - "execution_count": 14, + "execution_count": 42, "metadata": {}, "output_type": "execute_result" } @@ -260,7 +229,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 119, "metadata": { "collapsed": true }, @@ -272,7 +241,7 @@ " while not finished and agenda:\n", " current = agenda[0]\n", " if debug:\n", - " print(current)\n", + " print(current, agenda)\n", " if current[-1] == goal:\n", " finished = True\n", " else:\n", @@ -286,7 +255,7 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 44, "metadata": { "collapsed": true }, @@ -314,7 +283,7 @@ }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 45, "metadata": {}, "outputs": [ { @@ -323,8 +292,8 @@ "text": [ "['abbe']\n", "['abbe', 'able']\n", - "['abbe', 'able', 'axle']\n", "['abbe', 'able', 'ably']\n", + "['abbe', 'able', 'axle']\n", "['abbe', 'able', 'ably', 'ally']\n" ] }, @@ -334,7 +303,7 @@ "['abbe', 'able', 'ably', 'ally']" ] }, - "execution_count": 17, + "execution_count": 45, "metadata": {}, "output_type": "execute_result" } @@ -345,7 +314,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 121, "metadata": { "collapsed": true }, @@ -357,7 +326,7 @@ " while not finished and agenda:\n", " current = agenda[0]\n", " if debug:\n", - " print(current)\n", + " print(agenda)\n", " if current[-1] == goal:\n", " finished = True\n", " else:\n", @@ -371,7 +340,7 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 47, "metadata": {}, "outputs": [ { @@ -380,7 +349,6 @@ "text": [ "['abbe']\n", "['abbe', 'able']\n", - "['abbe', 'able', 'axle']\n", "['abbe', 'able', 'ably']\n", "['abbe', 'able', 'ably', 'ally']\n" ] @@ -391,7 +359,7 @@ "['abbe', 'able', 'ably', 'ally']" ] }, - "execution_count": 19, + "execution_count": 47, "metadata": {}, "output_type": "execute_result" } @@ -402,7 +370,7 @@ }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 48, "metadata": {}, "outputs": [ { @@ -410,1154 +378,668 @@ "output_type": "stream", "text": [ "['cart']\n", - "['cart', 'dart']\n", + "['cart', 'cast']\n", "['cart', 'hart']\n", + "['cart', 'cars']\n", "['cart', 'mart']\n", - "['cart', 'part']\n", - "['cart', 'tart']\n", "['cart', 'wart']\n", - "['cart', 'curt']\n", - "['cart', 'cant']\n", - "['cart', 'cast']\n", "['cart', 'card']\n", + "['cart', 'curt']\n", + "['cart', 'tart']\n", "['cart', 'care']\n", + "['cart', 'cant']\n", + "['cart', 'dart']\n", + "['cart', 'part']\n", "['cart', 'carp']\n", - "['cart', 'cars']\n", - "['cart', 'dart', 'hart']\n", - "['cart', 'dart', 'mart']\n", - "['cart', 'dart', 'part']\n", - "['cart', 'dart', 'tart']\n", - "['cart', 'dart', 'wart']\n", - "['cart', 'dart', 'dirt']\n", - "['cart', 'dart', 'daft']\n", - "['cart', 'dart', 'dare']\n", - "['cart', 'dart', 'dark']\n", - "['cart', 'dart', 'darn']\n", - "['cart', 'hart', 'dart']\n", - "['cart', 'hart', 'mart']\n", - "['cart', 'hart', 'part']\n", - "['cart', 'hart', 'tart']\n", - "['cart', 'hart', 'wart']\n", + "['cart', 'cast', 'last']\n", + "['cart', 'cast', 'bast']\n", + "['cart', 'cast', 'cant']\n", + "['cart', 'cast', 'past']\n", + "['cart', 'cast', 'mast']\n", + "['cart', 'cast', 'fast']\n", + "['cart', 'cast', 'case']\n", + "['cart', 'cast', 'east']\n", + "['cart', 'cast', 'cyst']\n", + "['cart', 'cast', 'cash']\n", + "['cart', 'cast', 'cask']\n", + "['cart', 'cast', 'vast']\n", + "['cart', 'cast', 'cost']\n", + "['cart', 'hart', 'hard']\n", + "['cart', 'hart', 'harm']\n", + "['cart', 'hart', 'hare']\n", "['cart', 'hart', 'hurt']\n", "['cart', 'hart', 'haft']\n", "['cart', 'hart', 'halt']\n", - "['cart', 'hart', 'hard']\n", - "['cart', 'hart', 'hare']\n", + "['cart', 'hart', 'mart']\n", + "['cart', 'hart', 'wart']\n", "['cart', 'hart', 'hark']\n", - "['cart', 'hart', 'harm']\n", + "['cart', 'hart', 'tart']\n", "['cart', 'hart', 'harp']\n", - "['cart', 'mart', 'dart']\n", - "['cart', 'mart', 'hart']\n", - "['cart', 'mart', 'part']\n", - "['cart', 'mart', 'tart']\n", - "['cart', 'mart', 'wart']\n", + "['cart', 'hart', 'dart']\n", + "['cart', 'hart', 'part']\n", + "['cart', 'cars', 'bars']\n", + "['cart', 'cars', 'ears']\n", + "['cart', 'cars', 'caps']\n", + "['cart', 'cars', 'wars']\n", + "['cart', 'cars', 'cabs']\n", + "['cart', 'cars', 'oars']\n", + "['cart', 'cars', 'pars']\n", + "['cart', 'cars', 'tars']\n", + "['cart', 'cars', 'card']\n", + "['cart', 'cars', 'cams']\n", + "['cart', 'cars', 'caws']\n", + "['cart', 'cars', 'cats']\n", + "['cart', 'cars', 'cads']\n", + "['cart', 'cars', 'care']\n", + "['cart', 'cars', 'cans']\n", + "['cart', 'cars', 'mars']\n", + "['cart', 'cars', 'curs']\n", + "['cart', 'cars', 'carp']\n", + "['cart', 'cars', 'jars']\n", + "['cart', 'mart', 'mare']\n", "['cart', 'mart', 'malt']\n", + "['cart', 'mart', 'hart']\n", + "['cart', 'mart', 'dart']\n", "['cart', 'mart', 'mast']\n", + "['cart', 'mart', 'wart']\n", + "['cart', 'mart', 'tart']\n", "['cart', 'mart', 'matt']\n", - "['cart', 'mart', 'mare']\n", - "['cart', 'mart', 'mark']\n", "['cart', 'mart', 'mars']\n", - "['cart', 'part', 'dart']\n", - "['cart', 'part', 'hart']\n", - "['cart', 'part', 'mart']\n", - "['cart', 'part', 'tart']\n", - "['cart', 'part', 'wart']\n", - "['cart', 'part', 'pert']\n", - "['cart', 'part', 'port']\n", - "['cart', 'part', 'pact']\n", - "['cart', 'part', 'pant']\n", - "['cart', 'part', 'past']\n", - "['cart', 'part', 'pare']\n", - "['cart', 'part', 'park']\n", - "['cart', 'part', 'pars']\n", - "['cart', 'tart', 'dart']\n", - "['cart', 'tart', 'hart']\n", - "['cart', 'tart', 'mart']\n", - "['cart', 'tart', 'part']\n", - "['cart', 'tart', 'wart']\n", - "['cart', 'tart', 'tort']\n", - "['cart', 'tart', 'tact']\n", - "['cart', 'tart', 'taut']\n", - "['cart', 'tart', 'tare']\n", - "['cart', 'tart', 'taro']\n", - "['cart', 'tart', 'tarp']\n", - "['cart', 'tart', 'tars']\n", - "['cart', 'wart', 'dart']\n", + "['cart', 'mart', 'part']\n", + "['cart', 'mart', 'mark']\n", + "['cart', 'wart', 'wary']\n", "['cart', 'wart', 'hart']\n", + "['cart', 'wart', 'warn']\n", + "['cart', 'wart', 'warm']\n", + "['cart', 'wart', 'warp']\n", + "['cart', 'wart', 'wars']\n", "['cart', 'wart', 'mart']\n", - "['cart', 'wart', 'part']\n", + "['cart', 'wart', 'watt']\n", + "['cart', 'wart', 'want']\n", + "['cart', 'wart', 'ware']\n", "['cart', 'wart', 'tart']\n", "['cart', 'wart', 'waft']\n", + "['cart', 'wart', 'dart']\n", + "['cart', 'wart', 'part']\n", "['cart', 'wart', 'wait']\n", - "['cart', 'wart', 'want']\n", - "['cart', 'wart', 'watt']\n", "['cart', 'wart', 'ward']\n", - "['cart', 'wart', 'ware']\n", - "['cart', 'wart', 'warm']\n", - "['cart', 'wart', 'warn']\n", - "['cart', 'wart', 'warp']\n", - "['cart', 'wart', 'wars']\n", - "['cart', 'wart', 'wary']\n", - "['cart', 'curt', 'hurt']\n", - "['cart', 'curt', 'cult']\n", - "['cart', 'curt', 'curb']\n", - "['cart', 'curt', 'curd']\n", - "['cart', 'curt', 'cure']\n", - "['cart', 'curt', 'curl']\n", - "['cart', 'curt', 'curs']\n", - "['cart', 'cant', 'pant']\n", - "['cart', 'cant', 'rant']\n", - "['cart', 'cant', 'want']\n", - "['cart', 'cant', 'cent']\n", - "['cart', 'cant', 'cast']\n", - "['cart', 'cant', 'cane']\n", - "['cart', 'cant', 'cans']\n", - "['cart', 'cast', 'bast']\n", - "['cart', 'cast', 'east']\n", - "['cart', 'cast', 'fast']\n", - "['cart', 'cast', 'last']\n", - "['cart', 'cast', 'mast']\n", - "['cart', 'cast', 'past']\n", - "['cart', 'cast', 'vast']\n", - "['cart', 'cast', 'cost']\n", - "['cart', 'cast', 'cyst']\n", - "['cart', 'cast', 'cant']\n", - "['cart', 'cast', 'case']\n", - "['cart', 'cast', 'cash']\n", - "['cart', 'cast', 'cask']\n", - "['cart', 'card', 'bard']\n", "['cart', 'card', 'hard']\n", + "['cart', 'card', 'bard']\n", "['cart', 'card', 'lard']\n", - "['cart', 'card', 'ward']\n", - "['cart', 'card', 'yard']\n", - "['cart', 'card', 'cord']\n", + "['cart', 'card', 'cars']\n", "['cart', 'card', 'curd']\n", - "['cart', 'card', 'care']\n", "['cart', 'card', 'carp']\n", - "['cart', 'card', 'cars']\n", - "['cart', 'care', 'bare']\n", - "['cart', 'care', 'dare']\n", - "['cart', 'care', 'fare']\n", + "['cart', 'card', 'care']\n", + "['cart', 'card', 'yard']\n", + "['cart', 'card', 'ward']\n", + "['cart', 'card', 'cord']\n", + "['cart', 'curt', 'curb']\n", + "['cart', 'curt', 'hurt']\n", + "['cart', 'curt', 'curd']\n", + "['cart', 'curt', 'curl']\n", + "['cart', 'curt', 'cure']\n", + "['cart', 'curt', 'cult']\n", + "['cart', 'curt', 'curs']\n", + "['cart', 'tart', 'hart']\n", + "['cart', 'tart', 'tare']\n", + "['cart', 'tart', 'mart']\n", + "['cart', 'tart', 'wart']\n", + "['cart', 'tart', 'tars']\n", + "['cart', 'tart', 'taut']\n", + "['cart', 'tart', 'tarp']\n", + "['cart', 'tart', 'tact']\n", + "['cart', 'tart', 'tort']\n", + "['cart', 'tart', 'dart']\n", + "['cart', 'tart', 'part']\n", + "['cart', 'tart', 'taro']\n", + "['cart', 'care', 'came']\n", "['cart', 'care', 'hare']\n", - "['cart', 'care', 'mare']\n", - "['cart', 'care', 'pare']\n", - "['cart', 'care', 'rare']\n", - "['cart', 'care', 'tare']\n", - "['cart', 'care', 'ware']\n", - "['cart', 'care', 'core']\n", "['cart', 'care', 'cure']\n", + "['cart', 'care', 'card']\n", + "['cart', 'care', 'core']\n", "['cart', 'care', 'cafe']\n", - "['cart', 'care', 'cage']\n", - "['cart', 'care', 'cake']\n", - "['cart', 'care', 'came']\n", - "['cart', 'care', 'cane']\n", - "['cart', 'care', 'cape']\n", + "['cart', 'care', 'cars']\n", + "['cart', 'care', 'fare']\n", "['cart', 'care', 'case']\n", - "['cart', 'care', 'cave']\n", - "['cart', 'care', 'card']\n", + "['cart', 'care', 'cane']\n", + "['cart', 'care', 'bare']\n", + "['cart', 'care', 'cage']\n", "['cart', 'care', 'carp']\n", - "['cart', 'care', 'cars']\n", - "['cart', 'carp', 'harp']\n", - "['cart', 'carp', 'tarp']\n", + "['cart', 'care', 'cave']\n", + "['cart', 'care', 'cape']\n", + "['cart', 'care', 'pare']\n", + "['cart', 'care', 'ware']\n", + "['cart', 'care', 'mare']\n", + "['cart', 'care', 'cake']\n", + "['cart', 'care', 'rare']\n", + "['cart', 'care', 'tare']\n", + "['cart', 'care', 'dare']\n", + "['cart', 'cant', 'cast']\n", + "['cart', 'cant', 'rant']\n", + "['cart', 'cant', 'cent']\n", + "['cart', 'cant', 'want']\n", + "['cart', 'cant', 'cans']\n", + "['cart', 'cant', 'cane']\n", + "['cart', 'cant', 'pant']\n", + "['cart', 'dart', 'dirt']\n", + "['cart', 'dart', 'daft']\n", + "['cart', 'dart', 'dark']\n", + "['cart', 'dart', 'hart']\n", + "['cart', 'dart', 'wart']\n", + "['cart', 'dart', 'mart']\n", + "['cart', 'dart', 'dare']\n", + "['cart', 'dart', 'darn']\n", + "['cart', 'dart', 'tart']\n", + "['cart', 'dart', 'part']\n", + "['cart', 'part', 'port']\n", + "['cart', 'part', 'hart']\n", + "['cart', 'part', 'pact']\n", + "['cart', 'part', 'pert']\n", + "['cart', 'part', 'pare']\n", + "['cart', 'part', 'past']\n", + "['cart', 'part', 'mart']\n", + "['cart', 'part', 'wart']\n", + "['cart', 'part', 'pars']\n", + "['cart', 'part', 'dart']\n", + "['cart', 'part', 'tart']\n", + "['cart', 'part', 'park']\n", + "['cart', 'part', 'pant']\n", + "['cart', 'carp', 'cars']\n", "['cart', 'carp', 'warp']\n", - "['cart', 'carp', 'camp']\n", "['cart', 'carp', 'card']\n", + "['cart', 'carp', 'camp']\n", "['cart', 'carp', 'care']\n", - "['cart', 'carp', 'cars']\n", - "['cart', 'cars', 'bars']\n", - "['cart', 'cars', 'ears']\n", - "['cart', 'cars', 'jars']\n", - "['cart', 'cars', 'mars']\n", - "['cart', 'cars', 'oars']\n", - "['cart', 'cars', 'pars']\n", - "['cart', 'cars', 'tars']\n", - "['cart', 'cars', 'wars']\n", - "['cart', 'cars', 'curs']\n", - "['cart', 'cars', 'cabs']\n", - "['cart', 'cars', 'cads']\n", - "['cart', 'cars', 'cams']\n", - "['cart', 'cars', 'cans']\n", - "['cart', 'cars', 'caps']\n", - "['cart', 'cars', 'cats']\n", - "['cart', 'cars', 'caws']\n", - "['cart', 'cars', 'card']\n", - "['cart', 'cars', 'care']\n", - "['cart', 'cars', 'carp']\n", - "['cart', 'dart', 'hart', 'mart']\n", - "['cart', 'dart', 'hart', 'part']\n", - "['cart', 'dart', 'hart', 'tart']\n", - "['cart', 'dart', 'hart', 'wart']\n", - "['cart', 'dart', 'hart', 'hurt']\n", - "['cart', 'dart', 'hart', 'haft']\n", - "['cart', 'dart', 'hart', 'halt']\n", - "['cart', 'dart', 'hart', 'hard']\n", - "['cart', 'dart', 'hart', 'hare']\n", - "['cart', 'dart', 'hart', 'hark']\n", - "['cart', 'dart', 'hart', 'harm']\n", - "['cart', 'dart', 'hart', 'harp']\n", - "['cart', 'dart', 'mart', 'hart']\n", - "['cart', 'dart', 'mart', 'part']\n", - "['cart', 'dart', 'mart', 'tart']\n", - "['cart', 'dart', 'mart', 'wart']\n", - "['cart', 'dart', 'mart', 'malt']\n", - "['cart', 'dart', 'mart', 'mast']\n", - "['cart', 'dart', 'mart', 'matt']\n", - "['cart', 'dart', 'mart', 'mare']\n", - "['cart', 'dart', 'mart', 'mark']\n", - "['cart', 'dart', 'mart', 'mars']\n", - "['cart', 'dart', 'part', 'hart']\n", - "['cart', 'dart', 'part', 'mart']\n", - "['cart', 'dart', 'part', 'tart']\n", - "['cart', 'dart', 'part', 'wart']\n", - "['cart', 'dart', 'part', 'pert']\n", - "['cart', 'dart', 'part', 'port']\n", - "['cart', 'dart', 'part', 'pact']\n", - "['cart', 'dart', 'part', 'pant']\n", - "['cart', 'dart', 'part', 'past']\n", - "['cart', 'dart', 'part', 'pare']\n", - "['cart', 'dart', 'part', 'park']\n", - "['cart', 'dart', 'part', 'pars']\n", - "['cart', 'dart', 'tart', 'hart']\n", - "['cart', 'dart', 'tart', 'mart']\n", - "['cart', 'dart', 'tart', 'part']\n", - "['cart', 'dart', 'tart', 'wart']\n", - "['cart', 'dart', 'tart', 'tort']\n", - "['cart', 'dart', 'tart', 'tact']\n", - "['cart', 'dart', 'tart', 'taut']\n", - "['cart', 'dart', 'tart', 'tare']\n", - "['cart', 'dart', 'tart', 'taro']\n", - "['cart', 'dart', 'tart', 'tarp']\n", - "['cart', 'dart', 'tart', 'tars']\n", - "['cart', 'dart', 'wart', 'hart']\n", - "['cart', 'dart', 'wart', 'mart']\n", - "['cart', 'dart', 'wart', 'part']\n", - "['cart', 'dart', 'wart', 'tart']\n", - "['cart', 'dart', 'wart', 'waft']\n", - "['cart', 'dart', 'wart', 'wait']\n", - "['cart', 'dart', 'wart', 'want']\n", - "['cart', 'dart', 'wart', 'watt']\n", - "['cart', 'dart', 'wart', 'ward']\n", - "['cart', 'dart', 'wart', 'ware']\n", - "['cart', 'dart', 'wart', 'warm']\n", - "['cart', 'dart', 'wart', 'warn']\n", - "['cart', 'dart', 'wart', 'warp']\n", - "['cart', 'dart', 'wart', 'wars']\n", - "['cart', 'dart', 'wart', 'wary']\n", - "['cart', 'dart', 'dirt', 'girt']\n", - "['cart', 'dart', 'dirt', 'diet']\n", - "['cart', 'dart', 'dirt', 'dint']\n", - "['cart', 'dart', 'dirt', 'dire']\n", - "['cart', 'dart', 'dirt', 'dirk']\n", - "['cart', 'dart', 'daft', 'haft']\n", - "['cart', 'dart', 'daft', 'raft']\n", - "['cart', 'dart', 'daft', 'waft']\n", - "['cart', 'dart', 'daft', 'deft']\n", - "['cart', 'dart', 'dare', 'bare']\n", - "['cart', 'dart', 'dare', 'care']\n", - "['cart', 'dart', 'dare', 'fare']\n", - "['cart', 'dart', 'dare', 'hare']\n", - "['cart', 'dart', 'dare', 'mare']\n", - "['cart', 'dart', 'dare', 'pare']\n", - "['cart', 'dart', 'dare', 'rare']\n", - "['cart', 'dart', 'dare', 'tare']\n", - "['cart', 'dart', 'dare', 'ware']\n", - "['cart', 'dart', 'dare', 'dire']\n", - "['cart', 'dart', 'dare', 'dale']\n", - "['cart', 'dart', 'dare', 'dame']\n", - "['cart', 'dart', 'dare', 'date']\n", - "['cart', 'dart', 'dare', 'daze']\n", - "['cart', 'dart', 'dare', 'dark']\n", - "['cart', 'dart', 'dare', 'darn']\n", - "['cart', 'dart', 'dark', 'bark']\n", - "['cart', 'dart', 'dark', 'hark']\n", - "['cart', 'dart', 'dark', 'lark']\n", - "['cart', 'dart', 'dark', 'mark']\n", - "['cart', 'dart', 'dark', 'nark']\n", - "['cart', 'dart', 'dark', 'park']\n", - "['cart', 'dart', 'dark', 'dirk']\n", - "['cart', 'dart', 'dark', 'dork']\n", - "['cart', 'dart', 'dark', 'dank']\n", - "['cart', 'dart', 'dark', 'dare']\n", - "['cart', 'dart', 'dark', 'darn']\n", - "['cart', 'dart', 'darn', 'barn']\n", - "['cart', 'dart', 'darn', 'earn']\n", - "['cart', 'dart', 'darn', 'warn']\n", - "['cart', 'dart', 'darn', 'yarn']\n", - "['cart', 'dart', 'darn', 'damn']\n", - "['cart', 'dart', 'darn', 'dawn']\n", - "['cart', 'dart', 'darn', 'dare']\n", - "['cart', 'dart', 'darn', 'dark']\n", - "['cart', 'hart', 'dart', 'mart']\n", - "['cart', 'hart', 'dart', 'part']\n", - "['cart', 'hart', 'dart', 'tart']\n", - "['cart', 'hart', 'dart', 'wart']\n", - "['cart', 'hart', 'dart', 'dirt']\n", - "['cart', 'hart', 'dart', 'daft']\n", - "['cart', 'hart', 'dart', 'dare']\n", - "['cart', 'hart', 'dart', 'dark']\n", - "['cart', 'hart', 'dart', 'darn']\n", - "['cart', 'hart', 'mart', 'dart']\n", - "['cart', 'hart', 'mart', 'part']\n", - "['cart', 'hart', 'mart', 'tart']\n", - "['cart', 'hart', 'mart', 'wart']\n", - "['cart', 'hart', 'mart', 'malt']\n", - "['cart', 'hart', 'mart', 'mast']\n", - "['cart', 'hart', 'mart', 'matt']\n", - "['cart', 'hart', 'mart', 'mare']\n", - "['cart', 'hart', 'mart', 'mark']\n", - "['cart', 'hart', 'mart', 'mars']\n", - "['cart', 'hart', 'part', 'dart']\n", - "['cart', 'hart', 'part', 'mart']\n", - "['cart', 'hart', 'part', 'tart']\n", - "['cart', 'hart', 'part', 'wart']\n", - "['cart', 'hart', 'part', 'pert']\n", - "['cart', 'hart', 'part', 'port']\n", - "['cart', 'hart', 'part', 'pact']\n", - "['cart', 'hart', 'part', 'pant']\n", - "['cart', 'hart', 'part', 'past']\n", - "['cart', 'hart', 'part', 'pare']\n", - "['cart', 'hart', 'part', 'park']\n", - "['cart', 'hart', 'part', 'pars']\n", - "['cart', 'hart', 'tart', 'dart']\n", - "['cart', 'hart', 'tart', 'mart']\n", - "['cart', 'hart', 'tart', 'part']\n", - "['cart', 'hart', 'tart', 'wart']\n", - "['cart', 'hart', 'tart', 'tort']\n", - "['cart', 'hart', 'tart', 'tact']\n", - "['cart', 'hart', 'tart', 'taut']\n", - "['cart', 'hart', 'tart', 'tare']\n", - "['cart', 'hart', 'tart', 'taro']\n", - "['cart', 'hart', 'tart', 'tarp']\n", - "['cart', 'hart', 'tart', 'tars']\n", - "['cart', 'hart', 'wart', 'dart']\n", - "['cart', 'hart', 'wart', 'mart']\n", - "['cart', 'hart', 'wart', 'part']\n", - "['cart', 'hart', 'wart', 'tart']\n", - "['cart', 'hart', 'wart', 'waft']\n", - "['cart', 'hart', 'wart', 'wait']\n", - "['cart', 'hart', 'wart', 'want']\n", - "['cart', 'hart', 'wart', 'watt']\n", - "['cart', 'hart', 'wart', 'ward']\n", - "['cart', 'hart', 'wart', 'ware']\n", - "['cart', 'hart', 'wart', 'warm']\n", - "['cart', 'hart', 'wart', 'warn']\n", - "['cart', 'hart', 'wart', 'warp']\n", - "['cart', 'hart', 'wart', 'wars']\n", - "['cart', 'hart', 'wart', 'wary']\n", - "['cart', 'hart', 'hurt', 'curt']\n", - "['cart', 'hart', 'hurt', 'hunt']\n", - "['cart', 'hart', 'hurt', 'hurl']\n", - "['cart', 'hart', 'haft', 'daft']\n", - "['cart', 'hart', 'haft', 'raft']\n", - "['cart', 'hart', 'haft', 'waft']\n", - "['cart', 'hart', 'haft', 'heft']\n", - "['cart', 'hart', 'haft', 'halt']\n", - "['cart', 'hart', 'halt', 'malt']\n", - "['cart', 'hart', 'halt', 'salt']\n", - "['cart', 'hart', 'halt', 'hilt']\n", - "['cart', 'hart', 'halt', 'haft']\n", - "['cart', 'hart', 'halt', 'hale']\n", - "['cart', 'hart', 'halt', 'half']\n", - "['cart', 'hart', 'halt', 'hall']\n", - "['cart', 'hart', 'halt', 'halo']\n", + "['cart', 'carp', 'tarp']\n", + "['cart', 'carp', 'harp']\n", + "['cart', 'cast', 'last', 'list']\n", + "['cart', 'cast', 'last', 'lost']\n", + "['cart', 'cast', 'last', 'bast']\n", + "['cart', 'cast', 'last', 'lust']\n", + "['cart', 'cast', 'last', 'lass']\n", + "['cart', 'cast', 'last', 'past']\n", + "['cart', 'cast', 'last', 'lash']\n", + "['cart', 'cast', 'last', 'mast']\n", + "['cart', 'cast', 'last', 'fast']\n", + "['cart', 'cast', 'last', 'east']\n", + "['cart', 'cast', 'last', 'lest']\n", + "['cart', 'cast', 'last', 'vast']\n", + "['cart', 'cast', 'bast', 'last']\n", + "['cart', 'cast', 'bast', 'bust']\n", + "['cart', 'cast', 'bast', 'bass']\n", + "['cart', 'cast', 'bast', 'base']\n", + "['cart', 'cast', 'bast', 'past']\n", + "['cart', 'cast', 'bast', 'mast']\n", + "['cart', 'cast', 'bast', 'bait']\n", + "['cart', 'cast', 'bast', 'fast']\n", + "['cart', 'cast', 'bast', 'best']\n", + "['cart', 'cast', 'bast', 'bash']\n", + "['cart', 'cast', 'bast', 'east']\n", + "['cart', 'cast', 'bast', 'bask']\n", + "['cart', 'cast', 'bast', 'vast']\n", + "['cart', 'cast', 'cant', 'rant']\n", + "['cart', 'cast', 'cant', 'cent']\n", + "['cart', 'cast', 'cant', 'want']\n", + "['cart', 'cast', 'cant', 'cans']\n", + "['cart', 'cast', 'cant', 'cane']\n", + "['cart', 'cast', 'cant', 'pant']\n", + "['cart', 'cast', 'past', 'last']\n", + "['cart', 'cast', 'past', 'bast']\n", + "['cart', 'cast', 'past', 'psst']\n", + "['cart', 'cast', 'past', 'pact']\n", + "['cart', 'cast', 'past', 'pass']\n", + "['cart', 'cast', 'past', 'pant']\n", + "['cart', 'cast', 'past', 'mast']\n", + "['cart', 'cast', 'past', 'post']\n", + "['cart', 'cast', 'past', 'fast']\n", + "['cart', 'cast', 'past', 'pest']\n", + "['cart', 'cast', 'past', 'east']\n", + "['cart', 'cast', 'past', 'part']\n", + "['cart', 'cast', 'past', 'vast']\n", + "['cart', 'cast', 'mast', 'mask']\n", + "['cart', 'cast', 'mast', 'last']\n", + "['cart', 'cast', 'mast', 'malt']\n", + "['cart', 'cast', 'mast', 'bast']\n", + "['cart', 'cast', 'mast', 'mist']\n", + "['cart', 'cast', 'mast', 'must']\n", + "['cart', 'cast', 'mast', 'past']\n", + "['cart', 'cast', 'mast', 'mart']\n", + "['cart', 'cast', 'mast', 'fast']\n", + "['cart', 'cast', 'mast', 'most']\n", + "['cart', 'cast', 'mast', 'mash']\n", + "['cart', 'cast', 'mast', 'matt']\n", + "['cart', 'cast', 'mast', 'east']\n", + "['cart', 'cast', 'mast', 'vast']\n", + "['cart', 'cast', 'mast', 'mass']\n", + "['cart', 'cast', 'fast', 'last']\n", + "['cart', 'cast', 'fast', 'fest']\n", + "['cart', 'cast', 'fast', 'bast']\n", + "['cart', 'cast', 'fast', 'fact']\n", + "['cart', 'cast', 'fast', 'past']\n", + "['cart', 'cast', 'fast', 'mast']\n", + "['cart', 'cast', 'fast', 'fist']\n", + "['cart', 'cast', 'fast', 'east']\n", + "['cart', 'cast', 'fast', 'vast']\n", + "['cart', 'cast', 'case', 'came']\n", + "['cart', 'cast', 'case', 'cake']\n", + "['cart', 'cast', 'case', 'cafe']\n", + "['cart', 'cast', 'case', 'cape']\n", + "['cart', 'cast', 'case', 'base']\n", + "['cart', 'cast', 'case', 'vase']\n", + "['cart', 'cast', 'case', 'care']\n", + "['cart', 'cast', 'case', 'ease']\n", + "['cart', 'cast', 'case', 'cane']\n", + "['cart', 'cast', 'case', 'cash']\n", + "['cart', 'cast', 'case', 'cask']\n", + "['cart', 'cast', 'case', 'cage']\n", + "['cart', 'cast', 'case', 'cave']\n", + "['cart', 'cast', 'east', 'last']\n", + "['cart', 'cast', 'east', 'bast']\n", + "['cart', 'cast', 'east', 'easy']\n", + "['cart', 'cast', 'east', 'past']\n", + "['cart', 'cast', 'east', 'mast']\n", + "['cart', 'cast', 'east', 'fast']\n", + "['cart', 'cast', 'east', 'ease']\n", + "['cart', 'cast', 'east', 'vast']\n", + "['cart', 'cast', 'cyst', 'cost']\n", + "['cart', 'cast', 'cash', 'sash']\n", + "['cart', 'cast', 'cash', 'lash']\n", + "['cart', 'cast', 'cash', 'dash']\n", + "['cart', 'cast', 'cash', 'bash']\n", + "['cart', 'cast', 'cash', 'wash']\n", + "['cart', 'cast', 'cash', 'case']\n", + "['cart', 'cast', 'cash', 'mash']\n", + "['cart', 'cast', 'cash', 'cask']\n", + "['cart', 'cast', 'cash', 'gash']\n", + "['cart', 'cast', 'cash', 'hash']\n", + "['cart', 'cast', 'cash', 'rash']\n", + "['cart', 'cast', 'cask', 'mask']\n", + "['cart', 'cast', 'cask', 'case']\n", + "['cart', 'cast', 'cask', 'cash']\n", + "['cart', 'cast', 'cask', 'bask']\n", + "['cart', 'cast', 'cask', 'task']\n", + "['cart', 'cast', 'vast', 'last']\n", + "['cart', 'cast', 'vast', 'bast']\n", + "['cart', 'cast', 'vast', 'vest']\n", + "['cart', 'cast', 'vast', 'past']\n", + "['cart', 'cast', 'vast', 'mast']\n", + "['cart', 'cast', 'vast', 'vase']\n", + "['cart', 'cast', 'vast', 'fast']\n", + "['cart', 'cast', 'vast', 'east']\n", + "['cart', 'cast', 'cost', 'colt']\n", + "['cart', 'cast', 'cost', 'lost']\n", + "['cart', 'cast', 'cost', 'tost']\n", + "['cart', 'cast', 'cost', 'post']\n", + "['cart', 'cast', 'cost', 'cosy']\n", + "['cart', 'cast', 'cost', 'coat']\n", + "['cart', 'cast', 'cost', 'coot']\n", + "['cart', 'cast', 'cost', 'most']\n", + "['cart', 'cast', 'cost', 'cyst']\n", + "['cart', 'cast', 'cost', 'host']\n", + "['cart', 'hart', 'hard', 'harm']\n", "['cart', 'hart', 'hard', 'bard']\n", - "['cart', 'hart', 'hard', 'card']\n", + "['cart', 'hart', 'hard', 'hare']\n", "['cart', 'hart', 'hard', 'lard']\n", - "['cart', 'hart', 'hard', 'ward']\n", - "['cart', 'hart', 'hard', 'yard']\n", + "['cart', 'hart', 'hard', 'card']\n", "['cart', 'hart', 'hard', 'herd']\n", - "['cart', 'hart', 'hard', 'hand']\n", - "['cart', 'hart', 'hard', 'hare']\n", "['cart', 'hart', 'hard', 'hark']\n", - "['cart', 'hart', 'hard', 'harm']\n", + "['cart', 'hart', 'hard', 'hand']\n", "['cart', 'hart', 'hard', 'harp']\n", - "['cart', 'hart', 'hare', 'bare']\n", - "['cart', 'hart', 'hare', 'care']\n", - "['cart', 'hart', 'hare', 'dare']\n", - "['cart', 'hart', 'hare', 'fare']\n", + "['cart', 'hart', 'hard', 'yard']\n", + "['cart', 'hart', 'hard', 'ward']\n", + "['cart', 'hart', 'harm', 'farm']\n", + "['cart', 'hart', 'harm', 'hard']\n", + "['cart', 'hart', 'harm', 'hare']\n", + "['cart', 'hart', 'harm', 'warm']\n", + "['cart', 'hart', 'harm', 'harp']\n", + "['cart', 'hart', 'harm', 'hark']\n", "['cart', 'hart', 'hare', 'mare']\n", - "['cart', 'hart', 'hare', 'pare']\n", + "['cart', 'hart', 'hare', 'hard']\n", + "['cart', 'hart', 'hare', 'harm']\n", "['cart', 'hart', 'hare', 'rare']\n", + "['cart', 'hart', 'hare', 'hake']\n", + "['cart', 'hart', 'hare', 'fare']\n", "['cart', 'hart', 'hare', 'tare']\n", - "['cart', 'hart', 'hare', 'ware']\n", + "['cart', 'hart', 'hare', 'pare']\n", + "['cart', 'hart', 'hare', 'hate']\n", "['cart', 'hart', 'hare', 'here']\n", - "['cart', 'hart', 'hare', 'hire']\n", - "['cart', 'hart', 'hare', 'hake']\n", + "['cart', 'hart', 'hare', 'dare']\n", "['cart', 'hart', 'hare', 'hale']\n", - "['cart', 'hart', 'hare', 'hate']\n", + "['cart', 'hart', 'hare', 'care']\n", "['cart', 'hart', 'hare', 'have']\n", - "['cart', 'hart', 'hare', 'haze']\n", - "['cart', 'hart', 'hare', 'hard']\n", - "['cart', 'hart', 'hare', 'hark']\n", - "['cart', 'hart', 'hare', 'harm']\n", "['cart', 'hart', 'hare', 'harp']\n", - "['cart', 'hart', 'hark', 'bark']\n", + "['cart', 'hart', 'hare', 'ware']\n", + "['cart', 'hart', 'hare', 'bare']\n", + "['cart', 'hart', 'hare', 'hark']\n", + "['cart', 'hart', 'hare', 'hire']\n", + "['cart', 'hart', 'hare', 'haze']\n", + "['cart', 'hart', 'hurt', 'curt']\n", + "['cart', 'hart', 'hurt', 'hurl']\n", + "['cart', 'hart', 'hurt', 'hunt']\n", + "['cart', 'hart', 'haft', 'daft']\n", + "['cart', 'hart', 'haft', 'heft']\n", + "['cart', 'hart', 'haft', 'halt']\n", + "['cart', 'hart', 'haft', 'waft']\n", + "['cart', 'hart', 'haft', 'raft']\n", + "['cart', 'hart', 'halt', 'malt']\n", + "['cart', 'hart', 'halt', 'halo']\n", + "['cart', 'hart', 'halt', 'hall']\n", + "['cart', 'hart', 'halt', 'salt']\n", + "['cart', 'hart', 'halt', 'half']\n", + "['cart', 'hart', 'halt', 'haft']\n", + "['cart', 'hart', 'halt', 'hale']\n", + "['cart', 'hart', 'halt', 'hilt']\n", + "['cart', 'hart', 'mart', 'mare']\n", + "['cart', 'hart', 'mart', 'malt']\n", + "['cart', 'hart', 'mart', 'dart']\n", + "['cart', 'hart', 'mart', 'mast']\n", + "['cart', 'hart', 'mart', 'wart']\n", + "['cart', 'hart', 'mart', 'tart']\n", + "['cart', 'hart', 'mart', 'matt']\n", + "['cart', 'hart', 'mart', 'mars']\n", + "['cart', 'hart', 'mart', 'part']\n", + "['cart', 'hart', 'mart', 'mark']\n", + "['cart', 'hart', 'wart', 'wary']\n", + "['cart', 'hart', 'wart', 'warn']\n", + "['cart', 'hart', 'wart', 'warm']\n", + "['cart', 'hart', 'wart', 'warp']\n", + "['cart', 'hart', 'wart', 'wars']\n", + "['cart', 'hart', 'wart', 'mart']\n", + "['cart', 'hart', 'wart', 'watt']\n", + "['cart', 'hart', 'wart', 'want']\n", + "['cart', 'hart', 'wart', 'ware']\n", + "['cart', 'hart', 'wart', 'tart']\n", + "['cart', 'hart', 'wart', 'waft']\n", + "['cart', 'hart', 'wart', 'dart']\n", + "['cart', 'hart', 'wart', 'part']\n", + "['cart', 'hart', 'wart', 'wait']\n", + "['cart', 'hart', 'wart', 'ward']\n", + "['cart', 'hart', 'hark', 'hard']\n", + "['cart', 'hart', 'hark', 'harm']\n", "['cart', 'hart', 'hark', 'dark']\n", - "['cart', 'hart', 'hark', 'lark']\n", - "['cart', 'hart', 'hark', 'mark']\n", + "['cart', 'hart', 'hark', 'hare']\n", "['cart', 'hart', 'hark', 'nark']\n", - "['cart', 'hart', 'hark', 'park']\n", - "['cart', 'hart', 'hark', 'hack']\n", + "['cart', 'hart', 'hark', 'bark']\n", + "['cart', 'hart', 'hark', 'lark']\n", "['cart', 'hart', 'hark', 'hank']\n", - "['cart', 'hart', 'hark', 'hawk']\n", - "['cart', 'hart', 'hark', 'hard']\n", - "['cart', 'hart', 'hark', 'hare']\n", - "['cart', 'hart', 'hark', 'harm']\n", "['cart', 'hart', 'hark', 'harp']\n", - "['cart', 'hart', 'harm', 'farm']\n", - "['cart', 'hart', 'harm', 'warm']\n", - "['cart', 'hart', 'harm', 'hard']\n", - "['cart', 'hart', 'harm', 'hare']\n", - "['cart', 'hart', 'harm', 'hark']\n", - "['cart', 'hart', 'harm', 'harp']\n", - "['cart', 'hart', 'harp', 'carp']\n", - "['cart', 'hart', 'harp', 'tarp']\n", - "['cart', 'hart', 'harp', 'warp']\n", - "['cart', 'hart', 'harp', 'hasp']\n", + "['cart', 'hart', 'hark', 'park']\n", + "['cart', 'hart', 'hark', 'hawk']\n", + "['cart', 'hart', 'hark', 'hack']\n", + "['cart', 'hart', 'hark', 'mark']\n", + "['cart', 'hart', 'tart', 'tare']\n", + "['cart', 'hart', 'tart', 'mart']\n", + "['cart', 'hart', 'tart', 'wart']\n", + "['cart', 'hart', 'tart', 'tars']\n", + "['cart', 'hart', 'tart', 'taut']\n", + "['cart', 'hart', 'tart', 'tarp']\n", + "['cart', 'hart', 'tart', 'tact']\n", + "['cart', 'hart', 'tart', 'tort']\n", + "['cart', 'hart', 'tart', 'dart']\n", + "['cart', 'hart', 'tart', 'part']\n", + "['cart', 'hart', 'tart', 'taro']\n", "['cart', 'hart', 'harp', 'hard']\n", + "['cart', 'hart', 'harp', 'harm']\n", "['cart', 'hart', 'harp', 'hare']\n", + "['cart', 'hart', 'harp', 'warp']\n", + "['cart', 'hart', 'harp', 'tarp']\n", "['cart', 'hart', 'harp', 'hark']\n", - "['cart', 'hart', 'harp', 'harm']\n", - "['cart', 'mart', 'dart', 'hart']\n", - "['cart', 'mart', 'dart', 'part']\n", - "['cart', 'mart', 'dart', 'tart']\n", - "['cart', 'mart', 'dart', 'wart']\n", - "['cart', 'mart', 'dart', 'dirt']\n", - "['cart', 'mart', 'dart', 'daft']\n", - "['cart', 'mart', 'dart', 'dare']\n", - "['cart', 'mart', 'dart', 'dark']\n", - "['cart', 'mart', 'dart', 'darn']\n", - "['cart', 'mart', 'hart', 'dart']\n", - "['cart', 'mart', 'hart', 'part']\n", - "['cart', 'mart', 'hart', 'tart']\n", - "['cart', 'mart', 'hart', 'wart']\n", - "['cart', 'mart', 'hart', 'hurt']\n", - "['cart', 'mart', 'hart', 'haft']\n", - "['cart', 'mart', 'hart', 'halt']\n", - "['cart', 'mart', 'hart', 'hard']\n", - "['cart', 'mart', 'hart', 'hare']\n", - "['cart', 'mart', 'hart', 'hark']\n", - "['cart', 'mart', 'hart', 'harm']\n", - "['cart', 'mart', 'hart', 'harp']\n", - "['cart', 'mart', 'part', 'dart']\n", - "['cart', 'mart', 'part', 'hart']\n", - "['cart', 'mart', 'part', 'tart']\n", - "['cart', 'mart', 'part', 'wart']\n", - "['cart', 'mart', 'part', 'pert']\n", - "['cart', 'mart', 'part', 'port']\n", - "['cart', 'mart', 'part', 'pact']\n", - "['cart', 'mart', 'part', 'pant']\n", - "['cart', 'mart', 'part', 'past']\n", - "['cart', 'mart', 'part', 'pare']\n", - "['cart', 'mart', 'part', 'park']\n", - "['cart', 'mart', 'part', 'pars']\n", - "['cart', 'mart', 'tart', 'dart']\n", - "['cart', 'mart', 'tart', 'hart']\n", - "['cart', 'mart', 'tart', 'part']\n", - "['cart', 'mart', 'tart', 'wart']\n", - "['cart', 'mart', 'tart', 'tort']\n", - "['cart', 'mart', 'tart', 'tact']\n", - "['cart', 'mart', 'tart', 'taut']\n", - "['cart', 'mart', 'tart', 'tare']\n", - "['cart', 'mart', 'tart', 'taro']\n", - "['cart', 'mart', 'tart', 'tarp']\n", - "['cart', 'mart', 'tart', 'tars']\n", - "['cart', 'mart', 'wart', 'dart']\n", - "['cart', 'mart', 'wart', 'hart']\n", - "['cart', 'mart', 'wart', 'part']\n", - "['cart', 'mart', 'wart', 'tart']\n", - "['cart', 'mart', 'wart', 'waft']\n", - "['cart', 'mart', 'wart', 'wait']\n", - "['cart', 'mart', 'wart', 'want']\n", - "['cart', 'mart', 'wart', 'watt']\n", - "['cart', 'mart', 'wart', 'ward']\n", - "['cart', 'mart', 'wart', 'ware']\n", - "['cart', 'mart', 'wart', 'warm']\n", - "['cart', 'mart', 'wart', 'warn']\n", - "['cart', 'mart', 'wart', 'warp']\n", - "['cart', 'mart', 'wart', 'wars']\n", - "['cart', 'mart', 'wart', 'wary']\n", - "['cart', 'mart', 'malt', 'halt']\n", - "['cart', 'mart', 'malt', 'salt']\n", - "['cart', 'mart', 'malt', 'melt']\n", - "['cart', 'mart', 'malt', 'mast']\n", - "['cart', 'mart', 'malt', 'matt']\n", - "['cart', 'mart', 'malt', 'male']\n", - "['cart', 'mart', 'malt', 'mall']\n", - "['cart', 'mart', 'mast', 'bast']\n", - "['cart', 'mart', 'mast', 'cast']\n", - "['cart', 'mart', 'mast', 'east']\n", - "['cart', 'mart', 'mast', 'fast']\n", - "['cart', 'mart', 'mast', 'last']\n", - "['cart', 'mart', 'mast', 'past']\n", - "['cart', 'mart', 'mast', 'vast']\n", - "['cart', 'mart', 'mast', 'mist']\n", - "['cart', 'mart', 'mast', 'most']\n", - "['cart', 'mart', 'mast', 'must']\n", - "['cart', 'mart', 'mast', 'malt']\n", - "['cart', 'mart', 'mast', 'matt']\n", - "['cart', 'mart', 'mast', 'mash']\n", - "['cart', 'mart', 'mast', 'mask']\n", - "['cart', 'mart', 'mast', 'mass']\n", - "['cart', 'mart', 'matt', 'watt']\n", - "['cart', 'mart', 'matt', 'mitt']\n", - "['cart', 'mart', 'matt', 'mutt']\n", - "['cart', 'mart', 'matt', 'malt']\n", - "['cart', 'mart', 'matt', 'mast']\n", - "['cart', 'mart', 'matt', 'mate']\n", - "['cart', 'mart', 'matt', 'math']\n", - "['cart', 'mart', 'matt', 'mats']\n", - "['cart', 'mart', 'mare', 'bare']\n", - "['cart', 'mart', 'mare', 'care']\n", - "['cart', 'mart', 'mare', 'dare']\n", - "['cart', 'mart', 'mare', 'fare']\n", - "['cart', 'mart', 'mare', 'hare']\n", - "['cart', 'mart', 'mare', 'pare']\n", - "['cart', 'mart', 'mare', 'rare']\n", - "['cart', 'mart', 'mare', 'tare']\n", - "['cart', 'mart', 'mare', 'ware']\n", - "['cart', 'mart', 'mare', 'mere']\n", - "['cart', 'mart', 'mare', 'mire']\n", - "['cart', 'mart', 'mare', 'more']\n", - "['cart', 'mart', 'mare', 'mace']\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', 'mart', 'mare', 'mate']\n", - "['cart', 'mart', 'mare', 'maze']\n", - "['cart', 'mart', 'mare', 'mark']\n", - "['cart', 'mart', 'mare', 'mars']\n", - "['cart', 'mart', 'mark', 'bark']\n", - "['cart', 'mart', 'mark', 'dark']\n", - "['cart', 'mart', 'mark', 'hark']\n", - "['cart', 'mart', 'mark', 'lark']\n", - "['cart', 'mart', 'mark', 'nark']\n", - "['cart', 'mart', 'mark', 'park']\n", - "['cart', 'mart', 'mark', 'murk']\n", - "['cart', 'mart', 'mark', 'mask']\n", - "['cart', 'mart', 'mark', 'mare']\n", - "['cart', 'mart', 'mark', 'mars']\n", - "['cart', 'mart', 'mars', 'bars']\n", - "['cart', 'mart', 'mars', 'cars']\n", - "['cart', 'mart', 'mars', 'ears']\n", - "['cart', 'mart', 'mars', 'jars']\n", - "['cart', 'mart', 'mars', 'oars']\n", - "['cart', 'mart', 'mars', 'pars']\n", - "['cart', 'mart', 'mars', 'tars']\n", - "['cart', 'mart', 'mars', 'wars']\n", - "['cart', 'mart', 'mars', 'mads']\n", - "['cart', 'mart', 'mars', 'mans']\n", - "['cart', 'mart', 'mars', 'maps']\n", - "['cart', 'mart', 'mars', 'mass']\n", - "['cart', 'mart', 'mars', 'mats']\n", - "['cart', 'mart', 'mars', 'maws']\n", - "['cart', 'mart', 'mars', 'mare']\n", - "['cart', 'mart', 'mars', 'mark']\n", - "['cart', 'part', 'dart', 'hart']\n", - "['cart', 'part', 'dart', 'mart']\n", - "['cart', 'part', 'dart', 'tart']\n", - "['cart', 'part', 'dart', 'wart']\n", - "['cart', 'part', 'dart', 'dirt']\n", - "['cart', 'part', 'dart', 'daft']\n", - "['cart', 'part', 'dart', 'dare']\n", - "['cart', 'part', 'dart', 'dark']\n", - "['cart', 'part', 'dart', 'darn']\n", - "['cart', 'part', 'hart', 'dart']\n", - "['cart', 'part', 'hart', 'mart']\n", - "['cart', 'part', 'hart', 'tart']\n", - "['cart', 'part', 'hart', 'wart']\n", - "['cart', 'part', 'hart', 'hurt']\n", - "['cart', 'part', 'hart', 'haft']\n", - "['cart', 'part', 'hart', 'halt']\n", - "['cart', 'part', 'hart', 'hard']\n", - "['cart', 'part', 'hart', 'hare']\n", - "['cart', 'part', 'hart', 'hark']\n", - "['cart', 'part', 'hart', 'harm']\n", - "['cart', 'part', 'hart', 'harp']\n", - "['cart', 'part', 'mart', 'dart']\n", - "['cart', 'part', 'mart', 'hart']\n", - "['cart', 'part', 'mart', 'tart']\n", - "['cart', 'part', 'mart', 'wart']\n", - "['cart', 'part', 'mart', 'malt']\n", - "['cart', 'part', 'mart', 'mast']\n", - "['cart', 'part', 'mart', 'matt']\n", - "['cart', 'part', 'mart', 'mare']\n", - "['cart', 'part', 'mart', 'mark']\n", - "['cart', 'part', 'mart', 'mars']\n", - "['cart', 'part', 'tart', 'dart']\n", - "['cart', 'part', 'tart', 'hart']\n", - "['cart', 'part', 'tart', 'mart']\n", - "['cart', 'part', 'tart', 'wart']\n", - "['cart', 'part', 'tart', 'tort']\n", - "['cart', 'part', 'tart', 'tact']\n", - "['cart', 'part', 'tart', 'taut']\n", - "['cart', 'part', 'tart', 'tare']\n", - "['cart', 'part', 'tart', 'taro']\n", - "['cart', 'part', 'tart', 'tarp']\n", - "['cart', 'part', 'tart', 'tars']\n", - "['cart', 'part', 'wart', 'dart']\n", - "['cart', 'part', 'wart', 'hart']\n", - "['cart', 'part', 'wart', 'mart']\n", - "['cart', 'part', 'wart', 'tart']\n", - "['cart', 'part', 'wart', 'waft']\n", - "['cart', 'part', 'wart', 'wait']\n", - "['cart', 'part', 'wart', 'want']\n", - "['cart', 'part', 'wart', 'watt']\n", - "['cart', 'part', 'wart', 'ward']\n", - "['cart', 'part', 'wart', 'ware']\n", - "['cart', 'part', 'wart', 'warm']\n", - "['cart', 'part', 'wart', 'warn']\n", - "['cart', 'part', 'wart', 'warp']\n", - "['cart', 'part', 'wart', 'wars']\n", - "['cart', 'part', 'wart', 'wary']\n", - "['cart', 'part', 'pert', 'port']\n", - "['cart', 'part', 'pert', 'peat']\n", - "['cart', 'part', 'pert', 'pelt']\n", - "['cart', 'part', 'pert', 'pent']\n", - "['cart', 'part', 'pert', 'pest']\n", - "['cart', 'part', 'pert', 'perk']\n", - "['cart', 'part', 'pert', 'perm']\n", - "['cart', 'part', 'port', 'fort']\n", - "['cart', 'part', 'port', 'sort']\n", - "['cart', 'part', 'port', 'tort']\n", - "['cart', 'part', 'port', 'pert']\n", - "['cart', 'part', 'port', 'poet']\n", - "['cart', 'part', 'port', 'post']\n", - "['cart', 'part', 'port', 'pout']\n", - "['cart', 'part', 'port', 'pore']\n", - "['cart', 'part', 'port', 'pork']\n", - "['cart', 'part', 'port', 'porn']\n", - "['cart', 'part', 'pact', 'fact']\n", - "['cart', 'part', 'pact', 'tact']\n", - "['cart', 'part', 'pact', 'pant']\n", - "['cart', 'part', 'pact', 'past']\n", - "['cart', 'part', 'pact', 'pace']\n", - "['cart', 'part', 'pact', 'pack']\n", - "['cart', 'part', 'pant', 'cant']\n", - "['cart', 'part', 'pant', 'rant']\n", - "['cart', 'part', 'pant', 'want']\n", - "['cart', 'part', 'pant', 'pent']\n", - "['cart', 'part', 'pant', 'pint']\n", - "['cart', 'part', 'pant', 'punt']\n", - "['cart', 'part', 'pant', 'pact']\n", - "['cart', 'part', 'pant', 'past']\n", - "['cart', 'part', 'pant', 'pane']\n", - "['cart', 'part', 'pant', 'pang']\n", - "['cart', 'part', 'pant', 'pans']\n", - "['cart', 'part', 'past', 'bast']\n", - "['cart', 'part', 'past', 'cast']\n", - "['cart', 'part', 'past', 'east']\n", - "['cart', 'part', 'past', 'fast']\n", - "['cart', 'part', 'past', 'last']\n", - "['cart', 'part', 'past', 'mast']\n", - "['cart', 'part', 'past', 'vast']\n", - "['cart', 'part', 'past', 'pest']\n", - "['cart', 'part', 'past', 'post']\n", - "['cart', 'part', 'past', 'psst']\n", - "['cart', 'part', 'past', 'pact']\n", - "['cart', 'part', 'past', 'pant']\n", - "['cart', 'part', 'past', 'pass']\n", - "['cart', 'part', 'pare', 'bare']\n", - "['cart', 'part', 'pare', 'care']\n", - "['cart', 'part', 'pare', 'dare']\n", - "['cart', 'part', 'pare', 'fare']\n", - "['cart', 'part', 'pare', 'hare']\n", - "['cart', 'part', 'pare', 'mare']\n", - "['cart', 'part', 'pare', 'rare']\n", - "['cart', 'part', 'pare', 'tare']\n", - "['cart', 'part', 'pare', 'ware']\n", - "['cart', 'part', 'pare', 'pore']\n", - "['cart', 'part', 'pare', 'pure']\n", - "['cart', 'part', 'pare', 'pyre']\n", - "['cart', 'part', 'pare', 'pace']\n", - "['cart', 'part', 'pare', 'page']\n", - "['cart', 'part', 'pare', 'pale']\n", - "['cart', 'part', 'pare', 'pane']\n", - "['cart', 'part', 'pare', 'pate']\n", - "['cart', 'part', 'pare', 'pave']\n", - "['cart', 'part', 'pare', 'park']\n", - "['cart', 'part', 'pare', 'pars']\n", - "['cart', 'part', 'park', 'bark']\n", - "['cart', 'part', 'park', 'dark']\n", - "['cart', 'part', 'park', 'hark']\n", - "['cart', 'part', 'park', 'lark']\n", - "['cart', 'part', 'park', 'mark']\n", - "['cart', 'part', 'park', 'nark']\n", - "['cart', 'part', 'park', 'perk']\n", - "['cart', 'part', 'park', 'pork']\n", - "['cart', 'part', 'park', 'pack']\n", - "['cart', 'part', 'park', 'pare']\n", - "['cart', 'part', 'park', 'pars']\n", - "['cart', 'part', 'pars', 'bars']\n", - "['cart', 'part', 'pars', 'cars']\n", - "['cart', 'part', 'pars', 'ears']\n", - "['cart', 'part', 'pars', 'jars']\n", - "['cart', 'part', 'pars', 'mars']\n", - "['cart', 'part', 'pars', 'oars']\n", - "['cart', 'part', 'pars', 'tars']\n", - "['cart', 'part', 'pars', 'wars']\n", - "['cart', 'part', 'pars', 'pads']\n", - "['cart', 'part', 'pars', 'pals']\n", - "['cart', 'part', 'pars', 'pans']\n", - "['cart', 'part', 'pars', 'paps']\n", - "['cart', 'part', 'pars', 'pass']\n", - "['cart', 'part', 'pars', 'pats']\n", - "['cart', 'part', 'pars', 'paws']\n", - "['cart', 'part', 'pars', 'pays']\n", - "['cart', 'part', 'pars', 'pare']\n", - "['cart', 'part', 'pars', 'park']\n", - "['cart', 'tart', 'dart', 'hart']\n", - "['cart', 'tart', 'dart', 'mart']\n", - "['cart', 'tart', 'dart', 'part']\n", - "['cart', 'tart', 'dart', 'wart']\n", - "['cart', 'tart', 'dart', 'dirt']\n", - "['cart', 'tart', 'dart', 'daft']\n", - "['cart', 'tart', 'dart', 'dare']\n", - "['cart', 'tart', 'dart', 'dark']\n", - "['cart', 'tart', 'dart', 'darn']\n", - "['cart', 'tart', 'hart', 'dart']\n", - "['cart', 'tart', 'hart', 'mart']\n", - "['cart', 'tart', 'hart', 'part']\n", - "['cart', 'tart', 'hart', 'wart']\n", - "['cart', 'tart', 'hart', 'hurt']\n", - "['cart', 'tart', 'hart', 'haft']\n", - "['cart', 'tart', 'hart', 'halt']\n", - "['cart', 'tart', 'hart', 'hard']\n", - "['cart', 'tart', 'hart', 'hare']\n", - "['cart', 'tart', 'hart', 'hark']\n", - "['cart', 'tart', 'hart', 'harm']\n", - "['cart', 'tart', 'hart', 'harp']\n", - "['cart', 'tart', 'mart', 'dart']\n", - "['cart', 'tart', 'mart', 'hart']\n", - "['cart', 'tart', 'mart', 'part']\n", - "['cart', 'tart', 'mart', 'wart']\n", - "['cart', 'tart', 'mart', 'malt']\n", - "['cart', 'tart', 'mart', 'mast']\n", - "['cart', 'tart', 'mart', 'matt']\n", - "['cart', 'tart', 'mart', 'mare']\n", - "['cart', 'tart', 'mart', 'mark']\n", - "['cart', 'tart', 'mart', 'mars']\n", - "['cart', 'tart', 'part', 'dart']\n", - "['cart', 'tart', 'part', 'hart']\n", - "['cart', 'tart', 'part', 'mart']\n", - "['cart', 'tart', 'part', 'wart']\n", - "['cart', 'tart', 'part', 'pert']\n", - "['cart', 'tart', 'part', 'port']\n", - "['cart', 'tart', 'part', 'pact']\n", - "['cart', 'tart', 'part', 'pant']\n", - "['cart', 'tart', 'part', 'past']\n", - "['cart', 'tart', 'part', 'pare']\n", - "['cart', 'tart', 'part', 'park']\n", - "['cart', 'tart', 'part', 'pars']\n", - "['cart', 'tart', 'wart', 'dart']\n", - "['cart', 'tart', 'wart', 'hart']\n", - "['cart', 'tart', 'wart', 'mart']\n", - "['cart', 'tart', 'wart', 'part']\n", - "['cart', 'tart', 'wart', 'waft']\n", - "['cart', 'tart', 'wart', 'wait']\n", - "['cart', 'tart', 'wart', 'want']\n", - "['cart', 'tart', 'wart', 'watt']\n", - "['cart', 'tart', 'wart', 'ward']\n", - "['cart', 'tart', 'wart', 'ware']\n", - "['cart', 'tart', 'wart', 'warm']\n", - "['cart', 'tart', 'wart', 'warn']\n", - "['cart', 'tart', 'wart', 'warp']\n", - "['cart', 'tart', 'wart', 'wars']\n", - "['cart', 'tart', 'wart', 'wary']\n", - "['cart', 'tart', 'tort', 'fort']\n", - "['cart', 'tart', 'tort', 'port']\n", - "['cart', 'tart', 'tort', 'sort']\n", - "['cart', 'tart', 'tort', 'toot']\n", - "['cart', 'tart', 'tort', 'tost']\n", - "['cart', 'tart', 'tort', 'tout']\n", - "['cart', 'tart', 'tort', 'tore']\n", - "['cart', 'tart', 'tort', 'torn']\n", - "['cart', 'tart', 'tort', 'tors']\n", - "['cart', 'tart', 'tact', 'fact']\n", - "['cart', 'tart', 'tact', 'pact']\n", - "['cart', 'tart', 'tact', 'taut']\n", - "['cart', 'tart', 'tact', 'tack']\n", - "['cart', 'tart', 'tact', 'taco']\n", - "['cart', 'tart', 'taut', 'tout']\n", - "['cart', 'tart', 'taut', 'tact']\n", - "['cart', 'tart', 'tare', 'bare']\n", - "['cart', 'tart', 'tare', 'care']\n", - "['cart', 'tart', 'tare', 'dare']\n", - "['cart', 'tart', 'tare', 'fare']\n", - "['cart', 'tart', 'tare', 'hare']\n", - "['cart', 'tart', 'tare', 'mare']\n", - "['cart', 'tart', 'tare', 'pare']\n", - "['cart', 'tart', 'tare', 'rare']\n", - "['cart', 'tart', 'tare', 'ware']\n", - "['cart', 'tart', 'tare', 'tire']\n", - "['cart', 'tart', 'tare', 'tore']\n", - "['cart', 'tart', 'tare', 'tyre']\n", - "['cart', 'tart', 'tare', 'take']\n", - "['cart', 'tart', 'tare', 'tale']\n", - "['cart', 'tart', 'tare', 'tame']\n", - "['cart', 'tart', 'tare', 'tape']\n", - "['cart', 'tart', 'tare', 'taro']\n", - "['cart', 'tart', 'tare', 'tarp']\n", - "['cart', 'tart', 'tare', 'tars']\n", - "['cart', 'tart', 'taro', 'tiro']\n", - "['cart', 'tart', 'taro', 'tyro']\n", - "['cart', 'tart', 'taro', 'taco']\n", - "['cart', 'tart', 'taro', 'tare']\n", - "['cart', 'tart', 'taro', 'tarp']\n", - "['cart', 'tart', 'taro', 'tars']\n", - "['cart', 'tart', 'tarp', 'carp']\n", - "['cart', 'tart', 'tarp', 'harp']\n", - "['cart', 'tart', 'tarp', 'warp']\n", - "['cart', 'tart', 'tarp', 'tamp']\n", - "['cart', 'tart', 'tarp', 'tare']\n", - "['cart', 'tart', 'tarp', 'taro']\n", - "['cart', 'tart', 'tarp', 'tars']\n", - "['cart', 'tart', 'tars', 'bars']\n", - "['cart', 'tart', 'tars', 'cars']\n", - "['cart', 'tart', 'tars', 'ears']\n", - "['cart', 'tart', 'tars', 'jars']\n", - "['cart', 'tart', 'tars', 'mars']\n", - "['cart', 'tart', 'tars', 'oars']\n", - "['cart', 'tart', 'tars', 'pars']\n", - "['cart', 'tart', 'tars', 'wars']\n", - "['cart', 'tart', 'tars', 'tors']\n", - "['cart', 'tart', 'tars', 'tabs']\n", - "['cart', 'tart', 'tars', 'tads']\n", - "['cart', 'tart', 'tars', 'tags']\n", - "['cart', 'tart', 'tars', 'tams']\n", - "['cart', 'tart', 'tars', 'tans']\n", - "['cart', 'tart', 'tars', 'taps']\n", - "['cart', 'tart', 'tars', 'tats']\n", - "['cart', 'tart', 'tars', 'tare']\n", - "['cart', 'tart', 'tars', 'taro']\n", - "['cart', 'tart', 'tars', 'tarp']\n", - "['cart', 'wart', 'dart', 'hart']\n", - "['cart', 'wart', 'dart', 'mart']\n", - "['cart', 'wart', 'dart', 'part']\n", - "['cart', 'wart', 'dart', 'tart']\n", - "['cart', 'wart', 'dart', 'dirt']\n", - "['cart', 'wart', 'dart', 'daft']\n", - "['cart', 'wart', 'dart', 'dare']\n", - "['cart', 'wart', 'dart', 'dark']\n", - "['cart', 'wart', 'dart', 'darn']\n", - "['cart', 'wart', 'hart', 'dart']\n", - "['cart', 'wart', 'hart', 'mart']\n", - "['cart', 'wart', 'hart', 'part']\n", - "['cart', 'wart', 'hart', 'tart']\n", - "['cart', 'wart', 'hart', 'hurt']\n", - "['cart', 'wart', 'hart', 'haft']\n", - "['cart', 'wart', 'hart', 'halt']\n", - "['cart', 'wart', 'hart', 'hard']\n", - "['cart', 'wart', 'hart', 'hare']\n", - "['cart', 'wart', 'hart', 'hark']\n", - "['cart', 'wart', 'hart', 'harm']\n", - "['cart', 'wart', 'hart', 'harp']\n", - "['cart', 'wart', 'mart', 'dart']\n", - "['cart', 'wart', 'mart', 'hart']\n", - "['cart', 'wart', 'mart', 'part']\n", - "['cart', 'wart', 'mart', 'tart']\n", - "['cart', 'wart', 'mart', 'malt']\n", - "['cart', 'wart', 'mart', 'mast']\n", - "['cart', 'wart', 'mart', 'matt']\n", - "['cart', 'wart', 'mart', 'mare']\n", - "['cart', 'wart', 'mart', 'mark']\n", - "['cart', 'wart', 'mart', 'mars']\n", - "['cart', 'wart', 'part', 'dart']\n", - "['cart', 'wart', 'part', 'hart']\n", - "['cart', 'wart', 'part', 'mart']\n", - "['cart', 'wart', 'part', 'tart']\n", - "['cart', 'wart', 'part', 'pert']\n", - "['cart', 'wart', 'part', 'port']\n", - "['cart', 'wart', 'part', 'pact']\n", - "['cart', 'wart', 'part', 'pant']\n", - "['cart', 'wart', 'part', 'past']\n", - "['cart', 'wart', 'part', 'pare']\n", - "['cart', 'wart', 'part', 'park']\n", - "['cart', 'wart', 'part', 'pars']\n", - "['cart', 'wart', 'tart', 'dart']\n", - "['cart', 'wart', 'tart', 'hart']\n", - "['cart', 'wart', 'tart', 'mart']\n", - "['cart', 'wart', 'tart', 'part']\n", - "['cart', 'wart', 'tart', 'tort']\n", - "['cart', 'wart', 'tart', 'tact']\n", - "['cart', 'wart', 'tart', 'taut']\n", - "['cart', 'wart', 'tart', 'tare']\n", - "['cart', 'wart', 'tart', 'taro']\n", - "['cart', 'wart', 'tart', 'tarp']\n", - "['cart', 'wart', 'tart', 'tars']\n", - "['cart', 'wart', 'waft', 'daft']\n", - "['cart', 'wart', 'waft', 'haft']\n", - "['cart', 'wart', 'waft', 'raft']\n", - "['cart', 'wart', 'waft', 'weft']\n", - "['cart', 'wart', 'waft', 'wait']\n", - "['cart', 'wart', 'waft', 'want']\n", - "['cart', 'wart', 'waft', 'watt']\n", - "['cart', 'wart', 'wait', 'bait']\n", - "['cart', 'wart', 'wait', 'gait']\n", - "['cart', 'wart', 'wait', 'whit']\n", - "['cart', 'wart', 'wait', 'writ']\n", - "['cart', 'wart', 'wait', 'waft']\n", - "['cart', 'wart', 'wait', 'want']\n", - "['cart', 'wart', 'wait', 'watt']\n", - "['cart', 'wart', 'wait', 'waif']\n", - "['cart', 'wart', 'wait', 'wail']\n", - "['cart', 'wart', 'want', 'cant']\n", - "['cart', 'wart', 'want', 'pant']\n", - "['cart', 'wart', 'want', 'rant']\n", - "['cart', 'wart', 'want', 'went']\n", - "['cart', 'wart', 'want', 'wont']\n", - "['cart', 'wart', 'want', 'waft']\n", - "['cart', 'wart', 'want', 'wait']\n", - "['cart', 'wart', 'want', 'watt']\n", - "['cart', 'wart', 'want', 'wand']\n", - "['cart', 'wart', 'want', 'wane']\n", - "['cart', 'wart', 'watt', 'matt']\n", - "['cart', 'wart', 'watt', 'waft']\n", - "['cart', 'wart', 'watt', 'wait']\n", - "['cart', 'wart', 'watt', 'want']\n", - "['cart', 'wart', 'ward', 'bard']\n", - "['cart', 'wart', 'ward', 'card']\n", - "['cart', 'wart', 'ward', 'hard']\n", - "['cart', 'wart', 'ward', 'lard']\n", - "['cart', 'wart', 'ward', 'yard']\n", - "['cart', 'wart', 'ward', 'word']\n", - "['cart', 'wart', 'ward', 'wand']\n", - "['cart', 'wart', 'ward', 'ware']\n", - "['cart', 'wart', 'ward', 'warm']\n", - "['cart', 'wart', 'ward', 'warn']\n", - "['cart', 'wart', 'ward', 'warp']\n", - "['cart', 'wart', 'ward', 'wars']\n", - "['cart', 'wart', 'ward', 'wary']\n", - "['cart', 'wart', 'ware', 'bare']\n", - "['cart', 'wart', 'ware', 'care']\n", - "['cart', 'wart', 'ware', 'dare']\n", - "['cart', 'wart', 'ware', 'fare']\n", - "['cart', 'wart', 'ware', 'hare']\n", - "['cart', 'wart', 'ware', 'mare']\n", - "['cart', 'wart', 'ware', 'pare']\n", - "['cart', 'wart', 'ware', 'rare']\n", - "['cart', 'wart', 'ware', 'tare']\n", - "['cart', 'wart', 'ware', 'were']\n", - "['cart', 'wart', 'ware', 'wire']\n", - "['cart', 'wart', 'ware', 'wore']\n", - "['cart', 'wart', 'ware', 'wade']\n", - "['cart', 'wart', 'ware', 'wage']\n", - "['cart', 'wart', 'ware', 'wake']\n", - "['cart', 'wart', 'ware', 'wale']\n", - "['cart', 'wart', 'ware', 'wane']\n", - "['cart', 'wart', 'ware', 'wave']\n", - "['cart', 'wart', 'ware', 'ward']\n", - "['cart', 'wart', 'ware', 'warm']\n", - "['cart', 'wart', 'ware', 'warn']\n", - "['cart', 'wart', 'ware', 'warp']\n", - "['cart', 'wart', 'ware', 'wars']\n", - "['cart', 'wart', 'ware', 'wary']\n", - "['cart', 'wart', 'warm', 'farm']\n", - "['cart', 'wart', 'warm', 'harm']\n", - "['cart', 'wart', 'warm', 'worm']\n", - "['cart', 'wart', 'warm', 'ward']\n", - "['cart', 'wart', 'warm', 'ware']\n", - "['cart', 'wart', 'warm', 'warn']\n", - "['cart', 'wart', 'warm', 'warp']\n", - "['cart', 'wart', 'warm', 'wars']\n", - "['cart', 'wart', 'warm', 'wary']\n", - "['cart', 'wart', 'warn', 'barn']\n", - "['cart', 'wart', 'warn', 'darn']\n", - "['cart', 'wart', 'warn', 'earn']\n", - "['cart', 'wart', 'warn', 'yarn']\n", - "['cart', 'wart', 'warn', 'worn']\n", - "['cart', 'wart', 'warn', 'ward']\n", - "['cart', 'wart', 'warn', 'ware']\n", - "['cart', 'wart', 'warn', 'warm']\n", - "['cart', 'wart', 'warn', 'warp']\n", - "['cart', 'wart', 'warn', 'wars']\n", - "['cart', 'wart', 'warn', 'wary']\n", - "['cart', 'wart', 'warp', 'carp']\n", - "['cart', 'wart', 'warp', 'harp']\n", - "['cart', 'wart', 'warp', 'tarp']\n", - "['cart', 'wart', 'warp', 'wasp']\n", - "['cart', 'wart', 'warp', 'ward']\n", - "['cart', 'wart', 'warp', 'ware']\n", - "['cart', 'wart', 'warp', 'warm']\n", - "['cart', 'wart', 'warp', 'warn']\n", - "['cart', 'wart', 'warp', 'wars']\n", - "['cart', 'wart', 'warp', 'wary']\n", - "['cart', 'wart', 'wars', 'bars']\n", - "['cart', 'wart', 'wars', 'cars']\n", - "['cart', 'wart', 'wars', 'ears']\n", - "['cart', 'wart', 'wars', 'jars']\n", - "['cart', 'wart', 'wars', 'mars']\n", - "['cart', 'wart', 'wars', 'oars']\n", - "['cart', 'wart', 'wars', 'pars']\n", - "['cart', 'wart', 'wars', 'tars']\n", - "['cart', 'wart', 'wars', 'wads']\n", - "['cart', 'wart', 'wars', 'wags']\n", - "['cart', 'wart', 'wars', 'ways']\n", - "['cart', 'wart', 'wars', 'ward']\n", - "['cart', 'wart', 'wars', 'ware']\n", - "['cart', 'wart', 'wars', 'warm']\n", - "['cart', 'wart', 'wars', 'warn']\n", - "['cart', 'wart', 'wars', 'warp']\n", - "['cart', 'wart', 'wars', 'wary']\n", - "['cart', 'wart', 'wary', 'nary']\n", - "['cart', 'wart', 'wary', 'vary']\n", - "['cart', 'wart', 'wary', 'wiry']\n", - "['cart', 'wart', 'wary', 'wavy']\n", - "['cart', 'wart', 'wary', 'waxy']\n", - "['cart', 'wart', 'wary', 'ward']\n", - "['cart', 'wart', 'wary', 'ware']\n", - "['cart', 'wart', 'wary', 'warm']\n", - "['cart', 'wart', 'wary', 'warn']\n", - "['cart', 'wart', 'wary', 'warp']\n", - "['cart', 'wart', 'wary', 'wars']\n", - "['cart', 'curt', 'hurt', 'hart']\n", - "['cart', 'curt', 'hurt', 'hunt']\n", - "['cart', 'curt', 'hurt', 'hurl']\n", - "['cart', 'curt', 'cult', 'colt']\n", - "['cart', 'curt', 'cult', 'cull']\n", - "['cart', 'curt', 'curb', 'curd']\n", - "['cart', 'curt', 'curb', 'cure']\n", - "['cart', 'curt', 'curb', 'curl']\n", - "['cart', 'curt', 'curb', 'curs']\n", - "['cart', 'curt', 'curd', 'turd']\n", - "['cart', 'curt', 'curd', 'card']\n", - "['cart', 'curt', 'curd', 'cord']\n", - "['cart', 'curt', 'curd', 'cued']\n", - "['cart', 'curt', 'curd', 'curb']\n", - "['cart', 'curt', 'curd', 'cure']\n", - "['cart', 'curt', 'curd', 'curl']\n", - "['cart', 'curt', 'curd', 'curs']\n", - "['cart', 'curt', 'cure', 'lure']\n", - "['cart', 'curt', 'cure', 'pure']\n", - "['cart', 'curt', 'cure', 'sure']\n", - "['cart', 'curt', 'cure', 'care']\n", - "['cart', 'curt', 'cure', 'core']\n", - "['cart', 'curt', 'cure', 'cube']\n", - "['cart', 'curt', 'cure', 'cute']\n", - "['cart', 'curt', 'cure', 'curb']\n", - "['cart', 'curt', 'cure', 'curd']\n", - "['cart', 'curt', 'cure', 'curl']\n", - "['cart', 'curt', 'cure', 'curs']\n", - "['cart', 'curt', 'curl', 'furl']\n", - "['cart', 'curt', 'curl', 'hurl']\n", - "['cart', 'curt', 'curl', 'purl']\n", - "['cart', 'curt', 'curl', 'cull']\n", - "['cart', 'curt', 'curl', 'curb']\n", - "['cart', 'curt', 'curl', 'curd']\n", - "['cart', 'curt', 'curl', 'cure']\n", - "['cart', 'curt', 'curl', 'curs']\n", - "['cart', 'curt', 'curs', 'burs']\n", - "['cart', 'curt', 'curs', 'furs']\n", - "['cart', 'curt', 'curs', 'ours']\n", - "['cart', 'curt', 'curs', 'cars']\n", - "['cart', 'curt', 'curs', 'cubs']\n", - "['cart', 'curt', 'curs', 'cuds']\n", - "['cart', 'curt', 'curs', 'cues']\n", - "['cart', 'curt', 'curs', 'cums']\n", - "['cart', 'curt', 'curs', 'cups']\n", - "['cart', 'curt', 'curs', 'cuss']\n", - "['cart', 'curt', 'curs', 'cuts']\n", - "['cart', 'curt', 'curs', 'curb']\n", - "['cart', 'curt', 'curs', 'curd']\n", - "['cart', 'curt', 'curs', 'cure']\n", - "['cart', 'curt', 'curs', 'curl']\n", - "['cart', 'cant', 'pant', 'rant']\n", - "['cart', 'cant', 'pant', 'want']\n", - "['cart', 'cant', 'pant', 'pent']\n", - "['cart', 'cant', 'pant', 'pint']\n", - "['cart', 'cant', 'pant', 'punt']\n", - "['cart', 'cant', 'pant', 'pact']\n", - "['cart', 'cant', 'pant', 'part']\n", - "['cart', 'cant', 'pant', 'past']\n", - "['cart', 'cant', 'pant', 'pane']\n", - "['cart', 'cant', 'pant', 'pang']\n", - "['cart', 'cant', 'pant', 'pans']\n", - "['cart', 'cant', 'rant', 'pant']\n", - "['cart', 'cant', 'rant', 'want']\n", - "['cart', 'cant', 'rant', 'rent']\n", - "['cart', 'cant', 'rant', 'runt']\n", - "['cart', 'cant', 'rant', 'raft']\n", - "['cart', 'cant', 'rant', 'rapt']\n", - "['cart', 'cant', 'rant', 'rang']\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', 'want', 'wont']\n", - "['cart', 'cant', 'want', 'waft']\n", - "['cart', 'cant', 'want', 'wait']\n", - "['cart', 'cant', 'want', 'wart']\n", - "['cart', 'cant', 'want', 'watt']\n", - "['cart', 'cant', 'want', 'wand']\n", - "['cart', 'cant', 'want', 'wane']\n", - "['cart', 'cant', 'cent', 'bent']\n", - "['cart', 'cant', 'cent', 'dent']\n", - "['cart', 'cant', 'cent', 'gent']\n", - "['cart', 'cant', 'cent', 'lent']\n", - "['cart', 'cant', 'cent', 'pent']\n", - "['cart', 'cant', 'cent', 'rent']\n", - "['cart', 'cant', 'cent', 'sent']\n", - "['cart', 'cant', 'cent', 'tent']\n", - "['cart', 'cant', 'cent', 'vent']\n", - "['cart', 'cant', 'cent', 'went']\n", - "['cart', 'cant', 'cast', 'bast']\n", - "['cart', 'cant', 'cast', 'east']\n", - "['cart', 'cant', 'cast', 'fast']\n", - "['cart', 'cant', 'cast', 'last']\n", - "['cart', 'cant', 'cast', 'mast']\n", - "['cart', 'cant', 'cast', 'past']\n", - "['cart', 'cant', 'cast', 'vast']\n", - "['cart', 'cant', 'cast', 'cost']\n", - "['cart', 'cant', 'cast', 'cyst']\n", - "['cart', 'cant', 'cast', 'case']\n", - "['cart', 'cant', 'cast', 'cash']\n", - "['cart', 'cant', 'cast', 'cask']\n", - "['cart', 'cant', 'cane', 'bane']\n", - "['cart', 'cant', 'cane', 'lane']\n", - "['cart', 'cant', 'cane', 'mane']\n", - "['cart', 'cant', 'cane', 'pane']\n", - "['cart', 'cant', 'cane', 'sane']\n", - "['cart', 'cant', 'cane', 'vane']\n", - "['cart', 'cant', 'cane', 'wane']\n", - "['cart', 'cant', 'cane', 'cone']\n", - "['cart', 'cant', 'cane', 'cafe']\n", - "['cart', 'cant', 'cane', 'cage']\n", - "['cart', 'cant', 'cane', 'cake']\n", - "['cart', 'cant', 'cane', 'came']\n", - "['cart', 'cant', 'cane', 'cape']\n", - "['cart', 'cant', 'cane', 'care']\n", - "['cart', 'cant', 'cane', 'case']\n", - "['cart', 'cant', 'cane', 'cave']\n", - "['cart', 'cant', 'cane', 'cans']\n", - "['cart', 'cant', 'cans', 'bans']\n", - "['cart', 'cant', 'cans', 'fans']\n", - "['cart', 'cant', 'cans', 'mans']\n", - "['cart', 'cant', 'cans', 'pans']\n", - "['cart', 'cant', 'cans', 'sans']\n", - "['cart', 'cant', 'cans', 'tans']\n", - "['cart', 'cant', 'cans', 'vans']\n" + "['cart', 'hart', 'harp', 'hasp']\n", + "['cart', 'hart', 'harp', 'carp']\n", + "['cart', 'hart', 'dart', 'dirt']\n", + "['cart', 'hart', 'dart', 'daft']\n", + "['cart', 'hart', 'dart', 'dark']\n", + "['cart', 'hart', 'dart', 'wart']\n", + "['cart', 'hart', 'dart', 'mart']\n", + "['cart', 'hart', 'dart', 'dare']\n", + "['cart', 'hart', 'dart', 'darn']\n", + "['cart', 'hart', 'dart', 'tart']\n", + "['cart', 'hart', 'dart', 'part']\n", + "['cart', 'hart', 'part', 'port']\n", + "['cart', 'hart', 'part', 'pact']\n", + "['cart', 'hart', 'part', 'pert']\n", + "['cart', 'hart', 'part', 'pare']\n", + "['cart', 'hart', 'part', 'past']\n", + "['cart', 'hart', 'part', 'mart']\n", + "['cart', 'hart', 'part', 'wart']\n", + "['cart', 'hart', 'part', 'pars']\n", + "['cart', 'hart', 'part', 'dart']\n", + "['cart', 'hart', 'part', 'tart']\n", + "['cart', 'hart', 'part', 'park']\n", + "['cart', 'hart', 'part', 'pant']\n", + "['cart', 'cars', 'bars', 'barb']\n", + "['cart', 'cars', 'bars', 'bard']\n", + "['cart', 'cars', 'bars', 'ears']\n", + "['cart', 'cars', 'bars', 'bass']\n", + "['cart', 'cars', 'bars', 'burs']\n", + "['cart', 'cars', 'bars', 'mars']\n", + "['cart', 'cars', 'bars', 'bays']\n", + "['cart', 'cars', 'bars', 'baas']\n", + "['cart', 'cars', 'bars', 'bark']\n", + "['cart', 'cars', 'bars', 'bags']\n", + "['cart', 'cars', 'bars', 'bans']\n", + "['cart', 'cars', 'bars', 'oars']\n", + "['cart', 'cars', 'bars', 'pars']\n", + "['cart', 'cars', 'bars', 'tars']\n", + "['cart', 'cars', 'bars', 'wars']\n", + "['cart', 'cars', 'bars', 'barn']\n", + "['cart', 'cars', 'bars', 'bats']\n", + "['cart', 'cars', 'bars', 'bare']\n", + "['cart', 'cars', 'bars', 'barf']\n", + "['cart', 'cars', 'bars', 'jars']\n", + "['cart', 'cars', 'ears', 'bars']\n", + "['cart', 'cars', 'ears', 'eats']\n", + "['cart', 'cars', 'ears', 'wars']\n", + "['cart', 'cars', 'ears', 'earl']\n", + "['cart', 'cars', 'ears', 'oars']\n", + "['cart', 'cars', 'ears', 'pars']\n", + "['cart', 'cars', 'ears', 'tars']\n", + "['cart', 'cars', 'ears', 'errs']\n", + "['cart', 'cars', 'ears', 'earn']\n", + "['cart', 'cars', 'ears', 'mars']\n", + "['cart', 'cars', 'ears', 'jars']\n", + "['cart', 'cars', 'caps', 'maps']\n", + "['cart', 'cars', 'caps', 'taps']\n", + "['cart', 'cars', 'caps', 'laps']\n", + "['cart', 'cars', 'caps', 'cape']\n", + "['cart', 'cars', 'caps', 'saps']\n", + "['cart', 'cars', 'caps', 'cops']\n", + "['cart', 'cars', 'caps', 'cabs']\n", + "['cart', 'cars', 'caps', 'cups']\n", + "['cart', 'cars', 'caps', 'naps']\n", + "['cart', 'cars', 'caps', 'raps']\n", + "['cart', 'cars', 'caps', 'cams']\n", + "['cart', 'cars', 'caps', 'cats']\n", + "['cart', 'cars', 'caps', 'yaps']\n", + "['cart', 'cars', 'caps', 'caws']\n", + "['cart', 'cars', 'caps', 'cads']\n", + "['cart', 'cars', 'caps', 'cans']\n", + "['cart', 'cars', 'caps', 'zaps']\n", + "['cart', 'cars', 'caps', 'paps']\n", + "['cart', 'cars', 'caps', 'gaps']\n", + "['cart', 'cars', 'wars', 'bars']\n", + "['cart', 'cars', 'wars', 'wary']\n", + "['cart', 'cars', 'wars', 'ears']\n", + "['cart', 'cars', 'wars', 'warn']\n", + "['cart', 'cars', 'wars', 'warm']\n", + "['cart', 'cars', 'wars', 'warp']\n", + "['cart', 'cars', 'wars', 'wart']\n", + "['cart', 'cars', 'wars', 'oars']\n", + "['cart', 'cars', 'wars', 'pars']\n", + "['cart', 'cars', 'wars', 'tars']\n", + "['cart', 'cars', 'wars', 'wags']\n", + "['cart', 'cars', 'wars', 'ways']\n", + "['cart', 'cars', 'wars', 'wads']\n", + "['cart', 'cars', 'wars', 'ware']\n", + "['cart', 'cars', 'wars', 'mars']\n", + "['cart', 'cars', 'wars', 'ward']\n", + "['cart', 'cars', 'wars', 'jars']\n", + "['cart', 'cars', 'cabs', 'cubs']\n", + "['cart', 'cars', 'cabs', 'labs']\n", + "['cart', 'cars', 'cabs', 'caps']\n", + "['cart', 'cars', 'cabs', 'cobs']\n", + "['cart', 'cars', 'cabs', 'jabs']\n", + "['cart', 'cars', 'cabs', 'cams']\n", + "['cart', 'cars', 'cabs', 'cats']\n", + "['cart', 'cars', 'cabs', 'caws']\n", + "['cart', 'cars', 'cabs', 'tabs']\n", + "['cart', 'cars', 'cabs', 'nabs']\n", + "['cart', 'cars', 'cabs', 'dabs']\n", + "['cart', 'cars', 'cabs', 'cads']\n", + "['cart', 'cars', 'cabs', 'cans']\n", + "['cart', 'cars', 'cabs', 'gabs']\n", + "['cart', 'cars', 'oars', 'bars']\n", + "['cart', 'cars', 'oars', 'ears']\n", + "['cart', 'cars', 'oars', 'oaks']\n", + "['cart', 'cars', 'oars', 'oafs']\n", + "['cart', 'cars', 'oars', 'wars']\n", + "['cart', 'cars', 'oars', 'oats']\n", + "['cart', 'cars', 'oars', 'pars']\n", + "['cart', 'cars', 'oars', 'tars']\n", + "['cart', 'cars', 'oars', 'ours']\n", + "['cart', 'cars', 'oars', 'mars']\n", + "['cart', 'cars', 'oars', 'jars']\n", + "['cart', 'cars', 'pars', 'pats']\n", + "['cart', 'cars', 'pars', 'bars']\n", + "['cart', 'cars', 'pars', 'ears']\n", + "['cart', 'cars', 'pars', 'pals']\n", + "['cart', 'cars', 'pars', 'pans']\n", + "['cart', 'cars', 'pars', 'mars']\n", + "['cart', 'cars', 'pars', 'pass']\n", + "['cart', 'cars', 'pars', 'paws']\n", + "['cart', 'cars', 'pars', 'pare']\n", + "['cart', 'cars', 'pars', 'wars']\n", + "['cart', 'cars', 'pars', 'oars']\n", + "['cart', 'cars', 'pars', 'tars']\n", + "['cart', 'cars', 'pars', 'paps']\n", + "['cart', 'cars', 'pars', 'pays']\n", + "['cart', 'cars', 'pars', 'park']\n", + "['cart', 'cars', 'pars', 'part']\n", + "['cart', 'cars', 'pars', 'jars']\n", + "['cart', 'cars', 'pars', 'pads']\n", + "['cart', 'cars', 'tars', 'tags']\n", + "['cart', 'cars', 'tars', 'bars']\n", + "['cart', 'cars', 'tars', 'tads']\n", + "['cart', 'cars', 'tars', 'ears']\n", + "['cart', 'cars', 'tars', 'taps']\n", + "['cart', 'cars', 'tars', 'tare']\n", + "['cart', 'cars', 'tars', 'tans']\n", + "['cart', 'cars', 'tars', 'tors']\n", + "['cart', 'cars', 'tars', 'oars']\n", + "['cart', 'cars', 'tars', 'pars']\n", + "['cart', 'cars', 'tars', 'tats']\n", + "['cart', 'cars', 'tars', 'tams']\n", + "['cart', 'cars', 'tars', 'tabs']\n", + "['cart', 'cars', 'tars', 'tart']\n", + "['cart', 'cars', 'tars', 'tarp']\n", + "['cart', 'cars', 'tars', 'wars']\n", + "['cart', 'cars', 'tars', 'mars']\n", + "['cart', 'cars', 'tars', 'taro']\n", + "['cart', 'cars', 'tars', 'jars']\n", + "['cart', 'cars', 'card', 'hard']\n", + "['cart', 'cars', 'card', 'bard']\n", + "['cart', 'cars', 'card', 'lard']\n", + "['cart', 'cars', 'card', 'curd']\n", + "['cart', 'cars', 'card', 'carp']\n", + "['cart', 'cars', 'card', 'care']\n", + "['cart', 'cars', 'card', 'yard']\n", + "['cart', 'cars', 'card', 'ward']\n", + "['cart', 'cars', 'card', 'cord']\n", + "['cart', 'cars', 'cams', 'came']\n", + "['cart', 'cars', 'cams', 'rams']\n", + "['cart', 'cars', 'cams', 'jams']\n", + "['cart', 'cars', 'cams', 'caps']\n", + "['cart', 'cars', 'cams', 'cums']\n", + "['cart', 'cars', 'cams', 'lams']\n", + "['cart', 'cars', 'cams', 'tams']\n", + "['cart', 'cars', 'cams', 'camp']\n", + "['cart', 'cars', 'cams', 'cabs']\n", + "['cart', 'cars', 'cams', 'dams']\n", + "['cart', 'cars', 'cams', 'cats']\n", + "['cart', 'cars', 'cams', 'caws']\n", + "['cart', 'cars', 'cams', 'cads']\n", + "['cart', 'cars', 'cams', 'hams']\n", + "['cart', 'cars', 'cams', 'cans']\n", + "['cart', 'cars', 'cams', 'yams']\n", + "['cart', 'cars', 'caws', 'saws']\n", + "['cart', 'cars', 'caws', 'maws']\n", + "['cart', 'cars', 'caws', 'haws']\n", + "['cart', 'cars', 'caws', 'caps']\n", + "['cart', 'cars', 'caws', 'paws']\n", + "['cart', 'cars', 'caws', 'laws']\n", + "['cart', 'cars', 'caws', 'cows']\n", + "['cart', 'cars', 'caws', 'cabs']\n", + "['cart', 'cars', 'caws', 'cams']\n", + "['cart', 'cars', 'caws', 'cats']\n", + "['cart', 'cars', 'caws', 'cads']\n", + "['cart', 'cars', 'caws', 'cans']\n", + "['cart', 'cars', 'caws', 'yaws']\n", + "['cart', 'cars', 'caws', 'jaws']\n", + "['cart', 'cars', 'cats', 'cots']\n", + "['cart', 'cars', 'cats', 'eats']\n", + "['cart', 'cars', 'cats', 'hats']\n", + "['cart', 'cars', 'cats', 'caps']\n", + "['cart', 'cars', 'cats', 'rats']\n", + "['cart', 'cars', 'cats', 'cuts']\n", + "['cart', 'cars', 'cats', 'fats']\n", + "['cart', 'cars', 'cats', 'vats']\n", + "['cart', 'cars', 'cats', 'cabs']\n", + "['cart', 'cars', 'cats', 'oats']\n", + "['cart', 'cars', 'cats', 'tats']\n", + "['cart', 'cars', 'cats', 'cams']\n", + "['cart', 'cars', 'cats', 'caws']\n", + "['cart', 'cars', 'cats', 'cads']\n", + "['cart', 'cars', 'cats', 'mats']\n", + "['cart', 'cars', 'cats', 'bats']\n", + "['cart', 'cars', 'cats', 'cans']\n", + "['cart', 'cars', 'cats', 'lats']\n", + "['cart', 'cars', 'cats', 'pats']\n", + "['cart', 'cars', 'cads', 'tads']\n", + "['cart', 'cars', 'cads', 'cods']\n", + "['cart', 'cars', 'cads', 'caps']\n", + "['cart', 'cars', 'cads', 'fads']\n", + "['cart', 'cars', 'cads', 'dads']\n", + "['cart', 'cars', 'cads', 'mads']\n", + "['cart', 'cars', 'cads', 'lads']\n", + "['cart', 'cars', 'cads', 'cuds']\n", + "['cart', 'cars', 'cads', 'cabs']\n", + "['cart', 'cars', 'cads', 'cams']\n", + "['cart', 'cars', 'cads', 'wads']\n", + "['cart', 'cars', 'cads', 'cats']\n", + "['cart', 'cars', 'cads', 'caws']\n", + "['cart', 'cars', 'cads', 'cans']\n", + "['cart', 'cars', 'cads', 'gads']\n", + "['cart', 'cars', 'cads', 'pads']\n", + "['cart', 'cars', 'care', 'came']\n", + "['cart', 'cars', 'care', 'hare']\n", + "['cart', 'cars', 'care', 'cure']\n", + "['cart', 'cars', 'care', 'card']\n", + "['cart', 'cars', 'care', 'core']\n", + "['cart', 'cars', 'care', 'cafe']\n", + "['cart', 'cars', 'care', 'fare']\n", + "['cart', 'cars', 'care', 'case']\n", + "['cart', 'cars', 'care', 'cane']\n", + "['cart', 'cars', 'care', 'bare']\n", + "['cart', 'cars', 'care', 'cage']\n", + "['cart', 'cars', 'care', 'carp']\n", + "['cart', 'cars', 'care', 'cave']\n", + "['cart', 'cars', 'care', 'cape']\n", + "['cart', 'cars', 'care', 'pare']\n", + "['cart', 'cars', 'care', 'ware']\n", + "['cart', 'cars', 'care', 'mare']\n", + "['cart', 'cars', 'care', 'cake']\n", + "['cart', 'cars', 'care', 'rare']\n", + "['cart', 'cars', 'care', 'tare']\n", + "['cart', 'cars', 'care', 'dare']\n", + "['cart', 'cars', 'cans', 'vans']\n" ] }, { "data": { "text/plain": [ - "['cart', 'cant', 'cans', 'vans']" + "['cart', 'cars', 'cans', 'vans']" ] }, - "execution_count": 20, + "execution_count": 48, "metadata": {}, "output_type": "execute_result" } @@ -1568,16 +1050,16 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 49, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['cart', 'cant', 'cane', 'vane']" + "['cart', 'care', 'cane', 'vane']" ] }, - "execution_count": 21, + "execution_count": 49, "metadata": {}, "output_type": "execute_result" } @@ -1588,604 +1070,27 @@ }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 51, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['cart',\n", - " 'dart',\n", - " 'hart',\n", - " 'mart',\n", - " 'part',\n", - " 'tart',\n", - " 'wart',\n", - " 'waft',\n", - " 'daft',\n", - " 'haft',\n", - " 'raft',\n", - " 'rift',\n", - " 'gift',\n", - " 'lift',\n", - " 'sift',\n", - " 'soft',\n", - " 'loft',\n", - " 'left',\n", - " 'deft',\n", - " 'heft',\n", - " 'weft',\n", - " 'welt',\n", - " 'belt',\n", - " 'felt',\n", - " 'gelt',\n", - " 'melt',\n", - " 'pelt',\n", - " 'peat',\n", - " 'beat',\n", - " 'feat',\n", - " 'heat',\n", - " 'meat',\n", - " 'neat',\n", - " 'seat',\n", - " 'teat',\n", - " 'that',\n", - " 'chat',\n", - " 'shat',\n", - " 'what',\n", - " 'whet',\n", - " 'whit',\n", - " 'chit',\n", - " 'chic',\n", - " 'chid',\n", - " 'chin',\n", - " 'shin',\n", - " 'thin',\n", - " 'twin',\n", - " 'twig',\n", - " 'swig',\n", - " 'swag',\n", - " 'shag',\n", - " 'slag',\n", - " 'flag',\n", - " 'flog',\n", - " 'blog',\n", - " 'clog',\n", - " 'slog',\n", - " 'smog',\n", - " 'smug',\n", - " 'slug',\n", - " 'plug',\n", - " 'plum',\n", - " 'alum',\n", - " 'glum',\n", - " 'slum',\n", - " 'scum',\n", - " 'swum',\n", - " 'swam',\n", - " 'scam',\n", - " 'seam',\n", - " 'beam',\n", - " 'ream',\n", - " 'team',\n", - " 'tram',\n", - " 'cram',\n", - " 'dram',\n", - " 'gram',\n", - " 'pram',\n", - " 'prim',\n", - " 'brim',\n", - " 'grim',\n", - " 'trim',\n", - " 'trig',\n", - " 'brig',\n", - " 'brag',\n", - " 'crag',\n", - " 'drag',\n", - " 'drug',\n", - " 'drub',\n", - " 'grub',\n", - " 'grab',\n", - " 'crab',\n", - " 'drab',\n", - " 'draw',\n", - " 'craw',\n", - " 'claw',\n", - " 'flaw',\n", - " 'slaw',\n", - " 'slew',\n", - " 'blew',\n", - " 'clew',\n", - " 'flew',\n", - " 'flow',\n", - " 'blow',\n", - " 'glow',\n", - " 'slow',\n", - " 'scow',\n", - " 'show',\n", - " 'chow',\n", - " 'crow',\n", - " 'brow',\n", - " 'grow',\n", - " 'prow',\n", - " 'prod',\n", - " 'trod',\n", - " 'trot',\n", - " 'toot',\n", - " 'boot',\n", - " 'coot',\n", - " 'foot',\n", - " 'hoot',\n", - " 'loot',\n", - " 'moot',\n", - " 'root',\n", - " 'soot',\n", - " 'shot',\n", - " 'slot',\n", - " 'blot',\n", - " 'clot',\n", - " 'plot',\n", - " 'plod',\n", - " 'clod',\n", - " 'clad',\n", - " 'glad',\n", - " 'goad',\n", - " 'load',\n", - " 'road',\n", - " 'toad',\n", - " 'toed',\n", - " 'coed',\n", - " 'hoed',\n", - " 'heed',\n", - " 'deed',\n", - " 'feed',\n", - " 'geed',\n", - " 'need',\n", - " 'peed',\n", - " 'reed',\n", - " 'seed',\n", - " 'teed',\n", - " 'weed',\n", - " 'weld',\n", - " 'geld',\n", - " 'held',\n", - " 'meld',\n", - " 'veld',\n", - " 'vend',\n", - " 'bend',\n", - " 'fend',\n", - " 'lend',\n", - " 'mend',\n", - " 'rend',\n", - " 'send',\n", - " 'tend',\n", - " 'wend',\n", - " 'wand',\n", - " 'band',\n", - " 'hand',\n", - " 'land',\n", - " 'sand',\n", - " 'said',\n", - " 'laid',\n", - " 'maid',\n", - " 'paid',\n", - " 'raid',\n", - " 'rail',\n", - " 'bail',\n", - " 'fail',\n", - " 'hail',\n", - " 'jail',\n", - " 'mail',\n", - " 'nail',\n", - " 'pail',\n", - " 'sail',\n", - " 'tail',\n", - " 'wail',\n", - " 'wall',\n", - " 'ball',\n", - " 'call',\n", - " 'fall',\n", - " 'gall',\n", - " 'hall',\n", - " 'mall',\n", - " 'pall',\n", - " 'tall',\n", - " 'tell',\n", - " 'bell',\n", - " 'cell',\n", - " 'dell',\n", - " 'fell',\n", - " 'hell',\n", - " 'jell',\n", - " 'sell',\n", - " 'well',\n", - " 'yell',\n", - " 'yelp',\n", - " 'help',\n", - " 'kelp',\n", - " 'keep',\n", - " 'beep',\n", - " 'deep',\n", - " 'jeep',\n", - " 'peep',\n", - " 'seep',\n", - " 'veep',\n", - " 'weep',\n", - " 'week',\n", - " 'geek',\n", - " 'leek',\n", - " 'meek',\n", - " 'peek',\n", - " 'reek',\n", - " 'seek',\n", - " 'seem',\n", - " 'deem',\n", - " 'teem',\n", - " 'them',\n", - " 'thee',\n", - " 'tree',\n", - " 'free',\n", - " 'flee',\n", - " 'glee',\n", - " 'glue',\n", - " 'blue',\n", - " 'clue',\n", - " 'flue',\n", - " 'slue',\n", - " 'sloe',\n", - " 'aloe',\n", - " 'floe',\n", - " 'flop',\n", - " 'clop',\n", - " 'glop',\n", - " 'plop',\n", - " 'slop',\n", - " 'shop',\n", - " 'chop',\n", - " 'coop',\n", - " 'goop',\n", - " 'hoop',\n", - " 'loop',\n", - " 'poop',\n", - " 'prop',\n", - " 'crop',\n", - " 'drop',\n", - " 'drip',\n", - " 'grip',\n", - " 'trip',\n", - " 'trap',\n", - " 'tray',\n", - " 'bray',\n", - " 'dray',\n", - " 'fray',\n", - " 'gray',\n", - " 'pray',\n", - " 'play',\n", - " 'clay',\n", - " 'flay',\n", - " 'slay',\n", - " 'spay',\n", - " 'stay',\n", - " 'sway',\n", - " 'away',\n", - " 'awry',\n", - " 'aery',\n", - " 'eery',\n", - " 'very',\n", - " 'vary',\n", - " 'nary',\n", - " 'wary',\n", - " 'wiry',\n", - " 'airy',\n", - " 'airs',\n", - " 'firs',\n", - " 'sirs',\n", - " 'sics',\n", - " 'tics',\n", - " 'ties',\n", - " 'dies',\n", - " 'hies',\n", - " 'lies',\n", - " 'pies',\n", - " 'vies',\n", - " 'vied',\n", - " 'died',\n", - " 'hied',\n", - " 'lied',\n", - " 'pied',\n", - " 'tied',\n", - " 'tier',\n", - " 'bier',\n", - " 'pier',\n", - " 'peer',\n", - " 'beer',\n", - " 'deer',\n", - " 'jeer',\n", - " 'leer',\n", - " 'seer',\n", - " 'veer',\n", - " 'weer',\n", - " 'wear',\n", - " 'bear',\n", - " 'dear',\n", - " 'fear',\n", - " 'gear',\n", - " 'hear',\n", - " 'near',\n", - " 'pear',\n", - " 'rear',\n", - " 'sear',\n", - " 'tear',\n", - " 'year',\n", - " 'yeah',\n", - " 'yeas',\n", - " 'leas',\n", - " 'peas',\n", - " 'seas',\n", - " 'teas',\n", - " 'tees',\n", - " 'bees',\n", - " 'fees',\n", - " 'gees',\n", - " 'lees',\n", - " 'pees',\n", - " 'sees',\n", - " 'wees',\n", - " 'woes',\n", - " 'does',\n", - " 'foes',\n", - " 'goes',\n", - " 'hoes',\n", - " 'noes',\n", - " 'roes',\n", - " 'toes',\n", - " 'togs',\n", - " 'bogs',\n", - " 'cogs',\n", - " 'dogs',\n", - " 'fogs',\n", - " 'hogs',\n", - " 'jogs',\n", - " 'logs',\n", - " 'lags',\n", - " 'bags',\n", - " 'fags',\n", - " 'gags',\n", - " 'hags',\n", - " 'jags',\n", - " 'nags',\n", - " 'rags',\n", - " 'sags',\n", - " 'tags',\n", - " 'wags',\n", - " 'wigs',\n", - " 'digs',\n", - " 'figs',\n", - " 'gigs',\n", - " 'jigs',\n", - " 'pigs',\n", - " 'rigs',\n", - " 'rugs',\n", - " 'bugs',\n", - " 'hugs',\n", - " 'jugs',\n", - " 'lugs',\n", - " 'mugs',\n", - " 'pugs',\n", - " 'tugs',\n", - " 'tubs',\n", - " 'cubs',\n", - " 'dubs',\n", - " 'hubs',\n", - " 'nubs',\n", - " 'pubs',\n", - " 'rubs',\n", - " 'subs',\n", - " 'sobs',\n", - " 'bobs',\n", - " 'cobs',\n", - " 'fobs',\n", - " 'gobs',\n", - " 'hobs',\n", - " 'jobs',\n", - " 'lobs',\n", - " 'mobs',\n", - " 'robs',\n", - " 'ribs',\n", - " 'bibs',\n", - " 'fibs',\n", - " 'jibs',\n", - " 'nibs',\n", - " 'nabs',\n", - " 'cabs',\n", - " 'dabs',\n", - " 'gabs',\n", - " 'jabs',\n", - " 'labs',\n", - " 'tabs',\n", - " 'tads',\n", - " 'cads',\n", - " 'dads',\n", - " 'fads',\n", - " 'gads',\n", - " 'lads',\n", - " 'mads',\n", - " 'pads',\n", - " 'wads',\n", - " 'weds',\n", - " 'beds',\n", - " 'feds',\n", - " 'reds',\n", - " 'rids',\n", - " 'aids',\n", - " 'bids',\n", - " 'kids',\n", - " 'lids',\n", - " 'lips',\n", - " 'dips',\n", - " 'hips',\n", - " 'nips',\n", - " 'pips',\n", - " 'rips',\n", - " 'sips',\n", - " 'tips',\n", - " 'yips',\n", - " 'zips',\n", - " 'zaps',\n", - " 'caps',\n", - " 'gaps',\n", - " 'laps',\n", - " 'maps',\n", - " 'naps',\n", - " 'paps',\n", - " 'raps',\n", - " 'saps',\n", - " 'taps',\n", - " 'yaps',\n", - " 'yeps',\n", - " 'peps',\n", - " 'reps',\n", - " 'refs',\n", - " 'reis',\n", - " 'leis',\n", - " 'legs',\n", - " 'begs',\n", - " 'kegs',\n", - " 'megs',\n", - " 'pegs',\n", - " 'pens',\n", - " 'dens',\n", - " 'fens',\n", - " 'hens',\n", - " 'kens',\n", - " 'lens',\n", - " 'tens',\n", - " 'wens',\n", - " 'yens',\n", - " 'yews',\n", - " 'hews',\n", - " 'mews',\n", - " 'news',\n", - " 'pews',\n", - " 'sews',\n", - " 'saws',\n", - " 'caws',\n", - " 'haws',\n", - " 'jaws',\n", - " 'laws',\n", - " 'maws',\n", - " 'paws',\n", - " 'yaws',\n", - " 'yaks',\n", - " 'oaks',\n", - " 'oafs',\n", - " 'oars',\n", - " 'bars',\n", - " 'cars',\n", - " 'ears',\n", - " 'jars',\n", - " 'mars',\n", - " 'pars',\n", - " 'tars',\n", - " 'wars',\n", - " 'ways',\n", - " 'bays',\n", - " 'days',\n", - " 'gays',\n", - " 'hays',\n", - " 'jays',\n", - " 'lays',\n", - " 'nays',\n", - " 'pays',\n", - " 'rays',\n", - " 'says',\n", - " 'sacs',\n", - " 'secs',\n", - " 'sets',\n", - " 'bets',\n", - " 'gets',\n", - " 'jets',\n", - " 'lets',\n", - " 'nets',\n", - " 'pets',\n", - " 'vets',\n", - " 'wets',\n", - " 'wits',\n", - " 'bits',\n", - " 'fits',\n", - " 'hits',\n", - " 'kits',\n", - " 'nits',\n", - " 'pits',\n", - " 'sits',\n", - " 'tits',\n", - " 'tats',\n", - " 'bats',\n", - " 'cats',\n", - " 'eats',\n", - " 'fats',\n", - " 'hats',\n", - " 'lats',\n", - " 'mats',\n", - " 'oats',\n", - " 'pats',\n", - " 'rats',\n", - " 'vats',\n", - " 'vans',\n", - " 'bans',\n", - " 'cans',\n", - " 'fans',\n", - " 'mans',\n", - " 'pans',\n", - " 'sans',\n", - " 'tans',\n", - " 'tins',\n", - " 'bins',\n", - " 'dins',\n", - " 'fins',\n", - " 'gins',\n", - " 'pins',\n", - " 'sins',\n", - " 'wins',\n", - " 'wind',\n", - " 'bind',\n", - " 'find',\n", - " 'hind',\n", - " 'kind',\n", - " 'mind',\n", - " 'rind',\n", - " 'ring',\n", - " 'ding',\n", - " 'king',\n", - " 'ping',\n", - " 'sing',\n", - " 'ting',\n", - " 'wing',\n", - " 'wine',\n", - " 'dine',\n", - " 'fine',\n", - " 'line',\n", - " 'mine',\n", - " 'nine',\n", - " 'pine',\n", - " 'sine',\n", - " 'tine',\n", - " 'vine',\n", - " 'vane']" + "1494" ] }, - "execution_count": 22, + "execution_count": 51, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "dfs_search('cart', 'vane')" + "len(dfs_search('cart', 'vane'))" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 52, "metadata": { "collapsed": true }, @@ -2213,7 +1118,7 @@ }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 53, "metadata": {}, "outputs": [ { @@ -2232,7 +1137,7 @@ "['cart', 'cant', 'cane', 'vane']" ] }, - "execution_count": 24, + "execution_count": 53, "metadata": {}, "output_type": "execute_result" } @@ -2243,7 +1148,7 @@ }, { "cell_type": "code", - "execution_count": 81, + "execution_count": 54, "metadata": { "collapsed": true }, @@ -2273,7 +1178,7 @@ }, { "cell_type": "code", - "execution_count": 26, + "execution_count": 55, "metadata": {}, "outputs": [ { @@ -2292,7 +1197,7 @@ "['cart', 'cant', 'cane', 'vane']" ] }, - "execution_count": 26, + "execution_count": 55, "metadata": {}, "output_type": "execute_result" } @@ -2312,22 +1217,22 @@ }, { "cell_type": "code", - "execution_count": 27, - "metadata": {}, + "execution_count": 69, + "metadata": { + "scrolled": true + }, "outputs": [ { - "data": { - "text/plain": [ - "94" - ] - }, - "execution_count": 27, - "metadata": {}, - "output_type": "execute_result" + "name": "stdout", + "output_type": "stream", + "text": [ + "10 loops, best of 3: 23.9 ms per loop\n" + ] } ], "source": [ - "candidates = [set([k] + neighbours[k]) for k in neighbours]\n", + "%%timeit\n", + "candidates = [set([k] + list(neighbours[k])) for k in neighbours]\n", "reachables = []\n", "while candidates:\n", " current = set(candidates.pop())\n", @@ -2347,7 +1252,41 @@ }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 71, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10 loops, best of 3: 25.9 ms per loop\n" + ] + } + ], + "source": [ + "%%timeit\n", + "candidates = set(frozenset({k}.union(neighbours[k])) for k in neighbours)\n", + "reachables = set()\n", + "while candidates:\n", + " current = set(candidates.pop())\n", + " remove_because_merged = set()\n", + " for other in candidates:\n", + " if current.intersection(other):\n", + " current.update(other)\n", + " remove_because_merged.add(other)\n", + " if remove_because_merged:\n", + " for rbm in remove_because_merged:\n", + " candidates.remove(rbm)\n", + " candidates.add(frozenset(current))\n", + " else:\n", + " reachables.add(frozenset(current))\n", + "\n", + "len(reachables)" + ] + }, + { + "cell_type": "code", + "execution_count": 72, "metadata": {}, "outputs": [ { @@ -2356,7 +1295,7 @@ "2204" ] }, - "execution_count": 28, + "execution_count": 72, "metadata": {}, "output_type": "execute_result" } @@ -2367,7 +1306,7 @@ }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 73, "metadata": {}, "outputs": [ { @@ -2376,7 +1315,7 @@ "1" ] }, - "execution_count": 29, + "execution_count": 73, "metadata": {}, "output_type": "execute_result" } @@ -2387,7 +1326,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 74, "metadata": { "scrolled": true }, @@ -2398,7 +1337,7 @@ "Counter({1: 75, 2: 6, 3: 7, 4: 2, 5: 2, 6: 1, 2204: 1})" ] }, - "execution_count": 30, + "execution_count": 74, "metadata": {}, "output_type": "execute_result" } @@ -2409,7 +1348,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 75, "metadata": {}, "outputs": [ { @@ -2418,7 +1357,7 @@ "[5]" ] }, - "execution_count": 31, + "execution_count": 75, "metadata": {}, "output_type": "execute_result" } @@ -2429,16 +1368,16 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 76, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "[{'abbe', 'able', 'ably', 'ally', 'axle'}]" + "[frozenset({'abbe', 'able', 'ably', 'ally', 'axle'})]" ] }, - "execution_count": 32, + "execution_count": 76, "metadata": {}, "output_type": "execute_result" } @@ -2449,7 +1388,7 @@ }, { "cell_type": "code", - "execution_count": 76, + "execution_count": 77, "metadata": { "scrolled": true }, @@ -2457,27 +1396,27 @@ { "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'}]" + "[frozenset({'bevy', 'levy'}),\n", + " frozenset({'ogle', 'ogre'}),\n", + " frozenset({'demo', 'memo'}),\n", + " frozenset({'crud', 'crux'}),\n", + " frozenset({'thou', 'thru'}),\n", + " frozenset({'idol', 'idyl'}),\n", + " frozenset({'icon', 'ikon', 'iron'}),\n", + " frozenset({'used', 'user', 'uses'}),\n", + " frozenset({'opal', 'oral', 'oval'}),\n", + " frozenset({'also', 'alto', 'auto'}),\n", + " frozenset({'idle', 'idly', 'isle'}),\n", + " frozenset({'afar', 'agar', 'ajar'}),\n", + " frozenset({'eddy', 'edge', 'edgy'}),\n", + " frozenset({'each', 'etch', 'inch', 'itch'}),\n", + " frozenset({'high', 'nigh', 'sigh', 'sign'}),\n", + " frozenset({'info', 'into', 'onto', 'undo', 'unto'}),\n", + " frozenset({'abbe', 'able', 'ably', 'ally', 'axle'}),\n", + " frozenset({'ache', 'achy', 'acme', 'acne', 'acre', 'ashy'})]" ] }, - "execution_count": 76, + "execution_count": 77, "metadata": {}, "output_type": "execute_result" } @@ -2488,7 +1427,7 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": 78, "metadata": {}, "outputs": [ { @@ -2497,7 +1436,7 @@ "'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, + "execution_count": 78, "metadata": {}, "output_type": "execute_result" } @@ -2508,7 +1447,89 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 120, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "['ache'] [['ache']]\n", + "['ache', 'acne'] [['ache', 'acne'], ['ache', 'acme'], ['ache', 'acre'], ['ache', 'achy']]\n", + "['ache', 'acme'] [['ache', 'acme'], ['ache', 'acre'], ['ache', 'achy'], ['ache', 'acne', 'acme'], ['ache', 'acne', 'acre']]\n", + "['ache', 'acre'] [['ache', 'acre'], ['ache', 'achy'], ['ache', 'acne', 'acme'], ['ache', 'acne', 'acre'], ['ache', 'acme', 'acne'], ['ache', 'acme', 'acre']]\n", + "['ache', 'achy'] [['ache', 'achy'], ['ache', 'acne', 'acme'], ['ache', 'acne', 'acre'], ['ache', 'acme', 'acne'], ['ache', 'acme', 'acre'], ['ache', 'acre', 'acne'], ['ache', 'acre', 'acme']]\n", + "['ache', 'acne', 'acme'] [['ache', 'acne', 'acme'], ['ache', 'acne', 'acre'], ['ache', 'acme', 'acne'], ['ache', 'acme', 'acre'], ['ache', 'acre', 'acne'], ['ache', 'acre', 'acme'], ['ache', 'achy', 'ashy']]\n", + "['ache', 'acne', 'acre'] [['ache', 'acne', 'acre'], ['ache', 'acme', 'acne'], ['ache', 'acme', 'acre'], ['ache', 'acre', 'acne'], ['ache', 'acre', 'acme'], ['ache', 'achy', 'ashy'], ['ache', 'acne', 'acme', 'acre']]\n", + "['ache', 'acme', 'acne'] [['ache', 'acme', 'acne'], ['ache', 'acme', 'acre'], ['ache', 'acre', 'acne'], ['ache', 'acre', 'acme'], ['ache', 'achy', 'ashy'], ['ache', 'acne', 'acme', 'acre'], ['ache', 'acne', 'acre', 'acme']]\n", + "['ache', 'acme', 'acre'] [['ache', 'acme', 'acre'], ['ache', 'acre', 'acne'], ['ache', 'acre', 'acme'], ['ache', 'achy', 'ashy'], ['ache', 'acne', 'acme', 'acre'], ['ache', 'acne', 'acre', 'acme'], ['ache', 'acme', 'acne', 'acre']]\n", + "['ache', 'acre', 'acne'] [['ache', 'acre', 'acne'], ['ache', 'acre', 'acme'], ['ache', 'achy', 'ashy'], ['ache', 'acne', 'acme', 'acre'], ['ache', 'acne', 'acre', 'acme'], ['ache', 'acme', 'acne', 'acre'], ['ache', 'acme', 'acre', 'acne']]\n", + "['ache', 'acre', 'acme'] [['ache', 'acre', 'acme'], ['ache', 'achy', 'ashy'], ['ache', 'acne', 'acme', 'acre'], ['ache', 'acne', 'acre', 'acme'], ['ache', 'acme', 'acne', 'acre'], ['ache', 'acme', 'acre', 'acne'], ['ache', 'acre', 'acne', 'acme']]\n", + "['ache', 'achy', 'ashy'] [['ache', 'achy', 'ashy'], ['ache', 'acne', 'acme', 'acre'], ['ache', 'acne', 'acre', 'acme'], ['ache', 'acme', 'acne', 'acre'], ['ache', 'acme', 'acre', 'acne'], ['ache', 'acre', 'acne', 'acme'], ['ache', 'acre', 'acme', 'acne']]\n" + ] + }, + { + "data": { + "text/plain": [ + "['ache', 'achy', 'ashy']" + ] + }, + "execution_count": 120, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "bfs_search('ache', 'ashy', debug=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 122, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "[['ache']]\n", + "[['ache', 'acne'], ['ache', 'acme'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acne', 'acme'], ['ache', 'acne', 'acre'], ['ache', 'acme'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acne', 'acme', 'acre'], ['ache', 'acne', 'acre'], ['ache', 'acme'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acne', 'acre'], ['ache', 'acme'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acne', 'acre', 'acme'], ['ache', 'acme'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acme'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acme', 'acne'], ['ache', 'acme', 'acre'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acme', 'acne', 'acre'], ['ache', 'acme', 'acre'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acme', 'acre'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acme', 'acre', 'acne'], ['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acre'], ['ache', 'achy']]\n", + "[['ache', 'acre', 'acne'], ['ache', 'acre', 'acme'], ['ache', 'achy']]\n", + "[['ache', 'acre', 'acne', 'acme'], ['ache', 'acre', 'acme'], ['ache', 'achy']]\n", + "[['ache', 'acre', 'acme'], ['ache', 'achy']]\n", + "[['ache', 'acre', 'acme', 'acne'], ['ache', 'achy']]\n", + "[['ache', 'achy']]\n", + "[['ache', 'achy', 'ashy']]\n" + ] + }, + { + "data": { + "text/plain": [ + "['ache', 'achy', 'ashy']" + ] + }, + "execution_count": 122, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dfs_search('ache', 'ashy', debug=True)" + ] + }, + { + "cell_type": "code", + "execution_count": 79, "metadata": {}, "outputs": [ { @@ -2517,7 +1538,7 @@ "['buns', 'bunk', 'punk']" ] }, - "execution_count": 33, + "execution_count": 79, "metadata": {}, "output_type": "execute_result" } @@ -2528,7 +1549,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 80, "metadata": { "collapsed": true }, @@ -2543,7 +1564,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 81, "metadata": { "collapsed": true }, @@ -2566,7 +1587,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 82, "metadata": { "collapsed": true }, @@ -2577,33 +1598,33 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 83, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "['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" + "['foil', 'boil', 'bail', 'ball', 'balk', 'bank', 'hank']\n", + "['pint', 'pent', 'peat', 'meat', 'meal', 'mewl']\n", + "['fuse', 'fuss', 'furs', 'ours']\n", + "['plop', 'flop', 'flow', 'flew']\n", + "['lull', 'bull', 'bell', 'belt', 'welt', 'wept', 'kept']\n", + "['coma', 'coda', 'cods', 'cons', 'sons']\n", + "['pits', 'bits', 'bats', 'bass', 'bash', 'rash']\n", + "['bean', 'been', 'bees', 'beds', 'buds', 'suds']\n", + "['yips', 'nips', 'nits', 'nite', 'note', 'vote']\n", + "['pent', 'pens', 'yens']\n", + "['crop', 'coop', 'coos', 'cons', 'cans', 'fans']\n", + "['flop', 'clop', 'coop', 'cool', 'cowl', 'bowl', 'bawl']\n", + "['hill', 'hull', 'hulk', 'sulk', 'suck']\n", + "['aced', 'acid', 'arid', 'grid', 'grin', 'gain', 'rain']\n", + "['land', 'sand', 'sans', 'suns', 'subs', 'hubs']\n", + "['cogs', 'coos', 'cool', 'coal', 'foal', 'foam']\n", + "['loss', 'moss', 'mods', 'nods', 'nous', 'yous']\n", + "['soap', 'soar', 'boar', 'boas', 'bogs', 'jogs']\n", + "['musk', 'must', 'bust', 'best', 'beet', 'beef']\n", + "['fine', 'wine', 'wane', 'want', 'waft']\n" ] } ], @@ -2615,7 +1636,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 84, "metadata": {}, "outputs": [ { @@ -2624,7 +1645,7 @@ "['cops', 'coos', 'coon', 'coin', 'chin', 'thin', 'this', 'thus', 'thug']" ] }, - "execution_count": 38, + "execution_count": 84, "metadata": {}, "output_type": "execute_result" } @@ -2635,7 +1656,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 85, "metadata": {}, "outputs": [ { @@ -2644,7 +1665,7 @@ "[2204]" ] }, - "execution_count": 39, + "execution_count": 85, "metadata": {}, "output_type": "execute_result" } @@ -2655,7 +1676,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 86, "metadata": {}, "outputs": [ { @@ -2664,7 +1685,7 @@ "[2204]" ] }, - "execution_count": 40, + "execution_count": 86, "metadata": {}, "output_type": "execute_result" } @@ -2675,7 +1696,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 87, "metadata": {}, "outputs": [ { @@ -2684,7 +1705,7 @@ "['hate', 'have', 'hove', 'love']" ] }, - "execution_count": 41, + "execution_count": 87, "metadata": {}, "output_type": "execute_result" } @@ -2695,7 +1716,7 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 88, "metadata": {}, "outputs": [ { @@ -2704,7 +1725,7 @@ "['wars', 'ware', 'wave', 'wove', 'love']" ] }, - "execution_count": 42, + "execution_count": 88, "metadata": {}, "output_type": "execute_result" } @@ -2715,7 +1736,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 89, "metadata": {}, "outputs": [ { @@ -2723,7 +1744,7 @@ "output_type": "stream", "text": [ "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n", - "Wall time: 185 µs\n" + "Wall time: 199 µs\n" ] }, { @@ -2732,7 +1753,7 @@ "5" ] }, - "execution_count": 43, + "execution_count": 89, "metadata": {}, "output_type": "execute_result" } @@ -2743,7 +1764,7 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 90, "metadata": {}, "outputs": [ { @@ -2751,7 +1772,7 @@ "output_type": "stream", "text": [ "CPU times: user 0 ns, sys: 0 ns, total: 0 ns\n", - "Wall time: 398 µs\n" + "Wall time: 210 µs\n" ] }, { @@ -2760,7 +1781,7 @@ "5" ] }, - "execution_count": 44, + "execution_count": 90, "metadata": {}, "output_type": "execute_result" } @@ -2771,24 +1792,24 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 91, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 32 ms, sys: 0 ns, total: 32 ms\n", - "Wall time: 32.3 ms\n" + "CPU times: user 12 ms, sys: 0 ns, total: 12 ms\n", + "Wall time: 13.5 ms\n" ] }, { "data": { "text/plain": [ - "404" + "272" ] }, - "execution_count": 45, + "execution_count": 91, "metadata": {}, "output_type": "execute_result" } @@ -2799,7 +1820,7 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 92, "metadata": { "collapsed": true }, @@ -2810,15 +1831,15 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 93, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 212 ms, sys: 0 ns, total: 212 ms\n", - "Wall time: 213 ms\n" + "CPU times: user 724 ms, sys: 0 ns, total: 724 ms\n", + "Wall time: 723 ms\n" ] }, { @@ -2827,7 +1848,7 @@ "5" ] }, - "execution_count": 47, + "execution_count": 93, "metadata": {}, "output_type": "execute_result" } @@ -2838,7 +1859,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 94, "metadata": {}, "outputs": [ { @@ -2847,7 +1868,7 @@ "['fear', 'feat', 'fest', 'lest', 'lost', 'lose', 'love']" ] }, - "execution_count": 48, + "execution_count": 94, "metadata": {}, "output_type": "execute_result" } @@ -2858,7 +1879,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 95, "metadata": {}, "outputs": [ { @@ -2867,7 +1888,7 @@ "['fail', 'fall', 'pall', 'pals', 'pass']" ] }, - "execution_count": 49, + "execution_count": 95, "metadata": {}, "output_type": "execute_result" } @@ -2878,7 +1899,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 96, "metadata": {}, "outputs": [ { @@ -2887,7 +1908,7 @@ "['star', 'soar', 'boar', 'boor', 'boon', 'born']" ] }, - "execution_count": 50, + "execution_count": 96, "metadata": {}, "output_type": "execute_result" } @@ -2898,7 +1919,7 @@ }, { "cell_type": "code", - "execution_count": 51, + "execution_count": 97, "metadata": {}, "outputs": [ { @@ -2917,7 +1938,7 @@ " 'pass']" ] }, - "execution_count": 51, + "execution_count": 97, "metadata": {}, "output_type": "execute_result" } @@ -2928,29 +1949,29 @@ }, { "cell_type": "code", - "execution_count": 52, + "execution_count": 98, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['bass',\n", - " 'lass',\n", - " 'mass',\n", - " 'sass',\n", - " 'puss',\n", - " 'pads',\n", - " 'pals',\n", - " 'pans',\n", - " 'paps',\n", - " 'pars',\n", - " 'pats',\n", - " 'paws',\n", - " 'pays',\n", - " 'past']" + "frozenset({'bass',\n", + " 'lass',\n", + " 'mass',\n", + " 'pads',\n", + " 'pals',\n", + " 'pans',\n", + " 'paps',\n", + " 'pars',\n", + " 'past',\n", + " 'pats',\n", + " 'paws',\n", + " 'pays',\n", + " 'puss',\n", + " 'sass'})" ] }, - "execution_count": 52, + "execution_count": 98, "metadata": {}, "output_type": "execute_result" } @@ -2961,7 +1982,7 @@ }, { "cell_type": "code", - "execution_count": 53, + "execution_count": 99, "metadata": {}, "outputs": [ { @@ -2970,7 +1991,7 @@ "[1]" ] }, - "execution_count": 53, + "execution_count": 99, "metadata": {}, "output_type": "execute_result" } @@ -2981,7 +2002,7 @@ }, { "cell_type": "code", - "execution_count": 54, + "execution_count": 100, "metadata": {}, "outputs": [ { @@ -2990,7 +2011,7 @@ "[2204]" ] }, - "execution_count": 54, + "execution_count": 100, "metadata": {}, "output_type": "execute_result" } @@ -3001,14 +2022,14 @@ }, { "cell_type": "code", - "execution_count": 55, + "execution_count": 101, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 8.21 s per loop\n" + "1 loop, best of 3: 9.05 s per loop\n" ] } ], @@ -3019,14 +2040,14 @@ }, { "cell_type": "code", - "execution_count": 56, + "execution_count": 102, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "10 loops, best of 3: 145 ms per loop\n" + "10 loops, best of 3: 147 ms per loop\n" ] } ], @@ -3037,7 +2058,7 @@ }, { "cell_type": "code", - "execution_count": 57, + "execution_count": 103, "metadata": {}, "outputs": [ { @@ -3055,7 +2076,7 @@ " 'exit']" ] }, - "execution_count": 57, + "execution_count": 103, "metadata": {}, "output_type": "execute_result" } @@ -3066,7 +2087,7 @@ }, { "cell_type": "code", - "execution_count": 58, + "execution_count": 104, "metadata": { "collapsed": true }, @@ -3090,7 +2111,7 @@ }, { "cell_type": "code", - "execution_count": 59, + "execution_count": 105, "metadata": { "collapsed": true }, @@ -3115,14 +2136,14 @@ }, { "cell_type": "code", - "execution_count": 60, + "execution_count": 106, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 334 ms per loop\n" + "1 loop, best of 3: 358 ms per loop\n" ] } ], @@ -3133,15 +2154,15 @@ }, { "cell_type": "code", - "execution_count": 61, + "execution_count": 107, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 344 ms, sys: 0 ns, total: 344 ms\n", - "Wall time: 342 ms\n" + "CPU times: user 384 ms, sys: 0 ns, total: 384 ms\n", + "Wall time: 382 ms\n" ] }, { @@ -3150,7 +2171,7 @@ "14" ] }, - "execution_count": 61, + "execution_count": 107, "metadata": {}, "output_type": "execute_result" } @@ -3161,15 +2182,15 @@ }, { "cell_type": "code", - "execution_count": 62, + "execution_count": 108, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 92 ms, sys: 0 ns, total: 92 ms\n", - "Wall time: 93.7 ms\n" + "CPU times: user 112 ms, sys: 0 ns, total: 112 ms\n", + "Wall time: 109 ms\n" ] }, { @@ -3178,7 +2199,7 @@ "15" ] }, - "execution_count": 62, + "execution_count": 108, "metadata": {}, "output_type": "execute_result" } @@ -3189,15 +2210,15 @@ }, { "cell_type": "code", - "execution_count": 63, + "execution_count": 109, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 32 ms, sys: 0 ns, total: 32 ms\n", - "Wall time: 32.8 ms\n" + "CPU times: user 40 ms, sys: 0 ns, total: 40 ms\n", + "Wall time: 36.5 ms\n" ] }, { @@ -3206,7 +2227,7 @@ "14" ] }, - "execution_count": 63, + "execution_count": 109, "metadata": {}, "output_type": "execute_result" } @@ -3217,15 +2238,15 @@ }, { "cell_type": "code", - "execution_count": 64, + "execution_count": 110, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 16 ms, sys: 0 ns, total: 16 ms\n", - "Wall time: 16.4 ms\n" + "CPU times: user 20 ms, sys: 0 ns, total: 20 ms\n", + "Wall time: 18.1 ms\n" ] }, { @@ -3234,7 +2255,7 @@ "14" ] }, - "execution_count": 64, + "execution_count": 110, "metadata": {}, "output_type": "execute_result" } @@ -3245,15 +2266,15 @@ }, { "cell_type": "code", - "execution_count": 65, + "execution_count": 111, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 256 ms, sys: 0 ns, total: 256 ms\n", - "Wall time: 253 ms\n" + "CPU times: user 272 ms, sys: 0 ns, total: 272 ms\n", + "Wall time: 267 ms\n" ] }, { @@ -3262,7 +2283,7 @@ "14" ] }, - "execution_count": 65, + "execution_count": 111, "metadata": {}, "output_type": "execute_result" } @@ -3273,15 +2294,15 @@ }, { "cell_type": "code", - "execution_count": 66, + "execution_count": 112, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 36 ms, sys: 0 ns, total: 36 ms\n", - "Wall time: 34.2 ms\n" + "CPU times: user 40 ms, sys: 0 ns, total: 40 ms\n", + "Wall time: 37.8 ms\n" ] }, { @@ -3290,7 +2311,7 @@ "14" ] }, - "execution_count": 66, + "execution_count": 112, "metadata": {}, "output_type": "execute_result" } @@ -3301,15 +2322,15 @@ }, { "cell_type": "code", - "execution_count": 67, + "execution_count": 113, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "bash bush True\n", - "rush bush True\n" + "rush bush True\n", + "bash bush True\n" ] }, { @@ -3318,7 +2339,7 @@ "2" ] }, - "execution_count": 67, + "execution_count": 113, "metadata": {}, "output_type": "execute_result" } @@ -3335,16 +2356,16 @@ }, { "cell_type": "code", - "execution_count": 68, + "execution_count": 114, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['gush', 'hush', 'lush', 'mush', 'push', 'tush', 'bosh']" + "['gush', 'mush', 'bosh', 'tush', 'lush', 'push', 'hush']" ] }, - "execution_count": 68, + "execution_count": 114, "metadata": {}, "output_type": "execute_result" } @@ -3355,16 +2376,16 @@ }, { "cell_type": "code", - "execution_count": 69, + "execution_count": 115, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "('nose', 2)" + "('came', 2)" ] }, - "execution_count": 69, + "execution_count": 115, "metadata": {}, "output_type": "execute_result" } @@ -3388,16 +2409,16 @@ }, { "cell_type": "code", - "execution_count": 70, + "execution_count": 116, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'grew'" + "'hags'" ] }, - "execution_count": 70, + "execution_count": 116, "metadata": {}, "output_type": "execute_result" } @@ -3408,7 +2429,7 @@ }, { "cell_type": "code", - "execution_count": 71, + "execution_count": 117, "metadata": {}, "outputs": [ { @@ -3417,7 +2438,7 @@ "{'bash', 'rush'}" ] }, - "execution_count": 71, + "execution_count": 117, "metadata": {}, "output_type": "execute_result" } @@ -3452,7 +2473,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2+" + "version": "3.5.3" } }, "nbformat": 4, diff --git a/08-word-chains/explore-word-chain7.ipynb b/08-word-chains/explore-word-chain7.ipynb index ad49340..c4ccd75 100644 --- a/08-word-chains/explore-word-chain7.ipynb +++ b/08-word-chains/explore-word-chain7.ipynb @@ -99,7 +99,9 @@ { "cell_type": "code", "execution_count": 10, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "# neighbours = {w: [n for n in adjacents(w) if n in words]\n", @@ -109,7 +111,9 @@ { "cell_type": "code", "execution_count": 17, - "metadata": {}, + "metadata": { + "collapsed": true + }, "outputs": [], "source": [ "worddict = {w: True for w in words}\n", @@ -2456,7 +2460,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2+" + "version": "3.5.3" } }, "nbformat": 4, diff --git a/08-word-chains/rush3.dot b/08-word-chains/rush3.dot index 6adfe2e..43ddbb4 100644 --- a/08-word-chains/rush3.dot +++ b/08-word-chains/rush3.dot @@ -1,636 +1,636 @@ graph g { -"buds" -- "buys"; -"rice" -- "rime"; -"rung" -- "runt"; -"pubs" -- "puss"; -"mask" -- "musk"; -"jest" -- "lest"; -"bast" -- "cast"; -"muck" -- "musk"; -"lash" -- "rash"; -"gosh" -- "posh"; -"pose" -- "hose"; -"busy" -- "bury"; -"runt" -- "runs"; -"rash" -- "rasp"; -"husk" -- "hulk"; -"puss" -- "puns"; -"bush" -- "tush"; -"gust" -- "gist"; -"nest" -- "pest"; -"pest" -- "test"; -"last" -- "cast"; -"nest" -- "lest"; -"mute" -- "muse"; -"lath" -- "hath"; -"bask" -- "cask"; -"buds" -- "buss"; -"lass" -- "pass"; -"mule" -- "yule"; -"push" -- "gush"; -"list" -- "mist"; -"bush" -- "bosh"; -"rise" -- "risk"; -"muss" -- "mass"; -"hush" -- "push"; -"musk" -- "rusk"; -"rise" -- "rife"; -"yest" -- "test"; -"duck" -- "muck"; -"rise" -- "rose"; -"pose" -- "rose"; -"pose" -- "lose"; -"puts" -- "puns"; -"fuss" -- "wuss"; +"miss" -- "mass"; +"best" -- "lest"; +"rite" -- "rice"; +"rude" -- "dude"; +"rusk" -- "dusk"; +"cask" -- "case"; +"rest" -- "best"; +"rope" -- "roue"; +"zest" -- "fest"; +"post" -- "pest"; +"tube" -- "rube"; +"bury" -- "buoy"; +"hash" -- "sash"; +"cash" -- "rash"; +"tusk" -- "dusk"; "puss" -- "pugs"; -"must" -- "mutt"; +"oust" -- "just"; +"rope" -- "rode"; +"rope" -- "robe"; +"hash" -- "hush"; +"mist" -- "gist"; +"puss" -- "buss"; +"bash" -- "mash"; +"hash" -- "wash"; +"must" -- "bust"; +"runs" -- "puns"; +"roue" -- "rode"; +"dunk" -- "dusk"; +"rest" -- "vest"; +"tuck" -- "muck"; +"rune" -- "tune"; +"mash" -- "rash"; +"rile" -- "rise"; +"dust" -- "duet"; +"last" -- "bast"; +"math" -- "lath"; +"rant" -- "rent"; +"best" -- "fest"; +"zest" -- "nest"; +"test" -- "jest"; +"dose" -- "lose"; +"mugs" -- "bugs"; "rule" -- "rude"; -"bask" -- "bass"; -"yest" -- "west"; -"mesh" -- "mush"; -"buns" -- "bums"; -"pose" -- "nose"; -"ripe" -- "ride"; -"fuss" -- "muss"; -"tush" -- "push"; -"disk" -- "desk"; -"rove" -- "rose"; -"jest" -- "best"; -"jest" -- "pest"; -"must" -- "musk"; -"buss" -- "cuss"; -"best" -- "zest"; -"mule" -- "mute"; -"disk" -- "dusk"; -"rice" -- "rife"; -"rune" -- "ruse"; -"gasp" -- "rasp"; -"rise" -- "ride"; -"hose" -- "lose"; -"yest" -- "jest"; -"pubs" -- "puns"; -"moss" -- "miss"; -"rife" -- "ride"; -"mast" -- "mist"; -"buds" -- "burs"; -"mush" -- "much"; -"rice" -- "rile"; -"hush" -- "bush"; -"buts" -- "butt"; -"gust" -- "rust"; -"rule" -- "yule"; -"mash" -- "bash"; -"gasp" -- "hasp"; -"gust" -- "gush"; -"just" -- "must"; -"fuse" -- "fume"; -"puss" -- "push"; -"cash" -- "hash"; +"mash" -- "mast"; +"mums" -- "bums"; +"hath" -- "bath"; +"bunt" -- "runt"; +"mush" -- "tush"; +"gust" -- "must"; +"lush" -- "bush"; +"math" -- "bath"; +"test" -- "pest"; +"lost" -- "list"; +"bunt" -- "butt"; "posy" -- "posh"; -"lash" -- "mash"; -"hunt" -- "hunk"; -"post" -- "pest"; -"rust" -- "ruse"; -"bush" -- "gush"; -"rite" -- "rote"; -"rune" -- "tune"; -"cast" -- "cash"; -"bash" -- "bath"; -"bash" -- "dash"; -"rune" -- "rube"; -"role" -- "rope"; -"gosh" -- "josh"; -"ruse" -- "rose"; -"bust" -- "rust"; -"posh" -- "nosh"; -"rule" -- "rile"; -"west" -- "pest"; -"pubs" -- "pups"; -"west" -- "lest"; -"dune" -- "dude"; -"mesa" -- "mesh"; -"mess" -- "mass"; -"gust" -- "lust"; -"rife" -- "ripe"; -"lest" -- "list"; -"gasp" -- "gash"; -"bast" -- "base"; -"buts" -- "bugs"; -"wash" -- "dash"; -"dose" -- "hose"; -"lest" -- "best"; -"lest" -- "pest"; -"gust" -- "bust"; -"puts" -- "buts"; -"tush" -- "mush"; -"robe" -- "rose"; -"such" -- "ouch"; -"puns" -- "buns"; -"bass" -- "pass"; -"rule" -- "role"; -"rune" -- "runs"; -"yest" -- "pest"; -"rush" -- "rust"; -"task" -- "tusk"; -"yest" -- "lest"; -"just" -- "lust"; -"mast" -- "mass"; -"post" -- "lost"; -"dust" -- "oust"; -"muss" -- "mush"; -"role" -- "roue"; -"just" -- "bust"; -"buds" -- "buns"; -"hush" -- "tush"; -"rust" -- "rusk"; -"lash" -- "gash"; -"rush" -- "rash"; -"hath" -- "hash"; -"mist" -- "must"; -"rote" -- "rose"; +"puss" -- "puns"; +"best" -- "vest"; +"rile" -- "role"; +"math" -- "mash"; +"lass" -- "lash"; +"mask" -- "task"; +"pest" -- "vest"; +"lash" -- "last"; +"bash" -- "gash"; +"burs" -- "buds"; +"bunt" -- "hunt"; +"bask" -- "bass"; +"runs" -- "rung"; +"oust" -- "must"; +"pose" -- "lose"; +"rube" -- "lube"; +"rite" -- "ripe"; +"rife" -- "rile"; +"oust" -- "rust"; +"sass" -- "bass"; +"nosh" -- "nose"; +"pose" -- "hose"; +"best" -- "bast"; +"buns" -- "buds"; +"duct" -- "duet"; +"rest" -- "lest"; +"buts" -- "bums"; +"lust" -- "bust"; +"rude" -- "rode"; +"mask" -- "mast"; +"robe" -- "role"; +"dash" -- "mash"; +"list" -- "last"; +"zest" -- "test"; "bash" -- "bosh"; -"burs" -- "bury"; -"gash" -- "gush"; +"buns" -- "puns"; +"puss" -- "puts"; +"role" -- "roue"; +"rant" -- "runt"; "runt" -- "hunt"; -"lath" -- "math"; -"husk" -- "hunk"; -"lost" -- "lose"; -"tube" -- "rube"; -"lest" -- "vest"; -"rope" -- "ripe"; -"puss" -- "cuss"; -"runs" -- "rubs"; -"case" -- "cash"; -"role" -- "robe"; -"dude" -- "nude"; -"best" -- "test"; -"west" -- "test"; -"must" -- "dust"; +"pubs" -- "puns"; +"runs" -- "runt"; +"lath" -- "bath"; +"just" -- "gust"; +"rope" -- "rove"; +"ouch" -- "such"; +"dust" -- "gust"; +"base" -- "bast"; +"bush" -- "gush"; +"puns" -- "pugs"; "boss" -- "bosh"; -"punt" -- "puns"; -"puns" -- "pups"; -"tusk" -- "rusk"; -"dusk" -- "rusk"; -"mugs" -- "bugs"; -"gosh" -- "nosh"; -"lash" -- "cash"; -"nose" -- "lose"; -"oust" -- "rust"; -"wash" -- "hash"; -"jest" -- "rest"; -"west" -- "zest"; +"mast" -- "most"; +"lush" -- "tush"; +"gash" -- "gasp"; +"west" -- "test"; +"lost" -- "lose"; +"cube" -- "lube"; +"wasp" -- "hasp"; +"cash" -- "wash"; +"cube" -- "tube"; +"role" -- "rose"; +"husk" -- "hulk"; +"test" -- "yest"; "rush" -- "push"; -"west" -- "fest"; -"lass" -- "bass"; -"moss" -- "most"; -"bust" -- "lust"; +"cask" -- "cast"; +"lush" -- "mush"; +"mesa" -- "mess"; +"best" -- "yest"; +"nest" -- "best"; +"west" -- "vest"; +"yest" -- "fest"; +"rush" -- "hush"; +"wash" -- "sash"; +"bash" -- "bast"; +"wash" -- "wish"; +"bask" -- "task"; "ruby" -- "rubs"; -"pose" -- "dose"; -"dust" -- "lust"; -"wash" -- "gash"; +"rite" -- "rime"; +"muss" -- "mass"; +"yest" -- "pest"; +"list" -- "lust"; +"rice" -- "rife"; +"fuse" -- "fuze"; +"boss" -- "bass"; +"gash" -- "gosh"; +"mast" -- "mass"; +"pubs" -- "pups"; +"buss" -- "bush"; +"tube" -- "lube"; +"ride" -- "rode"; +"miss" -- "mess"; +"mask" -- "bask"; +"hush" -- "gush"; +"posy" -- "rosy"; +"robe" -- "rove"; +"rove" -- "rode"; +"bunt" -- "punt"; +"cuss" -- "buss"; +"rust" -- "gust"; +"mess" -- "moss"; +"rush" -- "gush"; "rove" -- "roue"; -"gust" -- "oust"; -"wash" -- "bash"; -"zest" -- "test"; -"nest" -- "jest"; -"fest" -- "test"; -"disk" -- "risk"; -"rune" -- "rude"; +"lost" -- "post"; +"cuss" -- "wuss"; +"rife" -- "rise"; +"muss" -- "must"; +"mist" -- "mast"; +"buys" -- "buss"; +"mast" -- "must"; +"zest" -- "yest"; +"burs" -- "buys"; +"rule" -- "rube"; +"rime" -- "rise"; "buys" -- "bums"; -"wasp" -- "rasp"; -"puss" -- "buss"; -"rote" -- "robe"; +"puts" -- "puns"; +"dude" -- "nude"; +"just" -- "bust"; "bast" -- "bust"; -"must" -- "lust"; -"rest" -- "test"; -"cask" -- "cash"; -"musk" -- "mush"; -"musk" -- "tusk"; -"mist" -- "gist"; -"muss" -- "buss"; -"dunk" -- "dune"; -"husk" -- "musk"; -"role" -- "rove"; -"just" -- "oust"; -"hush" -- "mush"; -"task" -- "cask"; -"muss" -- "cuss"; -"rise" -- "vise"; +"gush" -- "gust"; +"base" -- "bass"; +"fuse" -- "ruse"; +"bash" -- "rash"; +"best" -- "pest"; +"mash" -- "gash"; +"rose" -- "lose"; +"vest" -- "fest"; +"ouch" -- "much"; +"post" -- "pose"; +"pass" -- "sass"; +"lust" -- "gust"; +"buns" -- "bugs"; +"pest" -- "fest"; "tush" -- "gush"; -"last" -- "lust"; -"josh" -- "nosh"; -"tush" -- "tusk"; -"hath" -- "bath"; -"most" -- "post"; -"rest" -- "rent"; "rude" -- "ruse"; -"buns" -- "runs"; -"dunk" -- "duck"; -"rust" -- "lust"; -"task" -- "bask"; -"boss" -- "buss"; -"rise" -- "ruse"; -"duck" -- "dusk"; -"rosy" -- "rose"; -"mast" -- "bast"; -"oust" -- "lust"; -"posy" -- "post"; -"mast" -- "last"; -"gash" -- "mash"; -"bunt" -- "butt"; -"rube" -- "rude"; -"case" -- "cask"; -"rode" -- "rude"; -"dash" -- "hash"; -"lest" -- "rest"; -"lest" -- "fest"; +"nest" -- "lest"; +"wish" -- "dish"; +"wasp" -- "wash"; +"buds" -- "buss"; +"lass" -- "mass"; +"zest" -- "rest"; +"dunk" -- "hunk"; +"lust" -- "must"; +"last" -- "cast"; +"cash" -- "cast"; +"mush" -- "push"; +"rush" -- "ruse"; +"robe" -- "rose"; +"husk" -- "hush"; +"hash" -- "gash"; +"burs" -- "buss"; +"musk" -- "tusk"; +"rash" -- "rasp"; +"rush" -- "bush"; +"role" -- "rode"; +"robe" -- "rote"; +"hush" -- "bush"; +"lost" -- "most"; +"posh" -- "gosh"; +"rove" -- "rote"; +"zest" -- "pest"; +"miss" -- "moss"; +"ruby" -- "rube"; +"rubs" -- "rube"; +"rice" -- "rise"; +"cash" -- "gash"; +"cube" -- "rube"; +"hunk" -- "hunt"; +"rest" -- "pest"; +"posy" -- "pose"; +"lush" -- "rush"; +"rude" -- "nude"; +"dusk" -- "duck"; +"rest" -- "jest"; +"runs" -- "rubs"; +"wasp" -- "gasp"; +"nest" -- "fest"; +"muss" -- "mush"; +"dust" -- "lust"; +"lest" -- "pest"; +"rust" -- "bust"; +"bunt" -- "bust"; +"lest" -- "vest"; +"burs" -- "buts"; +"pubs" -- "puts"; +"muse" -- "must"; +"rile" -- "ride"; +"rise" -- "wise"; +"puss" -- "fuss"; +"cash" -- "mash"; +"zest" -- "jest"; +"last" -- "mast"; +"rope" -- "role"; +"most" -- "must"; +"rush" -- "rusk"; +"bash" -- "dash"; +"tube" -- "tune"; +"sass" -- "sash"; +"nest" -- "pest"; +"gush" -- "push"; +"buds" -- "bugs"; +"rusk" -- "ruse"; +"post" -- "most"; +"bunt" -- "aunt"; +"rush" -- "tush"; +"buns" -- "buts"; +"rise" -- "vise"; +"rite" -- "rile"; +"dust" -- "just"; +"rite" -- "rife"; +"boss" -- "moss"; +"busy" -- "bush"; +"mash" -- "sash"; +"test" -- "lest"; +"puss" -- "pubs"; +"mugs" -- "muss"; +"buts" -- "buds"; +"mess" -- "mesh"; +"mess" -- "muss"; +"husk" -- "musk"; +"bosh" -- "bush"; +"hulk" -- "hunk"; +"bash" -- "sash"; +"bast" -- "bass"; +"zest" -- "west"; +"lass" -- "pass"; "bash" -- "bush"; -"list" -- "gist"; -"rube" -- "cube"; -"bast" -- "bash"; -"buys" -- "bugs"; -"gash" -- "bash"; -"bask" -- "bash"; -"dust" -- "rust"; -"burs" -- "buns"; -"lath" -- "bath"; -"muck" -- "murk"; -"lest" -- "lost"; -"pose" -- "posh"; -"bury" -- "buoy"; -"punt" -- "aunt"; -"buss" -- "bugs"; +"test" -- "fest"; +"musk" -- "mask"; +"dose" -- "pose"; +"rise" -- "ripe"; +"rash" -- "sash"; +"hash" -- "cash"; +"nest" -- "rest"; "moss" -- "mass"; +"bugs" -- "pugs"; +"musk" -- "muse"; +"bunt" -- "buns"; +"duct" -- "duck"; +"wash" -- "rash"; +"mash" -- "mesh"; +"cask" -- "bask"; +"muck" -- "much"; +"rule" -- "role"; +"rest" -- "yest"; +"dash" -- "lash"; +"rise" -- "risk"; "mash" -- "mass"; -"task" -- "mask"; -"posy" -- "rosy"; -"case" -- "base"; -"rune" -- "rule"; -"wash" -- "lash"; -"burs" -- "bums"; -"puts" -- "pups"; -"pose" -- "post"; -"roue" -- "robe"; -"most" -- "lost"; +"bash" -- "base"; +"zest" -- "vest"; +"rush" -- "rust"; "bash" -- "bass"; -"just" -- "jest"; -"dusk" -- "tusk"; -"lash" -- "hash"; -"mash" -- "rash"; -"gash" -- "cash"; +"rube" -- "ruse"; +"lest" -- "yest"; +"hasp" -- "gasp"; +"lass" -- "last"; +"mush" -- "mesh"; +"rusk" -- "musk"; +"mute" -- "mutt"; +"math" -- "hath"; +"rune" -- "runt"; +"cash" -- "case"; +"test" -- "vest"; +"pups" -- "puns"; +"cash" -- "sash"; +"wasp" -- "rasp"; +"vise" -- "wise"; +"hash" -- "rash"; +"cuss" -- "fuss"; +"dust" -- "duct"; +"posh" -- "push"; "mush" -- "gush"; -"wash" -- "cash"; -"rite" -- "rile"; -"josh" -- "bosh"; -"gosh" -- "gush"; -"muss" -- "must"; -"puns" -- "runs"; -"aunt" -- "hunt"; -"rove" -- "rote"; -"rote" -- "roue"; -"rile" -- "ripe"; -"buds" -- "bums"; -"mast" -- "must"; -"list" -- "lost"; -"fuss" -- "fuse"; -"post" -- "posh"; -"nest" -- "best"; -"husk" -- "dusk"; -"both" -- "bath"; -"lash" -- "lush"; -"list" -- "last"; -"muss" -- "wuss"; -"dish" -- "dash"; -"rube" -- "lube"; -"bust" -- "bunt"; -"bugs" -- "pugs"; -"rode" -- "rope"; -"sass" -- "bass"; -"rick" -- "risk"; -"bust" -- "dust"; -"rink" -- "risk"; -"rest" -- "best"; -"rest" -- "pest"; -"both" -- "bosh"; -"such" -- "much"; -"desk" -- "dusk"; -"buds" -- "bugs"; -"aunt" -- "runt"; -"busy" -- "buss"; -"runt" -- "rust"; -"jest" -- "fest"; -"muss" -- "miss"; -"mugs" -- "pugs"; -"rule" -- "mule"; -"tune" -- "dune"; -"mash" -- "math"; -"yest" -- "zest"; -"yest" -- "fest"; -"jest" -- "test"; -"bust" -- "must"; -"mutt" -- "butt"; +"tuck" -- "tusk"; +"rude" -- "rube"; +"nest" -- "yest"; +"cash" -- "lash"; +"rose" -- "ruse"; +"rude" -- "ride"; "fuse" -- "muse"; -"rote" -- "rope"; -"moss" -- "mess"; -"puts" -- "pugs"; +"buss" -- "bugs"; +"muse" -- "mush"; +"lath" -- "lash"; +"husk" -- "dusk"; +"rune" -- "rung"; +"rime" -- "ripe"; +"bush" -- "bust"; +"oust" -- "lust"; +"puss" -- "pups"; +"rice" -- "ripe"; +"buss" -- "bust"; +"miss" -- "muss"; +"bash" -- "bath"; +"rope" -- "ripe"; +"muse" -- "ruse"; +"mash" -- "mask"; +"roue" -- "rote"; +"dash" -- "sash"; +"dust" -- "rust"; +"musk" -- "murk"; +"rode" -- "rote"; +"lash" -- "rash"; +"hush" -- "mush"; +"dash" -- "wash"; +"pose" -- "rose"; +"just" -- "must"; +"lath" -- "hath"; +"musk" -- "muss"; +"buys" -- "bugs"; +"post" -- "posh"; +"mush" -- "much"; +"muss" -- "moss"; "sass" -- "mass"; -"musk" -- "dusk"; -"busy" -- "bust"; -"nose" -- "hose"; -"dunk" -- "hunk"; -"bust" -- "bush"; -"burs" -- "bugs"; -"ruby" -- "rube"; -"lash" -- "dash"; -"gash" -- "rash"; -"mash" -- "cash"; -"buys" -- "buns"; -"buss" -- "bush"; -"pooh" -- "posh"; -"muss" -- "mess"; -"puss" -- "puts"; -"hose" -- "rose"; -"miss" -- "mess"; -"ruse" -- "muse"; -"buns" -- "bunt"; -"mast" -- "mask"; -"hulk" -- "hunk"; -"just" -- "dust"; +"mass" -- "bass"; +"bash" -- "lash"; +"miss" -- "mist"; +"lass" -- "bass"; +"dune" -- "dunk"; +"lass" -- "sass"; +"musk" -- "muck"; +"mesa" -- "mesh"; +"rule" -- "mule"; +"dune" -- "rune"; +"lust" -- "lest"; +"west" -- "best"; +"lash" -- "mash"; +"bush" -- "tush"; +"musk" -- "must"; +"best" -- "bust"; +"rent" -- "runt"; +"rove" -- "rose"; +"posy" -- "post"; +"just" -- "rust"; +"oust" -- "dust"; +"mast" -- "cast"; +"bask" -- "bast"; "buts" -- "buss"; -"mash" -- "mask"; -"moss" -- "muss"; -"wuss" -- "buss"; -"gosh" -- "bosh"; -"mums" -- "mugs"; -"fest" -- "vest"; -"lash" -- "lass"; -"rise" -- "rite"; -"just" -- "gust"; -"list" -- "lust"; -"hush" -- "husk"; -"rush" -- "lush"; -"buds" -- "buts"; -"must" -- "rust"; -"mash" -- "mush"; +"posh" -- "pose"; +"dune" -- "dude"; +"cash" -- "cask"; +"rime" -- "ride"; +"rice" -- "rick"; +"hasp" -- "rasp"; +"rude" -- "rune"; +"both" -- "bath"; +"mule" -- "muse"; +"nosh" -- "josh"; +"buss" -- "bums"; +"rule" -- "yule"; +"robe" -- "roue"; +"aunt" -- "hunt"; +"fuse" -- "fume"; +"dose" -- "nose"; +"runt" -- "punt"; +"cuss" -- "muss"; +"fuse" -- "fuss"; +"rice" -- "rime"; +"fuss" -- "wuss"; +"dash" -- "hash"; +"husk" -- "rusk"; +"dose" -- "rose"; +"buns" -- "bums"; +"disk" -- "dusk"; +"hash" -- "hasp"; +"buts" -- "butt"; +"bosh" -- "gosh"; +"muse" -- "muss"; +"hash" -- "mash"; "tuck" -- "duck"; -"rash" -- "cash"; -"rude" -- "nude"; -"wash" -- "mash"; -"nest" -- "vest"; -"hunt" -- "bunt"; -"bosh" -- "nosh"; -"puns" -- "pugs"; -"muck" -- "much"; -"rope" -- "roue"; -"rune" -- "dune"; -"pest" -- "zest"; -"mash" -- "sash"; -"rise" -- "wise"; -"best" -- "pest"; +"bash" -- "wash"; +"rule" -- "ruse"; "puss" -- "wuss"; -"fest" -- "zest"; -"must" -- "oust"; +"dose" -- "hose"; +"last" -- "lest"; +"puss" -- "muss"; +"mutt" -- "must"; +"mute" -- "mule"; +"mute" -- "muse"; +"lest" -- "jest"; "wish" -- "wise"; -"mash" -- "mesh"; -"pose" -- "posy"; -"lest" -- "lust"; -"lest" -- "test"; -"rite" -- "ripe"; -"mums" -- "muss"; -"rife" -- "rile"; -"lash" -- "bash"; -"ride" -- "rude"; -"dose" -- "nose"; -"rube" -- "ruse"; -"rube" -- "rubs"; -"bask" -- "base"; +"runt" -- "rust"; +"rung" -- "runt"; +"disk" -- "dish"; +"mask" -- "mass"; +"wash" -- "gash"; +"oust" -- "gust"; +"nest" -- "west"; "rope" -- "rose"; -"fuze" -- "fuse"; -"rise" -- "rile"; -"hasp" -- "rasp"; -"must" -- "muse"; -"dunk" -- "dusk"; -"cash" -- "sash"; -"miss" -- "mass"; +"rite" -- "ride"; +"rose" -- "rote"; +"mums" -- "muss"; +"boss" -- "buss"; "puss" -- "pass"; -"musk" -- "muse"; -"tube" -- "lube"; -"buns" -- "bugs"; -"rash" -- "sash"; -"mast" -- "mash"; -"fuss" -- "cuss"; -"rise" -- "rice"; -"role" -- "rose"; -"fuse" -- "ruse"; -"bass" -- "base"; -"rode" -- "ride"; -"yest" -- "best"; -"lass" -- "sass"; +"gash" -- "gush"; +"puts" -- "pugs"; +"posh" -- "bosh"; +"mugs" -- "pugs"; +"rose" -- "hose"; +"moss" -- "most"; "bums" -- "bugs"; -"ouch" -- "much"; -"boss" -- "bass"; -"mass" -- "pass"; -"mast" -- "cast"; -"tube" -- "tune"; -"bust" -- "best"; -"rest" -- "fest"; -"muss" -- "muse"; +"roue" -- "rose"; +"jest" -- "fest"; +"buoy" -- "busy"; +"mist" -- "must"; +"burs" -- "bugs"; +"test" -- "best"; +"lust" -- "rust"; +"rile" -- "ripe"; +"muss" -- "buss"; +"rick" -- "risk"; +"murk" -- "muck"; +"cask" -- "mask"; +"oust" -- "bust"; +"rest" -- "rust"; +"nosh" -- "gosh"; +"muss" -- "wuss"; +"disk" -- "desk"; +"rest" -- "rent"; +"yest" -- "jest"; +"zest" -- "lest"; +"gosh" -- "josh"; +"puts" -- "pups"; +"nest" -- "jest"; +"lost" -- "lust"; +"jest" -- "vest"; +"butt" -- "bust"; +"pooh" -- "posh"; +"gust" -- "gist"; +"bosh" -- "josh"; +"rusk" -- "rust"; +"cask" -- "task"; +"rise" -- "ruse"; +"buds" -- "buys"; +"lash" -- "gash"; +"rise" -- "rose"; +"pose" -- "nose"; +"bush" -- "push"; +"dusk" -- "desk"; +"puss" -- "cuss"; +"posh" -- "josh"; +"best" -- "jest"; +"risk" -- "rink"; +"muck" -- "duck"; +"disk" -- "risk"; +"rune" -- "rube"; +"list" -- "gist"; +"hose" -- "nose"; +"pubs" -- "rubs"; +"mast" -- "bast"; +"gash" -- "sash"; +"musk" -- "dusk"; +"aunt" -- "runt"; +"last" -- "lust"; +"burs" -- "bury"; +"buts" -- "bugs"; +"lash" -- "wash"; +"lost" -- "lest"; +"dust" -- "must"; +"tusk" -- "tush"; +"nest" -- "test"; "role" -- "rote"; -"last" -- "lost"; -"mist" -- "miss"; -"gust" -- "dust"; -"rice" -- "ripe"; -"dust" -- "dusk"; -"lest" -- "zest"; -"gash" -- "dash"; -"best" -- "fest"; -"rife" -- "rime"; -"rush" -- "mush"; -"mute" -- "mutt"; -"lass" -- "mass"; -"mash" -- "hash"; -"nest" -- "zest"; -"wish" -- "dish"; -"nest" -- "fest"; -"rune" -- "rung"; -"tube" -- "cube"; -"hush" -- "lush"; -"lass" -- "last"; -"fuze" -- "fume"; -"wasp" -- "hasp"; -"puss" -- "muss"; -"rode" -- "roue"; -"punt" -- "bunt"; -"bash" -- "rash"; -"disk" -- "dish"; -"must" -- "mush"; -"lush" -- "mush"; -"nose" -- "nosh"; +"rasp" -- "gasp"; +"dunk" -- "duck"; +"mugs" -- "mums"; +"burs" -- "bums"; +"gush" -- "gosh"; +"mist" -- "most"; +"rush" -- "rash"; +"mist" -- "list"; +"hush" -- "tush"; +"nest" -- "vest"; +"buns" -- "runs"; "lush" -- "lust"; -"buts" -- "bums"; -"nest" -- "rest"; -"bush" -- "push"; -"lost" -- "lust"; -"mast" -- "most"; -"duet" -- "dust"; -"hush" -- "rush"; -"rule" -- "ruse"; -"rite" -- "ride"; -"sass" -- "sash"; -"wash" -- "rash"; -"bast" -- "bass"; -"aunt" -- "bunt"; -"bast" -- "best"; -"mesh" -- "mess"; +"dash" -- "gash"; +"busy" -- "bust"; +"rice" -- "rile"; +"buds" -- "bums"; +"lost" -- "last"; +"west" -- "rest"; +"lush" -- "lash"; +"mess" -- "mass"; +"pest" -- "jest"; +"tush" -- "push"; +"buns" -- "buys"; +"just" -- "lust"; +"pups" -- "pugs"; +"rice" -- "ride"; +"rest" -- "fest"; +"rule" -- "rune"; +"bask" -- "base"; +"zest" -- "best"; +"base" -- "case"; +"mule" -- "yule"; +"musk" -- "mush"; +"posh" -- "nosh"; +"rosy" -- "rose"; +"buss" -- "wuss"; +"fuss" -- "buss"; +"bash" -- "cash"; +"west" -- "lest"; +"both" -- "bosh"; +"cast" -- "bast"; +"nosh" -- "bosh"; +"role" -- "rove"; "lash" -- "sash"; -"rash" -- "hash"; -"rush" -- "gush"; -"just" -- "rust"; -"buts" -- "buns"; "case" -- "cast"; -"rime" -- "ride"; -"vest" -- "pest"; -"bust" -- "oust"; -"bust" -- "butt"; -"buts" -- "burs"; -"math" -- "bath"; -"role" -- "rile"; -"ruse" -- "rusk"; -"rite" -- "rice"; -"rite" -- "rife"; -"busy" -- "buoy"; -"rile" -- "rime"; -"rest" -- "zest"; -"wasp" -- "wash"; -"bass" -- "buss"; -"mash" -- "dash"; -"yest" -- "vest"; -"rode" -- "role"; -"jest" -- "zest"; -"hash" -- "sash"; -"rush" -- "tush"; -"lest" -- "last"; -"best" -- "vest"; -"wuss" -- "cuss"; -"puss" -- "fuss"; -"dose" -- "lose"; -"rice" -- "ride"; -"rush" -- "rusk"; -"punt" -- "runt"; -"west" -- "vest"; -"lush" -- "tush"; -"bust" -- "buss"; -"rash" -- "dash"; -"sass" -- "pass"; -"rise" -- "ripe"; -"rode" -- "rove"; -"dose" -- "rose"; -"pubs" -- "puts"; -"vest" -- "test"; -"muss" -- "musk"; -"nest" -- "test"; -"burs" -- "buss"; -"cash" -- "dash"; -"pubs" -- "rubs"; -"gust" -- "must"; -"tuck" -- "tusk"; -"rose" -- "lose"; -"husk" -- "tusk"; -"rube" -- "robe"; -"mush" -- "muse"; -"rush" -- "bush"; -"rove" -- "rope"; -"vest" -- "zest"; -"roue" -- "rose"; -"murk" -- "musk"; -"josh" -- "posh"; -"posh" -- "bosh"; -"hath" -- "math"; -"lush" -- "gush"; -"nest" -- "west"; -"hasp" -- "hash"; -"mule" -- "muse"; +"punt" -- "hunt"; +"rite" -- "rote"; +"west" -- "yest"; +"hose" -- "lose"; +"pass" -- "bass"; +"mutt" -- "butt"; +"hush" -- "push"; +"buns" -- "buss"; +"burs" -- "buns"; +"wash" -- "mash"; "bash" -- "hash"; -"nose" -- "rose"; -"gash" -- "sash"; -"risk" -- "rusk"; -"west" -- "best"; -"rile" -- "ride"; -"lash" -- "last"; -"rode" -- "rote"; -"runt" -- "rant"; -"dash" -- "sash"; -"buss" -- "bums"; -"puss" -- "pups"; -"husk" -- "rusk"; -"buts" -- "buys"; -"bass" -- "mass"; +"fume" -- "fuze"; +"runs" -- "rune"; +"rife" -- "rime"; +"rife" -- "ripe"; +"ramp" -- "rasp"; +"rusk" -- "risk"; +"rile" -- "rime"; +"rick" -- "rink"; "west" -- "jest"; -"wasp" -- "gasp"; -"west" -- "rest"; -"fest" -- "pest"; -"rush" -- "ruse"; -"rung" -- "runs"; -"rink" -- "rick"; -"gash" -- "gosh"; -"mask" -- "cask"; -"duet" -- "duct"; -"yest" -- "nest"; -"rice" -- "rick"; -"rasp" -- "ramp"; -"duck" -- "duct"; -"rule" -- "rube"; -"rent" -- "rant"; +"buss" -- "busy"; +"rope" -- "rote"; +"just" -- "jest"; +"buts" -- "buys"; "lush" -- "push"; -"bush" -- "mush"; -"buss" -- "buns"; -"bast" -- "last"; -"rune" -- "runt"; -"mist" -- "most"; -"bash" -- "cash"; -"rite" -- "rime"; -"cube" -- "lube"; -"dude" -- "rude"; -"punt" -- "hunt"; -"pugs" -- "pups"; -"yest" -- "rest"; -"runt" -- "rent"; -"moss" -- "boss"; -"wash" -- "wish"; -"dust" -- "duct"; -"rope" -- "robe"; -"mesa" -- "mess"; -"tuck" -- "muck"; -"vise" -- "wise"; -"cask" -- "cast"; -"busy" -- "bush"; -"runt" -- "bunt"; -"fuss" -- "buss"; -"hush" -- "hash"; -"rise" -- "rime"; -"rode" -- "rose"; -"rode" -- "robe"; +"rusk" -- "tusk"; +"mash" -- "mush"; +"rest" -- "test"; +"rush" -- "mush"; +"ride" -- "ripe"; +"robe" -- "rube"; +"bash" -- "bask"; +"rule" -- "rile"; +"bury" -- "busy"; +"mush" -- "must"; +"buss" -- "bass"; +"hash" -- "hath"; +"aunt" -- "punt"; +"gash" -- "rash"; +"puss" -- "push"; +"rite" -- "rise"; +"lush" -- "hush"; +"lose" -- "nose"; +"lest" -- "fest"; +"dash" -- "cash"; +"punt" -- "puns"; +"list" -- "lest"; +"hash" -- "lash"; +"rose" -- "rode"; +"husk" -- "hunk"; +"rust" -- "ruse"; +"mush" -- "bush"; +"rune" -- "ruse"; +"dust" -- "bust"; +"robe" -- "rode"; +"rise" -- "ride"; +"tusk" -- "task"; +"pass" -- "mass"; +"west" -- "pest"; +"husk" -- "tusk"; +"muss" -- "fuss"; "pubs" -- "pugs"; -"mums" -- "bums"; -"bask" -- "bast"; -"lath" -- "lash"; -"jest" -- "vest"; -"rest" -- "vest"; -"rove" -- "robe"; -"bask" -- "mask"; -"must" -- "most"; -"bash" -- "sash"; -"buys" -- "buss"; -"burs" -- "buys"; -"rest" -- "rust"; -"mugs" -- "muss"; -"wash" -- "sash"; -"ripe" -- "rime"; -"gash" -- "hash"; -"lush" -- "bush"; -"mush" -- "push"; -"mask" -- "mass"; -"hush" -- "gush"; -"posh" -- "push"; -"bash" -- "base"; +"dust" -- "dusk"; +"rose" -- "nose"; +"such" -- "much"; +"buts" -- "puts"; +"lush" -- "gush"; +"rife" -- "ride"; +"dash" -- "rash"; +"dash" -- "dish"; +"gust" -- "bust"; +"yest" -- "vest"; +"rust" -- "must"; +"dune" -- "tune"; +"west" -- "fest"; } diff --git a/08-word-chains/visa-woes-solution.ipynb b/08-word-chains/visa-woes-solution.ipynb index 009e187..a030d8a 100644 --- a/08-word-chains/visa-woes-solution.ipynb +++ b/08-word-chains/visa-woes-solution.ipynb @@ -50,9 +50,136 @@ "How many different offices could you visit in no more than 10 steps from `coax`?" ] }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "# Worked example solution: part 1\n", + "This is the first of two tasks intended to exercise skills developed in M269. In this case, this is about search. I won't go over the general idea of search itself here, as there are loads of tutorials online about it. Instead, I'll talk about the specific way I've implmeneted it in this solution.\n", + "\n", + "(See below for the discussion of part 2.)\n", + "\n", + "## Search\n", + "The offices/words can be thought of as a graph of nodes and edges. Each word is a node, and there's an edge between two words if those words differ by one letter. The diagrams below show the connections between words that are one step and two steps away from 'rush'.\n", + "\n", + "| Words one step from 'rush' | Words two steps from 'rush' |\n", + "| ------------- | ------------- |\n", + "| \"Words | \"Words |\n", + "\n", + "The task is to find a path, a sequence of words, from the starting word to the destination. This is a classic search problem.\n", + "\n", + "The key data structure is the _agenda_, a set of partial routes. We take a partial route from the agenda and _extend_ it with the words/rooms reachable from the end of the partial route, giving a new set of partial routes. Those are added back into the agenda.\n", + "\n", + "Search finishes either when the partial route we're processing is a solution (i.e. goes form the origin to destination room) or the agenda becomes empty.\n", + "\n", + "For instance, say we're going from `ache` to `ashy`. The initial agenda consists of just one partial route, and that partial route contains just `ache`.\n", + "\n", + "```\n", + "ache\n", + "```\n", + "\n", + "We take that item off the agenda, extend it (with `acne`, `acme`, `acre`, and `achy` as neighbours of `ache`). When we add those four items to the agenda, we get \n", + "\n", + "```\n", + "ache -> acne\n", + "ache -> acme\n", + "ache -> acre\n", + "ache -> achy\n", + "```\n", + "\n", + "We then proces the `ache -> acne` partial path, extending it with `acme` and `acre`, giving the agenda:\n", + "\n", + "```\n", + "ache -> acme\n", + "ache -> acre\n", + "ache -> achy\n", + "ache -> acne -> acme\n", + "ache -> acne -> acre\n", + "```\n", + "\n", + "(Note that while `ache` is adjacent to `acne`, we don't want to create a new partial path to `ache` as we've already visited it in this path.)\n", + "\n", + "We then proces the `ache -> acme` partial path, extending it with `acne` and `acre`, giving the agenda:\n", + "\n", + "```\n", + "ache -> acre\n", + "ache -> achy\n", + "ache -> acne -> acme\n", + "ache -> acne -> acre\n", + "ache -> acme -> acne\n", + "ache -> acme -> acre\n", + "```\n", + "\n", + "We then do `ache -> acre` and `ache -> achy` to give:\n", + "\n", + "```\n", + "ache -> acne -> acme\n", + "ache -> acne -> acre\n", + "ache -> acme -> acne\n", + "ache -> acme -> acre\n", + "ache -> acre -> acne\n", + "ache -> acre -> acme\n", + "ache -> achy -> ashy\n", + "```\n", + "\n", + "`ache -> acne -> acme` has only one valid extension, so we get:\n", + "\n", + "```\n", + "ache -> acne -> acre\n", + "ache -> acme -> acne\n", + "ache -> acme -> acre\n", + "ache -> acre -> acne\n", + "ache -> acre -> acme\n", + "ache -> achy -> ashy\n", + "ache -> acne -> acme -> acre\n", + "```\n", + "\n", + "We process all the other partial paths in turn until we get to the agenda looking like:\n", + "```\n", + "ache -> achy -> ashy\n", + "ache -> acne -> acme -> acre\n", + "ache -> acne -> acre -> acme\n", + "ache -> acme -> acne -> acre\n", + "ache -> acme -> acre -> acne\n", + "ache -> acre -> acne -> acme\n", + "ache -> acre -> acme -> acne\n", + "```\n", + "At this point, the first partial path in the agenda is a solution, so we report success and return that path.\n", + "\n", + "With breadth-first search, we add the newly-discovered partial paths to the end of the agenda, meaning we go through the graph one layer at a time. If we add the new partial paths to the front of the agenda, we have depth-first search, where we explore one trail fully before backtracking and trying another.\n", + "\n", + "There are other clever things we can do, such as sorting the agenda by predicted distance to go, which can speed things up.\n", + "\n", + "## Agenda and paths\n", + "As each partial path is a sequence of words in order, it makes sense to store it as a Python `list` of words. For breadth-first and depth-first searches, the agenda is a sequence of partial paths. Again, it makes sense to store this a a Python `list` of partial paths.\n", + "\n", + "For A* search, the agenda is sorted by the sum of path length and predicted cost to complete the path. In this case, it makes sense to represent the agenda by a priority queue, also known as a heap. I decided to use the standard Python `heapq` library, rather than the one used in M269. Partial paths are put on the heap with `heappush` and the partial path with the lowest cost is removed with `heappop`. \n", + "\n", + "## The graph of words\n", + "How to represent the graph of words? In the input, the connections between words are implicit, so we need to write a little procedure that returns all the neighbouring words for the word passed in. \n", + "\n", + "There's also a choice here: to we calculate and store the explicit graph of words, or do we rediscover the neighbours every time we want to process a word? The first approach consumes space to reduce time; the second uses time to reduce space. \n", + "\n", + "In this case, as there are only 2300 words and 20,000 connections, it's not a lot of space. The search will be examining lots of nodes, so I took a decision to explicity cache all the word neighbour relations first, then just look them up as needed. \n", + "\n", + "(It turns out this wasn't a good idea in terms of raw perfromance. Generating the graph takes ~130ms, but seems to give just about no change in performance for any search algorithm. Ho hum, but an example of where a [premature optimistion](https://en.wikiquote.org/wiki/Donald_Knuth) turns out to be costly!)\n", + "\n", + "## Important optimisation: closed sets\n", + "If you look at the diagrams and traces above, you'll see that the graph of words is very heavily connected, with several different routes from one word to another. But we often don't need to try out all these alternatives. If we're considering a partial route that ends at a particular word _w_, and we've already found another partial route to _w_ that's no longer than this one, there's no need to continue analysing this one. For instance, in the trace above, there's a route `ache -> acne -> acme`, but we've already found the route `ache -> acme`, so we can discard the `ache -> acne -> acme` alternative without worrying about missing possible solutions.\n", + "\n", + "If we use something like breadth-first search, we know that the first time we encounter a new word is the shortest path to that word. That means that all subsequent times we arrive that that word, we know we can discard that partial path. \n", + "\n", + "We maintain a `closed set` of the words we've already processed. We can use that set in two places. Either we check the partial path when we take it off the agenda, or we use the closed set to reduce the number of partial paths generated at each step. In the implementation below, I do the latter.\n", + "\n", + "## Another optimisation: `list` or `set` of words?\n", + "The obvious way to represent the known words is as a list. But, we don't care about the order of items in the collection of words. All we do with them is check for existence of a word, and iterate through the whole collection. In these cases, the Python `set` is a much more efficient data structure than the Pyhton `list`, as it uses something like a `dict` underneath. This means membership checking is much faster while iteration takes about the same amount of time.\n", + "\n", + "Therefore, rather than using `list`s, we'll use `set`s where possible. In fact, as the set of words doesn't change, we can use the `frozenset` type to indicate that the set is immutable." + ] + }, { "cell_type": "code", - "execution_count": 2, + "execution_count": 116, "metadata": { "collapsed": true }, @@ -64,7 +191,7 @@ }, { "cell_type": "code", - "execution_count": 3, + "execution_count": 117, "metadata": {}, "outputs": [ { @@ -73,46 +200,73 @@ "2336" ] }, - "execution_count": 3, + "execution_count": 117, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "words = [w.strip() for w in open('08-rooms.txt').readlines()]\n", + "words = frozenset(w.strip() for w in open('08-rooms.txt').readlines())\n", "len(words)" ] }, { "cell_type": "code", - "execution_count": 4, + "execution_count": 191, "metadata": { "collapsed": true }, "outputs": [], "source": [ "def adjacents(word):\n", - " return [word[0:i] + l + word[i+1:]\n", + " return frozenset(word[0:i] + l + word[i+1:]\n", " for i in range(len(word))\n", " for l in string.ascii_lowercase\n", - " if l != word[i]]" + " if l != word[i])" ] }, { "cell_type": "code", - "execution_count": 5, - "metadata": { - "collapsed": true - }, - "outputs": [], + "execution_count": 192, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10 loops, best of 3: 130 ms per loop\n" + ] + } + ], "source": [ - "neighbours = {w: [n for n in adjacents(w) if n in words]\n", + "%%timeit\n", + "neighbours = {w: frozenset(n for n in adjacents(w) if n in words)\n", " for w in words}" ] }, { "cell_type": "code", - "execution_count": 6, + "execution_count": 193, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "20092" + ] + }, + "execution_count": 193, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "sum(len(neighbours[w]) for w in neighbours)" + ] + }, + { + "cell_type": "code", + "execution_count": 233, "metadata": { "collapsed": true }, @@ -125,7 +279,7 @@ }, { "cell_type": "code", - "execution_count": 7, + "execution_count": 195, "metadata": { "collapsed": true }, @@ -138,7 +292,7 @@ }, { "cell_type": "code", - "execution_count": 8, + "execution_count": 196, "metadata": { "collapsed": true }, @@ -155,21 +309,24 @@ }, { "cell_type": "code", - "execution_count": 9, + "execution_count": 197, "metadata": { "collapsed": true }, "outputs": [], "source": [ - "def extend_raw(chain):\n", - " nbrs = [w for w in adjacents(chain[-1]) if w in words]\n", + "def extend_raw(chain, closed=None):\n", + " if closed:\n", + " nbrs = set(neighbours[chain[-1]]) - closed\n", + " else:\n", + " nbrs = neighbours[chain[-1]]\n", " return [chain + [s] for s in nbrs\n", " if s not in chain]" ] }, { "cell_type": "code", - "execution_count": 10, + "execution_count": 198, "metadata": { "collapsed": true }, @@ -195,7 +352,33 @@ }, { "cell_type": "code", - "execution_count": 11, + "execution_count": 172, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def bfs_search_raw(start, goal, debug=False):\n", + " agenda = [[start]]\n", + " finished = False\n", + " while not finished and agenda:\n", + " current = agenda[0]\n", + " if debug:\n", + " print(current)\n", + " if current[-1] == goal:\n", + " finished = True\n", + " else:\n", + " successors = extend_raw(current)\n", + " agenda = agenda[1:] + successors\n", + " if finished:\n", + " return current\n", + " else:\n", + " return None " + ] + }, + { + "cell_type": "code", + "execution_count": 173, "metadata": { "collapsed": true }, @@ -223,7 +406,35 @@ }, { "cell_type": "code", - "execution_count": 12, + "execution_count": 181, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [ + "def bfs_search_closed_raw(start, goal, debug=False):\n", + " agenda = [[start]]\n", + " closed = set()\n", + " finished = False\n", + " while not finished and agenda:\n", + " current = agenda[0]\n", + " if debug:\n", + " print(current)\n", + " if current[-1] == goal:\n", + " finished = True\n", + " else:\n", + " closed.add(current[-1])\n", + " successors = extend_raw(current, closed)\n", + " agenda = agenda[1:] + successors\n", + " if finished:\n", + " return current\n", + " else:\n", + " return None " + ] + }, + { + "cell_type": "code", + "execution_count": 127, "metadata": { "collapsed": true }, @@ -249,7 +460,7 @@ }, { "cell_type": "code", - "execution_count": 13, + "execution_count": 128, "metadata": { "collapsed": true }, @@ -277,7 +488,7 @@ }, { "cell_type": "code", - "execution_count": 14, + "execution_count": 129, "metadata": { "collapsed": true }, @@ -306,7 +517,7 @@ }, { "cell_type": "code", - "execution_count": 15, + "execution_count": 130, "metadata": { "collapsed": true }, @@ -336,27 +547,27 @@ }, { "cell_type": "code", - "execution_count": 16, + "execution_count": 234, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "['vice', 'dice', 'dire', 'dare', 'ware', 'wars']" + "['coax', 'coat', 'boat', 'boar', 'soar', 'star', 'stay']" ] }, - "execution_count": 16, + "execution_count": 234, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "astar_search('vice', 'wars')" + "astar_search('coax', 'stay')" ] }, { "cell_type": "code", - "execution_count": 17, + "execution_count": 235, "metadata": {}, "outputs": [ { @@ -365,7 +576,7 @@ "['vice', 'dice', 'dire', 'dare', 'ware', 'wars']" ] }, - "execution_count": 17, + "execution_count": 235, "metadata": {}, "output_type": "execute_result" } @@ -376,7 +587,7 @@ }, { "cell_type": "code", - "execution_count": 18, + "execution_count": 201, "metadata": {}, "outputs": [ { @@ -385,7 +596,7 @@ "['boon', 'boot', 'bolt', 'belt', 'bell', 'sell']" ] }, - "execution_count": 18, + "execution_count": 201, "metadata": {}, "output_type": "execute_result" } @@ -396,27 +607,27 @@ }, { "cell_type": "code", - "execution_count": 19, + "execution_count": 236, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "6" + "7" ] }, - "execution_count": 19, + "execution_count": 236, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "len(astar_search('vice', 'wars'))" + "len(astar_search('coax', 'stay'))" ] }, { "cell_type": "code", - "execution_count": 20, + "execution_count": 203, "metadata": { "collapsed": true }, @@ -427,146 +638,251 @@ }, { "cell_type": "code", - "execution_count": 21, + "execution_count": 237, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "6" + "7" ] }, - "execution_count": 21, + "execution_count": 237, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "len(bfs_search_closed('vice', 'wars'))" + "len(bfs_search_closed('coax', 'stay'))" ] }, { "cell_type": "code", - "execution_count": 22, + "execution_count": 238, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "793" + "458" ] }, - "execution_count": 22, + "execution_count": 238, "metadata": {}, "output_type": "execute_result" } ], "source": [ - "len(dfs_search('vice', 'wars'))" + "len(dfs_search('coax', 'stay'))" ] }, { "cell_type": "code", - "execution_count": 23, + "execution_count": 239, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "10000 loops, best of 3: 157 µs per loop\n" + "1000 loops, best of 3: 605 µs per loop\n" ] } ], "source": [ "%%timeit\n", - "astar_search('vice', 'wars')" + "astar_search('coax', 'stay')" ] }, { "cell_type": "code", - "execution_count": 24, + "execution_count": 240, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "100 loops, best of 3: 15.5 ms per loop\n" + "1000 loops, best of 3: 607 µs per loop\n" ] } ], "source": [ "%%timeit\n", - "astar_search_raw('vice', 'wars')" + "astar_search_raw('coax', 'stay')" ] }, { "cell_type": "code", - "execution_count": 25, + "execution_count": 241, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "10000 loops, best of 3: 166 µs per loop\n" + "1000 loops, best of 3: 552 µs per loop\n" ] } ], "source": [ "%%timeit\n", - "astar_search_closed('vice', 'wars')" + "astar_search_closed('coax', 'stay')" ] }, { "cell_type": "code", - "execution_count": 26, - "metadata": { - "collapsed": true - }, - "outputs": [], + "execution_count": 243, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 loop, best of 3: 4min 25s per loop\n" + ] + } + ], + "source": [ + "%%timeit\n", + "bfs_search('coax', 'stay')" + ] + }, + { + "cell_type": "code", + "execution_count": 244, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 loop, best of 3: 4min 25s per loop\n" + ] + } + ], + "source": [ + "%%timeit\n", + "bfs_search_raw('coax', 'stay')" + ] + }, + { + "cell_type": "code", + "execution_count": 245, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 loop, best of 3: 810 ms per loop\n" + ] + } + ], + "source": [ + "%%timeit\n", + "bfs_search_closed('coax', 'stay')" + ] + }, + { + "cell_type": "code", + "execution_count": 246, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1 loop, best of 3: 814 ms per loop\n" + ] + } + ], "source": [ - "# %%timeit\n", - "# bfs_search('vice', 'wars')" + "%%timeit\n", + "bfs_search_closed_raw('coax', 'stay')" + ] + }, + { + "cell_type": "code", + "execution_count": 247, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10 loops, best of 3: 26.8 ms per loop\n" + ] + } + ], + "source": [ + "%%timeit\n", + "dfs_search('coax', 'stay')" ] }, { "cell_type": "code", - "execution_count": 27, + "execution_count": 248, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "1 loop, best of 3: 554 ms per loop\n" + "1 loop, best of 3: 4.39 s per loop\n" ] } ], "source": [ "%%timeit\n", - "bfs_search_closed('vice', 'wars')" + "astar_search('amen', 'doff')" ] }, { "cell_type": "code", - "execution_count": 28, + "execution_count": 249, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "10 loops, best of 3: 90.6 ms per loop\n" + "1 loop, best of 3: 4.4 s per loop\n" ] } ], "source": [ "%%timeit\n", - "dfs_search('vice', 'wars')" + "astar_search_raw('amen', 'doff')" ] }, + { + "cell_type": "code", + "execution_count": 250, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "10 loops, best of 3: 87.4 ms per loop\n" + ] + } + ], + "source": [ + "%%timeit\n", + "astar_search_closed('amen', 'doff')" + ] + }, + { + "cell_type": "code", + "execution_count": null, + "metadata": { + "collapsed": true + }, + "outputs": [], + "source": [] + }, { "cell_type": "markdown", "metadata": {}, @@ -580,12 +896,33 @@ "\n", "There are 180 words reachable in up to three steps from `rash`.\n", "\n", - "How many words are reachable in up to ten steps from `vice`?" + "How many words are reachable in up to ten steps from `coax`?" + ] + }, + { + "cell_type": "markdown", + "metadata": {}, + "source": [ + "\n", + "# Worked example solution: part 2\n", + "After all the mucking around with search algorithms, this is actually much easier. It's all to do with building up sets.\n", + "\n", + "The basic idea is to maintain a `set` of reachable words which is extended in passes. In each pass, we find all the neighbours of all the words in the reachable word set, and add those neighbours to the set of reachable words. We just do the number of passes specified in in the task.\n", + "\n", + "In the code below, `reachable` is set of reachable words and `extras` is the set of new words found. As an optimisation, I use the set `boundary` to hold the words added in the previous pass, as the new words to add to `reachable` must be neighbours of a word in the `boundary`: all words that are neighbours of the 'interior' of the set of reachable words have already been added. so there's no need to process them again.\n", + "\n", + "The `trim_extras` flag is for another optimisation: eacy time we add some more words to `extras`, remove words which are already in `reachable`. That will make the later update of `reachable` faster.\n", + "\n", + "This approach is quick, as its based on sets and set membership checking, which is a fast process.\n", + "\n", + "This also suggests another way of solving part 1. Start at depth 1, and find all the words reachable at that depth. If the target word is in the reachable set, report success. If not, increment the depth and find the reachable words again.\n", + "\n", + "This approach does give the right answer of the minimal distance from source to goal words, but it doesn't give any information about the route to take to go from one word to another; the route is something returned by the search algorithms above." ] }, { "cell_type": "code", - "execution_count": 29, + "execution_count": 217, "metadata": { "collapsed": true }, @@ -607,7 +944,7 @@ }, { "cell_type": "code", - "execution_count": 30, + "execution_count": 218, "metadata": {}, "outputs": [ { @@ -626,7 +963,7 @@ " 'rasp']" ] }, - "execution_count": 30, + "execution_count": 218, "metadata": {}, "output_type": "execute_result" } @@ -637,7 +974,7 @@ }, { "cell_type": "code", - "execution_count": 31, + "execution_count": 219, "metadata": { "scrolled": true }, @@ -649,7 +986,7 @@ " '`bash`, `cash`, `dash`, `gash`, `hash`, `lash`, `mash`, `rasp`, `rush`, `sash`, `wash`')" ] }, - "execution_count": 31, + "execution_count": 219, "metadata": {}, "output_type": "execute_result" } @@ -660,7 +997,7 @@ }, { "cell_type": "code", - "execution_count": 32, + "execution_count": 220, "metadata": { "scrolled": true }, @@ -672,7 +1009,7 @@ " 'bash, cash, dash, gash, hash, lash, mash, rasp, rush, sash, wash')" ] }, - "execution_count": 32, + "execution_count": 220, "metadata": {}, "output_type": "execute_result" } @@ -683,7 +1020,7 @@ }, { "cell_type": "code", - "execution_count": 33, + "execution_count": 221, "metadata": { "scrolled": true }, @@ -695,7 +1032,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": 33, + "execution_count": 221, "metadata": {}, "output_type": "execute_result" } @@ -706,7 +1043,7 @@ }, { "cell_type": "code", - "execution_count": 34, + "execution_count": 222, "metadata": { "scrolled": true }, @@ -718,7 +1055,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": 34, + "execution_count": 222, "metadata": {}, "output_type": "execute_result" } @@ -729,7 +1066,7 @@ }, { "cell_type": "code", - "execution_count": 35, + "execution_count": 223, "metadata": { "scrolled": true }, @@ -740,7 +1077,7 @@ "180" ] }, - "execution_count": 35, + "execution_count": 223, "metadata": {}, "output_type": "execute_result" } @@ -751,7 +1088,7 @@ }, { "cell_type": "code", - "execution_count": 36, + "execution_count": 224, "metadata": { "scrolled": true }, @@ -762,7 +1099,7 @@ "2195" ] }, - "execution_count": 36, + "execution_count": 224, "metadata": {}, "output_type": "execute_result" } @@ -773,7 +1110,7 @@ }, { "cell_type": "code", - "execution_count": 37, + "execution_count": 225, "metadata": { "scrolled": true }, @@ -784,7 +1121,7 @@ "2192" ] }, - "execution_count": 37, + "execution_count": 225, "metadata": {}, "output_type": "execute_result" } @@ -795,7 +1132,7 @@ }, { "cell_type": "code", - "execution_count": 38, + "execution_count": 226, "metadata": { "scrolled": true }, @@ -804,7 +1141,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "100 loops, best of 3: 5.81 ms per loop\n" + "100 loops, best of 3: 6.2 ms per loop\n" ] } ], @@ -815,7 +1152,7 @@ }, { "cell_type": "code", - "execution_count": 39, + "execution_count": 227, "metadata": { "scrolled": true }, @@ -824,7 +1161,7 @@ "name": "stdout", "output_type": "stream", "text": [ - "100 loops, best of 3: 2.71 ms per loop\n" + "100 loops, best of 3: 2.92 ms per loop\n" ] } ], @@ -835,7 +1172,7 @@ }, { "cell_type": "code", - "execution_count": 40, + "execution_count": 155, "metadata": {}, "outputs": [ { @@ -844,7 +1181,7 @@ "2188" ] }, - "execution_count": 40, + "execution_count": 155, "metadata": {}, "output_type": "execute_result" } @@ -855,7 +1192,7 @@ }, { "cell_type": "code", - "execution_count": 41, + "execution_count": 156, "metadata": {}, "outputs": [ { @@ -864,7 +1201,7 @@ "2193" ] }, - "execution_count": 41, + "execution_count": 156, "metadata": {}, "output_type": "execute_result" } @@ -875,7 +1212,63 @@ }, { "cell_type": "code", - "execution_count": 42, + "execution_count": 232, + "metadata": {}, + "outputs": [ + { + "data": { + "text/plain": [ + "(True, 1)" + ] + }, + "execution_count": 232, + "metadata": {}, + "output_type": "execute_result" + } + ], + "source": [ + "dist = 0\n", + "found = False\n", + "\n", + "while not found and distance < 50:\n", + " dist += 1\n", + " others = reachable_in('coax', distance)\n", + " if 'stay' in others:\n", + " found = True\n", + "\n", + "found, dist" + ] + }, + { + "cell_type": "code", + "execution_count": 229, + "metadata": {}, + "outputs": [ + { + "name": "stdout", + "output_type": "stream", + "text": [ + "1000 loops, best of 3: 1.26 ms per loop\n" + ] + } + ], + "source": [ + "%%timeit\n", + "distance = 0\n", + "found = False\n", + "\n", + "while not found and distance < 50:\n", + " distance += 1\n", + " others = reachable_in('coax', distance)\n", + " if 'stay' in others:\n", + " found = True\n", + "\n", + "found, distance" + ] + }, + { + "cell_type": "code", + "execution_count": 157, "metadata": {}, "outputs": [ { @@ -884,7 +1277,7 @@ "280" ] }, - "execution_count": 42, + "execution_count": 157, "metadata": {}, "output_type": "execute_result" } @@ -896,7 +1289,7 @@ }, { "cell_type": "code", - "execution_count": 43, + "execution_count": 158, "metadata": {}, "outputs": [ { @@ -905,7 +1298,7 @@ "296" ] }, - "execution_count": 43, + "execution_count": 158, "metadata": {}, "output_type": "execute_result" } @@ -920,16 +1313,16 @@ }, { "cell_type": "code", - "execution_count": 44, + "execution_count": 159, "metadata": {}, "outputs": [ { "data": { "text/plain": [ - "'know step yeps test pout book beck poor boos veep teed gent saws dyer hemp soon deem legs bets twit whim belt rock well bled whet prop spec weep peed loan week clef feed lock yens vent doer less teem toot yews blur clue pert pegs brew flea trig vets sued felt perk bobs brat tens beef leap bloc shoo moan boob jeez suet sits rood drag goat stay chip fled fist than loot pets suck peek pled heel hair sill prep char knot lens meek trap jeep beet crew draw tell nets peep meet sows glue bees bent pelt whit need foot bran chop gram chew teen veil lent gees fret soft leis pent gets weed keen reek news prim drab wets sics deed bows pier akin pock geed grey bogs goad skis peck prod loam keep pens hoot best reed yous sewn been tram pest whom bout unit deep boot dual lees omit peel sues berm dock yock shes lets mock grow jell whip lean thin sots geek stem floe tees sort fees gout mead dram said twin prom bras bier heft foul root fell melt bops coup coot atop brad chin moot shoe sacs chit hell door lead feet boon bolt leaf bell bias eery goop reel text boom herd rent leek rend club self send sick term airs frog yell next czar plus mean brow foam crow troy nest heed dell load glib peps cent chow pees bend jock held tent soil poop moor sped emit boss fest crop mews knit tout crag knob grab thaw vial sack help jets very boys flue whir newt wiry beep room pews crab baas cock coop hock blue flee moat skid quit dial brag cell aloe grad hews went leak toad wees mewl coat dent'" + "'brow chit bees hoot weep cock sots dock boob book boys brag bled eery sows cent crow mead aloe coup wiry less goat well vent deed rood moor belt atop bows draw prep chip sewn whom plus bets sued wets mean news czar newt fees chow reek flue troy pled geek boot akin lock bout leek fell feed shoe club heed bolt root peel thin yock vets crew load wees clue brad been meet pert boos beet legs mews self hock moot tell toad lead shoo jell teed sill skis veil glue went step test crop text peck bran teen crab pier bogs boss leis grow lent quit foam bras prod knot trap cell dram very goad felt chop sack omit poop pelt drag gram peps yens jeep brat prim jets goop tees deep dual bobs beef sits baas dyer lets leaf gees feet chew rend sues gent whet chin whip berm whim yell trig blue peek prop leak lean bent yeps bier drab bell foot heel boon fret moan send tens jock brew crag thaw sick beck gets bend pest loan geed herd skid toot grab pees hair poor rock best bloc pens coat bias fest heft mock lees loot gout sped sics tout frog nest flee meek stay weed doer stem peep hews grad peed knit keep pegs next twin blur coop week saws perk lens suet pews foul char vial soil term flea leap pent coot sort nets keen loam beep soft boom twit jeez glib teem than prom yews need veep shes bops dent moat hemp held reed whir whit deem know clef reel soon pock room tent floe pout help fist knob dell melt yous sacs unit door spec said hell mewl emit tram suck grey pets rent fled airs dial'" ] }, - "execution_count": 44, + "execution_count": 159, "metadata": {}, "output_type": "execute_result" } @@ -940,7 +1333,7 @@ }, { "cell_type": "code", - "execution_count": 45, + "execution_count": 160, "metadata": {}, "outputs": [ { @@ -949,7 +1342,7 @@ "['coax', 'coat', 'boat', 'boar', 'soar', 'star', 'stay']" ] }, - "execution_count": 45, + "execution_count": 160, "metadata": {}, "output_type": "execute_result" } @@ -960,24 +1353,24 @@ }, { "cell_type": "code", - "execution_count": 46, + "execution_count": 161, "metadata": {}, "outputs": [ { "name": "stdout", "output_type": "stream", "text": [ - "CPU times: user 620 ms, sys: 4 ms, total: 624 ms\n", - "Wall time: 624 ms\n" + "CPU times: user 848 ms, sys: 0 ns, total: 848 ms\n", + "Wall time: 849 ms\n" ] }, { "data": { "text/plain": [ - "['coax', 'coat', 'chat', 'shat', 'spat', 'spay', 'stay']" + "['coax', 'coat', 'boat', 'boar', 'soar', 'star', 'stay']" ] }, - "execution_count": 46, + "execution_count": 161, "metadata": {}, "output_type": "execute_result" } @@ -988,7 +1381,7 @@ }, { "cell_type": "code", - "execution_count": 47, + "execution_count": 162, "metadata": { "collapsed": true }, @@ -999,7 +1392,7 @@ }, { "cell_type": "code", - "execution_count": 48, + "execution_count": 163, "metadata": {}, "outputs": [ { @@ -1008,7 +1401,7 @@ "['czar', 'tzar', 'tear', 'sear', 'star', 'stay']" ] }, - "execution_count": 48, + "execution_count": 163, "metadata": {}, "output_type": "execute_result" } @@ -1019,7 +1412,7 @@ }, { "cell_type": "code", - "execution_count": 49, + "execution_count": 164, "metadata": { "collapsed": true }, @@ -1030,7 +1423,7 @@ }, { "cell_type": "code", - "execution_count": 50, + "execution_count": 165, "metadata": { "collapsed": true }, @@ -1041,7 +1434,7 @@ }, { "cell_type": "code", - "execution_count": 79, + "execution_count": 166, "metadata": {}, "outputs": [ { @@ -1050,7 +1443,7 @@ "185" ] }, - "execution_count": 79, + "execution_count": 166, "metadata": {}, "output_type": "execute_result" } @@ -1063,7 +1456,7 @@ }, { "cell_type": "code", - "execution_count": 80, + "execution_count": 167, "metadata": { "collapsed": true, "scrolled": true @@ -1110,7 +1503,7 @@ "name": "python", "nbconvert_exporter": "python", "pygments_lexer": "ipython3", - "version": "3.5.2+" + "version": "3.5.3" } }, "nbformat": 4,