Renamed puzzles, added amidakuji
[ou-summer-of-code-2017.git] / 04-word-search / wordsearch-creation.ipynb
diff --git a/04-word-search/wordsearch-creation.ipynb b/04-word-search/wordsearch-creation.ipynb
deleted file mode 100644 (file)
index 52cbbdc..0000000
+++ /dev/null
@@ -1,1704 +0,0 @@
-{
- "cells": [
-  {
-   "cell_type": "code",
-   "execution_count": 206,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "import string\n",
-    "import re\n",
-    "import random\n",
-    "import collections\n",
-    "import copy\n",
-    "import os\n",
-    "\n",
-    "from IPython.display import clear_output\n",
-    "\n",
-    "from enum import Enum\n",
-    "Direction = Enum('Direction', 'left right up down upleft upright downleft downright')\n",
-    "    \n",
-    "delta = {Direction.left: (0, -1),Direction.right: (0, 1), \n",
-    "         Direction.up: (-1, 0), Direction.down: (1, 0), \n",
-    "         Direction.upleft: (-1, -1), Direction.upright: (-1, 1), \n",
-    "         Direction.downleft: (1, -1), Direction.downright: (1, 1)}\n",
-    "\n",
-    "cat = ''.join\n",
-    "wcat = ' '.join\n",
-    "lcat = '\\n'.join"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 180,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "# all_words = [w.strip() for w in open('/usr/share/dict/british-english').readlines()\n",
-    "#             if all(c in string.ascii_lowercase for c in w.strip())]\n",
-    "# words = [w for w in all_words\n",
-    "#          if not any(w in w2 for w2 in all_words if w != w2)]\n",
-    "# open('wordsearch-words', 'w').write(lcat(words))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 181,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "# ws_words = [w.strip() for w in open('wordsearch-words').readlines()\n",
-    "#             if all(c in string.ascii_lowercase for c in w.strip())]\n",
-    "# ws_words[:10]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 182,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "ws_words = [w.strip() for w in open('/usr/share/dict/british-english').readlines()\n",
-    "            if all(c in string.ascii_lowercase for c in w.strip())]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 183,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "62183"
-      ]
-     },
-     "execution_count": 183,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "len([w for w in ws_words if len(w) >= 4])"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 184,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def empty_grid(w, h):\n",
-    "    return [['.' for c in range(w)] for r in range(h)]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 185,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def show_grid(grid):\n",
-    "    return lcat(cat(r) for r in grid)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 186,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "..........\n",
-      "..........\n",
-      "..........\n",
-      "..........\n",
-      "..........\n",
-      "..........\n",
-      "..........\n",
-      "..........\n",
-      "..........\n",
-      "..........\n"
-     ]
-    }
-   ],
-   "source": [
-    "grid = empty_grid(10, 10)\n",
-    "print(show_grid(grid))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 187,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def indices(grid, r, c, l, d):\n",
-    "    dr, dc = delta[d]\n",
-    "    w = len(grid[0])\n",
-    "    h = len(grid)\n",
-    "    inds = [(r + i * dr, c + i * dc) for i in range(l)]\n",
-    "    return [(i, j) for i, j in inds\n",
-    "           if i >= 0\n",
-    "           if j >= 0\n",
-    "           if i < h\n",
-    "           if j < w]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 188,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def gslice(grid, r, c, l, d):\n",
-    "    return [grid[i][j] for i, j in indices(grid, r, c, l, d)]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 189,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def set_grid(grid, r, c, d, word):\n",
-    "    for (i, j), l in zip(indices(grid, r, c, len(word), d), word):\n",
-    "        grid[i][j] = l\n",
-    "    return grid"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 190,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "..........\n",
-      "..........\n",
-      "...t......\n",
-      "....e.....\n",
-      ".....s....\n",
-      "......t...\n",
-      ".......w..\n",
-      "........o.\n",
-      ".........r\n",
-      "..........\n"
-     ]
-    }
-   ],
-   "source": [
-    "set_grid(grid, 2, 3, Direction.downright, 'testword')\n",
-    "print(show_grid(grid))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 191,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "'..e.....'"
-      ]
-     },
-     "execution_count": 191,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "cat(gslice(grid, 3, 2, 15, Direction.right))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 192,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "<_sre.SRE_Match object; span=(0, 4), match='keen'>"
-      ]
-     },
-     "execution_count": 192,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "re.match(cat(gslice(grid, 3, 2, 4, Direction.right)), 'keen')"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 193,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "<_sre.SRE_Match object; span=(0, 3), match='kee'>"
-      ]
-     },
-     "execution_count": 193,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "re.match(cat(gslice(grid, 3, 2, 3, Direction.right)), 'keen')"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 194,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "re.fullmatch(cat(gslice(grid, 3, 2, 3, Direction.right)), 'keen')"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 195,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "re.match(cat(gslice(grid, 3, 2, 4, Direction.right)), 'kine')"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 196,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def could_add(grid, r, c, d, word):\n",
-    "    s = gslice(grid, r, c, len(word), d)\n",
-    "    return re.fullmatch(cat(s), word)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 197,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "<_sre.SRE_Match object; span=(0, 4), match='keen'>"
-      ]
-     },
-     "execution_count": 197,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "could_add(grid, 3, 2, Direction.right, 'keen')"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 198,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "could_add(grid, 3, 2, Direction.right, 'kine')"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 199,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "<Direction.up: 3>"
-      ]
-     },
-     "execution_count": 199,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "random.choice(list(Direction))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 207,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def fill_grid(grid, words, word_count, max_attempts=10000, min_word_len=4):\n",
-    "    attempts = 0\n",
-    "    added_words = []\n",
-    "    w = len(grid[0])\n",
-    "    h = len(grid)\n",
-    "    while len(added_words) < word_count and attempts < max_attempts:\n",
-    "        clear_output(wait=True)\n",
-    "        print(\"Added\", len(added_words), '; attempt', attempts)\n",
-    "        attempts += 1\n",
-    "        r = random.randrange(w)\n",
-    "        c = random.randrange(h)\n",
-    "        word = random.choice(words)\n",
-    "        d = random.choice(list(Direction))\n",
-    "#         print(word, r, c, d, \n",
-    "#               len(word) >= min_word_len, \n",
-    "#               not any(word in w2 for w2 in added_words), \n",
-    "#               could_add(grid, r, c, d, word), \n",
-    "#               not present(grid, word)[0]\n",
-    "#              )\n",
-    "        if (len(word) >= min_word_len\n",
-    "              and not any(word in w2 for w2 in added_words) \n",
-    "              and could_add(grid, r, c, d, word)\n",
-    "              and not present(grid, word)[0]):\n",
-    "            grid2 = copy.deepcopy(grid)\n",
-    "            set_grid(grid2, r, c, d, word)\n",
-    "#             print(present_many(grid2, [word]))\n",
-    "            if collections.Counter(p[0] for p in \n",
-    "                                   present_many(grid2, added_words + [word])).most_common(1)[0][1] == 1:\n",
-    "                set_grid(grid, r, c, d, word)\n",
-    "                added_words += [word]\n",
-    "                attempts = 0\n",
-    "    return grid, added_words"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 201,
-   "metadata": {},
-   "outputs": [
-    {
-     "ename": "KeyboardInterrupt",
-     "evalue": "",
-     "output_type": "error",
-     "traceback": [
-      "\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
-      "\u001b[0;31mKeyboardInterrupt\u001b[0m                         Traceback (most recent call last)",
-      "\u001b[0;32m<ipython-input-201-6ab66457c812>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0mg\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mempty_grid\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0;36m20\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m20\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m \u001b[0mg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mws\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mfill_grid\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mg\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mws_words\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0;36m40\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      3\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mws\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m<ipython-input-200-42497f37ad7f>\u001b[0m in \u001b[0;36mfill_grid\u001b[0;34m(grid, words, word_count, max_attempts, min_word_len)\u001b[0m\n\u001b[1;32m     24\u001b[0m \u001b[0;31m#             print(present_many(grid2, [word]))\u001b[0m\u001b[0;34m\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     25\u001b[0m             if collections.Counter(p[0] for p in \n\u001b[0;32m---> 26\u001b[0;31m                                    present_many(grid2, added_words + [word])).most_common(1)[0][1] == 1:\n\u001b[0m\u001b[1;32m     27\u001b[0m                 \u001b[0mset_grid\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgrid\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mword\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     28\u001b[0m                 \u001b[0madded_words\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mword\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m<ipython-input-123-ff8574b12cf0>\u001b[0m in \u001b[0;36mpresent_many\u001b[0;34m(grid, words)\u001b[0m\n\u001b[1;32m      8\u001b[0m             \u001b[0;32mfor\u001b[0m \u001b[0md\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mDirection\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      9\u001b[0m                 \u001b[0;32mfor\u001b[0m \u001b[0mwordlen\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mwordlens\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m---> 10\u001b[0;31m                     \u001b[0mword\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mcat\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgslice\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgrid\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mwordlen\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m     11\u001b[0m                     \u001b[0;32mif\u001b[0m \u001b[0mword\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mwords\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m     12\u001b[0m                         \u001b[0mpresences\u001b[0m \u001b[0;34m+=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mword\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;32m<ipython-input-188-a5adda74be28>\u001b[0m in \u001b[0;36mgslice\u001b[0;34m(grid, r, c, l, d)\u001b[0m\n\u001b[1;32m      1\u001b[0m \u001b[0;32mdef\u001b[0m \u001b[0mgslice\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgrid\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ml\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0;32m----> 2\u001b[0;31m     \u001b[0;32mreturn\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0mgrid\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mi\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0mj\u001b[0m\u001b[0;34m]\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mj\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mindices\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgrid\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ml\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
-      "\u001b[0;32m<ipython-input-187-e0e67252b972>\u001b[0m in \u001b[0;36mindices\u001b[0;34m(grid, r, c, l, d)\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0;32mdef\u001b[0m \u001b[0mindices\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgrid\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0ml\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0md\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m:\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m\u001b[1;32m      2\u001b[0m     \u001b[0mdr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mdc\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mdelta\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0md\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      3\u001b[0m     \u001b[0mw\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgrid\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      4\u001b[0m     \u001b[0mh\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0mlen\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mgrid\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[1;32m      5\u001b[0m     \u001b[0minds\u001b[0m \u001b[0;34m=\u001b[0m \u001b[0;34m[\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0mr\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mi\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mdr\u001b[0m\u001b[0;34m,\u001b[0m \u001b[0mc\u001b[0m \u001b[0;34m+\u001b[0m \u001b[0mi\u001b[0m \u001b[0;34m*\u001b[0m \u001b[0mdc\u001b[0m\u001b[0;34m)\u001b[0m \u001b[0;32mfor\u001b[0m \u001b[0mi\u001b[0m \u001b[0;32min\u001b[0m \u001b[0mrange\u001b[0m\u001b[0;34m(\u001b[0m\u001b[0ml\u001b[0m\u001b[0;34m)\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n",
-      "\u001b[0;31mKeyboardInterrupt\u001b[0m: "
-     ]
-    }
-   ],
-   "source": [
-    "g = empty_grid(20, 20)\n",
-    "g, ws = fill_grid(g, ws_words, 40)\n",
-    "len(ws)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "print(show_grid(g))\n",
-    "print(len(ws), 'words added')\n",
-    "print(wcat(ws))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def present(grid, word):\n",
-    "    w = len(grid[0])\n",
-    "    h = len(grid)\n",
-    "    for r in range(h):\n",
-    "        for c in range(w):\n",
-    "            for d in Direction:\n",
-    "                if cat(gslice(grid, r, c, len(word), d)) == word:\n",
-    "                    return True, r, c, d\n",
-    "    return False, 0, 0, list(Direction)[0]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def present_many(grid, words):\n",
-    "    w = len(grid[0])\n",
-    "    h = len(grid)\n",
-    "    wordlens = set(len(w) for w in words)\n",
-    "    presences = []\n",
-    "    for r in range(h):\n",
-    "        for c in range(w):\n",
-    "            for d in Direction:\n",
-    "                for wordlen in wordlens:\n",
-    "                    word = cat(gslice(grid, r, c, wordlen, d))\n",
-    "                    if word in words:\n",
-    "                        presences += [(word, r, c, d)]\n",
-    "    return set(presences)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "for w in ws:\n",
-    "    print(w, present(g, w))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def interesting(grid, words, words_limit=40, direction_slack=1):\n",
-    "    dirs = set(present(grid, w)[3] for w in words)\n",
-    "    return len(words) > words_limit and len(dirs) + direction_slack >= len(delta)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "interesting(g, ws)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def interesting_grid(width=20, height=20, words_limit=40, max_words=80, direction_slack=1):\n",
-    "    boring = True\n",
-    "    while boring:\n",
-    "        grid = empty_grid(width, height)\n",
-    "        grid, words = fill_grid(grid, ws_words, max_words)\n",
-    "        boring = not interesting(grid, words, words_limit=words_limit, direction_slack=direction_slack)\n",
-    "    return grid, words"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "g, ws = interesting_grid()\n",
-    "print(show_grid(g))\n",
-    "print(len(ws), 'words added; ', len(set(present(g, w)[3] for w in ws)), 'directions')\n",
-    "print(wcat(ws))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def datafile(name, sep='\\t'):\n",
-    "    \"\"\"Read key,value pairs from file.\n",
-    "    \"\"\"\n",
-    "    with open(name) as f:\n",
-    "        for line in f:\n",
-    "            splits = line.split(sep)\n",
-    "            yield [splits[0], int(splits[1])]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def normalise(frequencies):\n",
-    "    \"\"\"Scale a set of frequencies so they sum to one\n",
-    "    \n",
-    "    >>> sorted(normalise({1: 1, 2: 0}).items())\n",
-    "    [(1, 1.0), (2, 0.0)]\n",
-    "    >>> sorted(normalise({1: 1, 2: 1}).items())\n",
-    "    [(1, 0.5), (2, 0.5)]\n",
-    "    >>> sorted(normalise({1: 1, 2: 1, 3: 1}).items()) # doctest: +ELLIPSIS\n",
-    "    [(1, 0.333...), (2, 0.333...), (3, 0.333...)]\n",
-    "    >>> sorted(normalise({1: 1, 2: 2, 3: 1}).items())\n",
-    "    [(1, 0.25), (2, 0.5), (3, 0.25)]\n",
-    "    \"\"\"\n",
-    "    length = sum(f for f in frequencies.values())\n",
-    "    return collections.defaultdict(int, ((k, v / length) \n",
-    "        for (k, v) in frequencies.items()))\n"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "english_counts = collections.Counter(dict(datafile('count_1l.txt')))\n",
-    "normalised_english_counts = normalise(english_counts)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "wordsearch_counts = collections.Counter(cat(ws_words))\n",
-    "normalised_wordsearch_counts = normalise(wordsearch_counts)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "normalised_wordsearch_counts = normalise(collections.Counter(normalised_wordsearch_counts) + collections.Counter({l: 0.05 for l in string.ascii_lowercase}))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def weighted_choice(d):\n",
-    "    \"\"\"Generate random item from a dictionary of item counts\n",
-    "    \"\"\"\n",
-    "    target = random.uniform(0, sum(d.values()))\n",
-    "    cuml = 0.0\n",
-    "    for (l, p) in d.items():\n",
-    "        cuml += p\n",
-    "        if cuml > target:\n",
-    "            return l\n",
-    "    return None\n",
-    "\n",
-    "def random_english_letter():\n",
-    "    \"\"\"Generate a random letter based on English letter counts\n",
-    "    \"\"\"\n",
-    "    return weighted_choice(normalised_english_counts)\n",
-    "\n",
-    "def random_wordsearch_letter():\n",
-    "    \"\"\"Generate a random letter based on wordsearch letter counts\n",
-    "    \"\"\"\n",
-    "    return weighted_choice(normalised_wordsearch_counts)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "cat(sorted(random_english_letter() for i in range(100)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "cat(sorted(random_wordsearch_letter() for i in range(100)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "random_wordsearch_letter()"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def pad_grid(g0):\n",
-    "    grid = copy.deepcopy(g0)\n",
-    "    w = len(grid[0])\n",
-    "    h = len(grid)\n",
-    "    for r in range(h):\n",
-    "        for c in range(w):\n",
-    "            if grid[r][c] == '.':\n",
-    "                grid[r][c] = random_wordsearch_letter()\n",
-    "    return grid"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "padded = pad_grid(g)\n",
-    "print(show_grid(padded))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "print(show_grid(g))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "for w in ws:\n",
-    "    print(w, present(padded, w))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def decoys(grid, words, all_words, limit=100):\n",
-    "    decoy_words = []\n",
-    "    dlen_limit = max(len(w) for w in words)\n",
-    "    while len(words) + len(decoy_words) < limit:\n",
-    "        d = random.choice(all_words)\n",
-    "        if d not in words and len(d) >= 4 and len(d) <= dlen_limit and not present(grid, d)[0]:\n",
-    "            decoy_words += [d]\n",
-    "    return decoy_words"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def decoys(grid, words, all_words, limit=100, min_word_len=4):\n",
-    "    decoy_words = []\n",
-    "#     dlen_limit = max(len(w) for w in words)\n",
-    "    while len(words) + len(decoy_words) < limit:\n",
-    "        d = random.choice(all_words)\n",
-    "        if d not in words and len(d) >= min_word_len and not present(grid, d)[0]:\n",
-    "            decoy_words += [d]\n",
-    "    return decoy_words"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "ds = decoys(padded, ws, ws_words)\n",
-    "ds"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "for w in ws + ds:\n",
-    "    print(w, present(padded, w))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "g, ws = interesting_grid()\n",
-    "p = pad_grid(g)\n",
-    "ds = decoys(p, ws, ws_words)\n",
-    "print(show_grid(g))\n",
-    "print(show_grid(p))\n",
-    "print(len(ws), 'words added; ', len(set(present(g, w)[3] for w in ws)), 'directions')\n",
-    "print('Present:', wcat(sorted(ws)))\n",
-    "print('Decoys:', wcat(sorted(ds)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "g, ws = interesting_grid(width=10, height=10, words_limit=5, direction_slack=6)\n",
-    "p = pad_grid(g)\n",
-    "ds = decoys(p, ws, ws_words)\n",
-    "print(show_grid(g))\n",
-    "print()\n",
-    "print(show_grid(p))\n",
-    "print(len(ws), 'words added; ', len(set(present(g, w)[3] for w in ws)), 'directions')\n",
-    "print('Present:', wcat(sorted(ws)))\n",
-    "print('Decoys:', wcat(sorted(ds)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "ds_original = ['regards', 'perfect', 'instants', 'refined', 'coddle', 'fickler', 'gambol', 'misprint', 'tapes', 'impugns', 'moonshot', 'chump', 'brick', 'siren', 'faddish', 'winced', 'kielbasy', 'market', 'puckered', 'trains', 'welts', 'cackles', 'foaming', 'proceed', 'gliding', 'guts', 'uric', 'oaks', 'molested', 'curled', 'boor', 'solaria', 'gristle', 'bombing', 'loamier', 'ensuing', 'cunt', 'sunder', 'revel', 'coaster', 'grunts', 'mucking', 'typesets', 'carnal', 'whimsy', 'scoff', 'coccyxes', 'meanly', 'sprain', 'minuend', 'ringlet', 'fest', 'winced', 'shinier', 'dicier', 'thirds', 'olives', 'garoting', 'pastrami', 'tranquil', 'tamped', 'sunup', 'crumbled', 'throw', 'ridges', 'chaplets', 'curlier', 'lugs', 'collies', 'adapting', 'demeanor', 'deepen', 'lanyard', 'tiller', 'transfix', 'wariness', 'times', 'mitts', 'dowses', 'creels', 'curds', 'quashed', 'orgasmic', 'ibex', 'retraces', 'casino']\n",
-    "ds = random.sample(ds_original, 15)\n",
-    "ds"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "ds_original"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "print('grid = ', g)\n",
-    "print('padded_grid = ', p)\n",
-    "print('present_words = ', ws)\n",
-    "print('decoy_words = ', ds)\n",
-    "print('Directions: ', [(w, '`' + str(present(g, w)) + '`') for w in ws])"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "# with open('example-wordsearch.txt', 'w') as f:\n",
-    "#     f.write('10x10\\n')\n",
-    "#     f.write(show_grid(p))\n",
-    "#     f.write('\\n')\n",
-    "#     f.write(lcat(sorted(ws + ds)))\n",
-    "# with open('exmaple-wordsearch-solution.txt', 'w') as f:\n",
-    "#     f.write('10x10\\n')\n",
-    "#     f.write(show_grid(g))\n",
-    "#     f.write('\\n')\n",
-    "#     f.write(lcat(sorted(ws)) + '\\n\\n')\n",
-    "#     f.write(lcat(sorted(ds)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "cts = collections.Counter()\n",
-    "for w in ws:\n",
-    "    _, r, c, d = present(g, w)\n",
-    "    inds = indices(g, r, c, len(w), d)\n",
-    "    for i in inds:\n",
-    "        cts[i] += 1\n",
-    "    print(w, r, c, len(w), d, inds)\n",
-    "[i for i in cts if cts[i] > 1]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": []
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true,
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "# for i in range(100):\n",
-    "#     print(i)\n",
-    "#     g, ws = interesting_grid()\n",
-    "#     p = pad_grid(g)\n",
-    "#     ds = decoys(p, ws, ws_words)\n",
-    "#     with open('wordsearch{:02}.txt'.format(i), 'w') as f:\n",
-    "#         f.write('20x20\\n')\n",
-    "#         f.write(show_grid(p))\n",
-    "#         f.write('\\n')\n",
-    "#         f.write(lcat(sorted(ws + ds)))\n",
-    "#     with open('wordsearch-solution{:02}.txt'.format(i), 'w') as f:\n",
-    "#         f.write('20x20\\n')\n",
-    "#         f.write(show_grid(g))\n",
-    "#         f.write('\\n')\n",
-    "#         f.write(lcat(sorted(ws)) + '\\n\\n')\n",
-    "#         f.write(lcat(sorted(ds)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "g, ws = interesting_grid(width=100, height=100, words_limit=1, max_words=2000, direction_slack=1)\n",
-    "p = pad_grid(g)\n",
-    "ds = decoys(p, ws, ws_words, limit=2500)\n",
-    "# print(show_grid(g))\n",
-    "# print()\n",
-    "# print(show_grid(p))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "print(len(ws), 'words added; ', len(set(present(g, w)[3] for w in ws)), 'directions')\n",
-    "# print('Present:', wcat(sorted(ws)))\n",
-    "# print('Decoys:', wcat(sorted(ds)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true,
-    "scrolled": true
-   },
-   "outputs": [],
-   "source": [
-    "with open('huge-wordsearch.txt', 'w') as f:\n",
-    "        f.write('{}x{}\\n'.format(len(g[0]), len(g)))\n",
-    "        f.write(show_grid(p))\n",
-    "        f.write('\\n')\n",
-    "        f.write(lcat(sorted(ws + ds)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def read_wordsearch(fn):\n",
-    "    lines = [l.strip() for l in open(fn).readlines()]\n",
-    "    w, h = [int(s) for s in lines[0].split('x')]\n",
-    "    grid = lines[1:h+1]\n",
-    "    words = lines[h+1:]\n",
-    "    return w, h, grid, words"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "def do_wordsearch_tasks(fn, show_anyway=False):\n",
-    "    width, height, grid, words = read_wordsearch(fn)\n",
-    "    used_words = [w for w in words if present(grid, w)[0]]\n",
-    "    unused_words = [w for w in words if not present(grid, w)[0]]\n",
-    "    lwp = sorted([w for w in words if present(grid, w)[0]], key=len)[-1]\n",
-    "    lwps = [w for w in used_words if len(w) == len(lwp)]\n",
-    "    lwa = sorted(unused_words, key=len)[-1]\n",
-    "    lwas = [w for w in unused_words if len(w) == len(lwa)]\n",
-    "    g0 = empty_grid(width, height)\n",
-    "    for w in words:\n",
-    "        p, r, c, d = present(grid, w)\n",
-    "        if p:\n",
-    "            set_grid(g0, r, c, d, w) \n",
-    "    unused_letters = [l for l, u in zip((c for c in cat(cat(l) for l in grid)), (c for c in cat(cat(l) for l in g0)))\n",
-    "                  if u == '.']\n",
-    "    unused_letter_count = collections.Counter(unused_letters)\n",
-    "    makeable_words = []\n",
-    "    for w in unused_words:\n",
-    "        unused_word_count = collections.Counter(w)\n",
-    "        if all(unused_word_count[l] <= unused_letter_count[l] for l in unused_word_count):\n",
-    "            makeable_words += [w]\n",
-    "    lwm = sorted(makeable_words, key=len)[-1]\n",
-    "    lwms = [w for w in makeable_words if len(w) == len(lwm)]\n",
-    "    if show_anyway or len(set((len(lwp),len(lwa),len(lwm)))) == 3:\n",
-    "        print('\\n{}'.format(fn))\n",
-    "        print('{} words present'.format(len(words) - len(unused_words)))\n",
-    "        print('Longest word present: {}, {} letters ({})'.format(lwp, len(lwp), lwps))\n",
-    "        print('Longest word absent: {}, {} letters ({})'.format(lwa, len(lwa), lwas))\n",
-    "        print('{} unused letters'.format(len([c for c in cat(cat(l) for l in g0) if c == '.'])))\n",
-    "        print('Longest makeable word: {}, {} ({})'.format(lwm, len(lwm), lwms))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "[w for w in ws_words if len(w) == 16]"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "# all_lines = []\n",
-    "# for fn in sorted(os.listdir()):\n",
-    "#     if re.match('wordsearch\\d\\d\\.txt', fn):\n",
-    "#         all_lines += open(fn).readlines()\n",
-    "#         all_lines += ['\\n'] * 2\n",
-    "\n",
-    "# open('all-wordsearches.txt', 'w').writelines(all_lines)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 209,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Added 6 ; attempt 19\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "6"
-      ]
-     },
-     "execution_count": 209,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "g = empty_grid(10, 10)\n",
-    "g, ws = fill_grid(g, ws_words, 200, min_word_len=4, max_attempts=20)\n",
-    "len(ws)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 210,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Added 1149 ; attempt 9427\n"
-     ]
-    },
-    {
-     "name": "stderr",
-     "output_type": "stream",
-     "text": [
-      "IOPub message rate exceeded.\n",
-      "The notebook server will temporarily stop sending output\n",
-      "to the client in order to avoid crashing it.\n",
-      "To change this limit, set the config variable\n",
-      "`--NotebookApp.iopub_msg_rate_limit`.\n"
-     ]
-    }
-   ],
-   "source": [
-    "g = empty_grid(100, 100)\n",
-    "g, ws = fill_grid(g, ws_words, 2000, min_word_len=5)\n",
-    "len(ws)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 216,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "(1149, 1149, [('scofflaw', 1)])"
-      ]
-     },
-     "execution_count": 216,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "pm = present_many(g, ws)\n",
-    "pold = [w for w in ws if present(g, w)[0]]\n",
-    "len(pm), len(pold), collections.Counter(p[0] for p in pm).most_common(1)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 219,
-   "metadata": {},
-   "outputs": [],
-   "source": [
-    "\n",
-    "with open('huge-unpadded-wordsearch.txt', 'w') as f:\n",
-    "        f.write('{}x{}\\n'.format(len(g[0]), len(g)))\n",
-    "        f.write(show_grid(g))\n",
-    "        f.write('\\n')\n",
-    "        f.write(lcat(sorted(ws)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 218,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "smuiclacphysics.hcnebrevilingd..skcabllup.s...gnitnacs..blusted.....pilafeldrig..enquireddetnawnu...\n",
-      "e....nutmegs.t..telbanimret...e..tseikwagewoodpeckerstirwas.b.r...picksn...ylhsiroobsuspectingsexevd\n",
-      "cgnittacdliw..isuoniallivsegas.lrafts.y.vcs..demrofsnart.mla...e.c....e..fannysdiscrimination.oe..e.\n",
-      "nnytima.wharfrep.stswashbucklersw....m.eos...noprat....ao.rs....t.h..m.relabele..sss...b.sc.ts..vb.s\n",
-      "eid..desivedaia.shegdtg.gniyugys.o..a.rme.gpantedsobeysodgm.a....t.osabound...s.bttp...uje.orhd.boe.\n",
-      "tverediw...dtlw.eiar.ehacrierhsrmccosiant.nbestridi..sreepegarotedadr.slaropauses..e..rdis.oteia.lld\n",
-      "nardd.p...itli.i.pesu.srwe...ciuuhfsnti.sgingivitislubl.fotkcuhs..rmsensitisedeu...eleygbutsiyjcf.u.\n",
-      "eerne.u..aiin.r.i.nset.ioku..taeia.gods.e.n..dh.n.emld.r.lht.hobnobsi.s..l.c.trs...jnb.ieoizw.llka.f\n",
-      "shiense.nhae.s.n.aietun.owig.idtrp.srsayi.w..ogu.oecnie..yo.u...whmt.t..u.a.lcds...tb.ondran.oeersa.\n",
-      ".nhpnnktsts...g.d.cve.qe.pblohdoaseomtc.r.a.tgnrgdnaiae.spd.sc.sora...nt.r.en.no..ro...g.l..msbfdue.\n",
-      ".asxiiasehcnerdj.moido.edsoayvebr.w.ufh.rtr.sgiaxgdekm.rtfo.k.noir.....ag.se..ur.al..sreraehsu.xnoet\n",
-      "gr.erah.peeweeu.i.tdir..h.acc.mard..tie.u.pdeehbo.eyx.u.ralge.kucnoveltiesseirfdp..buttocksn..laodne\n",
-      "nr.sgls..d..sdwrg.iela...c.uikise.o.altwf.i.idcbtged...poeoatsqo...gratefully..sportingsweepersaa..s\n",
-      "iaw.bp...e.hgor.ulnnstullee.ntl.t.mttps.os..d.tienstc...nhggcst.gsugaringinsight..snifters.....cde.i\n",
-      "nta..m..ssteno..i.eckef..b...ar..y.ieu.lpls.n.endirswu..gsiehs..n.delbaf....interpose..dsurt..r.el.u\n",
-      "oeg..oae.usdr..kl..ecd.aiproveso..llsdsayeb.a.ra.iee.er.l.esih.ti.sllihygrellapractisedatcneea..gg.r\n",
-      "sdeb.cziofe.r.e.d..da..rgthrive.p.agearetr.hs.stsavr..riy.srec.ar.pocketbooktrotxe.....nw.unlk..gg.b\n",
-      "a.re.a.m.rs.espumoneb.t..o.semorhc.rnadau.istp.eehio..cpoga.sn.uuyratchetswisher.....n.se..fepc.aos.\n",
-      "e.saf...fsrrh.a.retpada...t.....e.iggiiv.llcaam.vgnt.o.t.sidtu.pj.r.retemarapecnarussau.a.l.frpante.\n",
-      "rretarcurne.c.g.pellagra...s...d.wni.dk.elgnaae.inusm..msgibehfedtsl..prowldenimn.shiedrka...l.il.ss\n",
-      "n..i..leatgbt.rc..s..sesitengamedinkafgnonn.tladta.m....uentbl.aa.oeegniyartrop.eseitoobsnoleme.tpuu\n",
-      "ub.f.lent.gri.afassevissimagingslgiryuoriit...nsahaseigodniiyelwb..upwthguorb.obmil....hfeedings..tr\n",
-      ".a.yydne..aew.ryrri.emackintoshw.trsbnasnh.u..trksr.gasketrpc.raar..ptereinterpretingie....deggiwtnp\n",
-      ".s..nyl...raslitloeett.splinesobtih.gnlgtkt.r.ealwasset....usu.bvgi..eej......rtss.dnrtonnaccords.oa\n",
-      ".ihikers..bkawa.rtssrao...gc.r.yek..ues..rhn.ennaob.gmovers.bid.riwcsketches.esar.etsi.gswollefdebcs\n",
-      ".leticilli.zaen..uftsrnv..log..dils.rrc..noau.nitrlbr.eidrib.iwa.irea..st...ieiadxe.n.lrolocsid....s\n",
-      "sr...m....edl.s...loyeage.ap...e.pc....h..ilk.am.roouevilamsidv.r.e.gt..ge.gfdeaer.s.ygnideerbnquoit\n",
-      "reprobatesdiyruovasbs.d.oddu..hks..h.s..e..kliee.uoae.lairetsigamt.r..e..nneedmsp.t.p.incisesuhctulc\n",
-      "s.vr.t.sdld..s.controllablel.s.aleavese..l..s..s.btrshalvesylsuougibma.s.sim.pgo.avhshortensr.zzazip\n",
-      ".ebae.oliedpmsuesilangisg..a..hc.zingsyy..oqueryingdoreopened..endless...l.bs.lrlsnikskcub.t..knifed\n",
-      "jiklruons.lefilbsnwodwohsn.ttupnit..tdretsenohl..cvsm...gnimirgnidaetsemoh..baamongst..y.wucustomers\n",
-      "doionfgh.a.lsotej.....e.h.iee...gniretnuas..s..o.oa.e.g.r...snoitulos.selppitue..w...io.trrbfruits..\n",
-      ".eydj.g.n..i.iutvosplithsejlhp.s.eieinveighing..mnl.rlbu..pineapple....a.f.e.nsrealiseadel.ar.eevell\n",
-      "r.ertu.e..gc..dleoi....htiiyi.m.avr..transducers.fe.aatempts.b.....d.n.f.ud.t.scales.r.tr.aopinion.l\n",
-      ".d.yoveterinaryoenrn..a.bapg.wjuin..psalmist.x...innlenvd...iebrashereat.ne...snaeco..aeiide.ps...ii\n",
-      "..pb.dtacosei.l.sr.gim.b.eb.ho.nrideraems....opa.dcdri.ie..n.lv.sc.k.kweent.outsmartedwl.oaef.ek..mb\n",
-      "feweste....p.v.a.p..enisreesbtg..t.h.e.k.tt..bem.eecas.lpggday.ipmrn.akrqeasedoberofmrr.l.nhp..de.pn\n",
-      "dy.sighting...o.spalfngsd..b.cellistott.nscc.hdesshlhe.leinde.aas.ea.ewnulcsekytmrg.oa..co..la...tao\n",
-      ".ddr..object...r.aehg.ee..ipr......degmreioascontrrits.an.oieinw.umlzwaoa.iss..i.netu.midictatorialo\n",
-      ".e.em..muiretcab.sn.rnh.gnoigimletslry.denreftmdie.trsygdm.rssvsealplyrobcll.gx.i.egusnm..b.c.ps..ap\n",
-      ".pstekcolsopyh..s...schngpsteppes.esoadwcaib.aesvsrhiiree.iprikvrc.l.ydniapisenb.banaoicar.yagr...ss\n",
-      "ep.sew......macinimin.islp..s....xrpaotoirdf.mto.eoomharntse.elti.a.a.eslrxarebiajdahvalaslprnoarbez\n",
-      "so.ykbongothistlektass.iidsreg..e.ia.lreogaiweevilgg..n.tagrw.ia.d.r..s.ioemsoinsa.pnnavtr.adidllucs\n",
-      "il.oloverwhelmednilni.neegee.cnd.as.mduvrch.n.r..lurd.oarnasenilesab..t.tul.stkxuie.ctesae.rigd.....\n",
-      "rp..y.......l..ivbal.nrigdn.l.ni.n.damava..t.g...seaeyi.ik..se...rtheoryysab.shnolreeril.edknniesohw\n",
-      "oproponents.etli.kacotr.in.o.t.en.innsidu...relruc.pgetge.d.lciportosi...ega.itgeplpyautge.egon.ar..\n",
-      "ecaudalyokelrst.ynoiif.l.piklstsrrtf.aenvoyeuristichnludta.b.se.i.ngnirabrer.entuleaugsno.gd.rgdlibd\n",
-      "h..configurationontnt.g...omr.toteo.fsg.g..stsefni.yora.psa.t.l.msa.....e.rbd.sseol.e.at.x.dwhesieee\n",
-      "tpalsy.r..c.e..ivcsrscinap.tma.irsfm.uliuqnartoday..racp.neo..u.plncaninev.eg.eduynr.rg.e.ieat.lgngp\n",
-      "..fleshyuk.s.dteeme.eruptingtah.lhir.gm.r.contrastedhbe.ugni..p.uei.yamsidad.nreal..r.ny.rrntc.antoy\n",
-      "....yogins..earnis..ripeness.edsmethe.na.bsromalgte.trr.ni..k.m.lemigfieryed..iwvtta.wia.hnis.ss.eth\n",
-      "nonhuman..knnsnte...e...cupolargiitapt.igreideew.s.re.pie....oaespo.nrcb.y.ke.wlfiee.hdws.p...mu.d..\n",
-      "bywords...osiohme..estnemegagnedlnstcon.ya...primessn.mshockerhleyd..sehe.t.ssealra.daua.s....ar....\n",
-      "outlastedt.ocsb.c.x....enilefileeavgotsi.lrfordssgt..ettautnessbdebbadieil.p.ur.po.w.lle......oe.k.g\n",
-      "ddetsyrte.n..l.gnp.esuccocddypl.ppdeisi..rlpimplyn..ecg..dsuitcases.a.ksnfl.mdtnekrahecs.etsawfpn.cn\n",
-      "iawaitss.s..e.a.e..lp....euhauwpi.udrv.ve..er.a..udt..as.se...ctlocn.c.ltifsretaehcc.rnempollenag.ii\n",
-      "essertsimdaehrsci.gdr...tstrcocrn.stesidi..ejs...o.e..erq..lt.i.akaco.ksussocondoretsaocno....tdnnls\n",
-      "s.rettab.es.rptgc.ide..itaeidodohb.cynen.sn.o....y..vrcua..uclb.earhgiyhla.hn..lebil..c..ak..senioli\n",
-      "retsim.tlu.eoo.rssfaa.xsendns.ehoqa.oeesgdtpmoppets.ueeu.moseyu.cygan.tlaib..detoormoisterpe.l.olial\n",
-      "......hbbdtpr..inmt.desrtaetjhpilu.rlrtdsso.derunettceirltesl.csneofis.aenssregnifrettub...od.asbtha\n",
-      "sfeergalebia.f.noui.iobattlae.ebei.bdwe..r..os...gpoz.orslsl.le.odefdr..tvdn...adjectivess.dr.geaapr\n",
-      "....isitultscrbdccn.n.lelipa.gnime..is.dp....we..ane.b..toi..bikc.sener..ii.eslays.rp..c.du..pagnr.t\n",
-      "f..limocleiasoaegsgignduear..udtut.l...gambol.nsrv.ib.o.re.ni..mupfdete..ysa.t....ea.oa..fetm.taeu.n\n",
-      "o.ideokoslb.ewnr.nrso.psnss.reeifelatrinems....ei..etb.s..rvg...ol..rtc.y.lin.u..t.lsne.cp.tceeyypte\n",
-      "owd.mel.ear.isir.eipeatsenye.snvfr..latticeworkndlrfesgnihsalpslagf.suunsprlv...u..otk.tardslassgpcc\n",
-      "t.yltd.dl.e.hysam.uhtl.so.tm.scelcascadinghl..c.asiyrse.vexed.tsng.fshpaslpua..c.oasislliiumtocsguie\n",
-      "wynifnpseydscetdso.acyyi.e..i.elihslanifbstsle.r.vevrycv.....rhi.ne.tsetoahdstaupset..eascae.rj.isvd\n",
-      "euamrae.sliuraeicccecnttmstner.yn.st....olansonsade.ieeoi...oeo..i.ga.rubqyaito..deposittdaat.a.wael\n",
-      "apmeitr.ussrarra..aaraiosgy...g.g.gie...tewor.wart.n.cbrfd.odds.hrpnb.ar.usddlltpoesyrr.js.l...wt.he\n",
-      "rpisasmtoutgid.l..ilctnl.nabiopsy.gnbi..cwsii.gepei.g..u.fn.ee.cseiimptaweiecoae..s.euyu...ynominees\n",
-      ".ictrsiarorerr..gdiipoi.fiwgnilratsnibu.hortcgn.saef.e.rtslrre.lcknlooelahcka.rvre.isdraeslather...r\n",
-      "yekopuspalirtu.eenf.re.m.nbslartueneiloqebeakoihstlhi.ru...ap.aaonilculirskrs..nnsntaarttdetcartsbao\n",
-      ".s.n.bsrclcyamnmei.h.pl..nu.deniapeptllns.kvslky.mymce.fs.mawussrane.nasdaiut.ylsasetmae.canoes.oe.m\n",
-      "...e.oio.at.ptmrt.c..r...estappinggp.odos.cahfnm..imi.dfl.c.gtudihgv.cieiunlerugpshietetniksgipdnt..\n",
-      "flierroo.cs.liac.gunfire.pwhimsd..aa..grr.ucasue...rmn.lis.hidu.n..i.etdnqgerfoceaodidsdewotwokrgals\n",
-      "latconnm.f.e..epaimedc...deducesddshs..aunfx..rn....kugie.tgdl..g..n..y.g.nawn.krnilse.snoopingisgil\n",
-      "obmibsss..asir..l..a.eeviecerggee.em....ecue..tstoadspynveael....resonantgtan.ugseiti.ruolev...freao\n",
-      "u..gdarnsspegniciee.sylbatonarpgfhrsodomychaiserelbmuh.grtnsstseebedliw.o.la.p..ncmpr.enrapturetertv\n",
-      "t...rd...oncc.t.srnclennut.cainoaap...od..bfrolics.k....o.rosseforp...brazzesb.laopa.eseifidoc.elgee\n",
-      "v...ee..o..ooe.eslsth.ke...drarnwan.l.es..a...sc.liatesrohc.sdellennekgi..s.u.af.albtkn...clawsrigrn\n",
-      "o..bdbyc....krsindekyasa..etredsdodi.l.re.l..tgo.nobscuredhh..securere..al.c.nsfn.iace.i.coupledoanl\n",
-      "t.mei.si..maximaltedynn.sdstss.doem.iebe.dm.n.nng.gnippohca....m....dt..eso.dnes.a.operpetuatingbo.i\n",
-      "eegggclassroomss...ral.t.pssp.ewbidtlelpd.yedoic.g.....s.dnm..otopaetn.t.lsmov..sfh.s.piling....i..e\n",
-      "dahh.n...h..pecnarpeeti.yeeredsrte.ere.e..mdepkrn.np....iucsun..ae...eotisaie..eis.ey.rknittings..br\n",
-      "rt.eenickinglfy...l.rdig..ie.neet.cev.ha.eo.naceo.wispsenme.eie.gr..lmncertrntdxs.bdpsao.tokenismda.\n",
-      "...dla.g..i.oar.cc.e.onchnn.ktihttfi.s.lgg.lwqitcp.en.rpttmt.ldnn.ti.i.bkii.hgeamyseprzk.r..mld.e.l.\n",
-      ".vwkibp.a.n.wlo.ifg..g.ugtw.afglrtr.i..nwpa.auleae.crorpoaaek.ueo.ssoai.ds.a.ryognhkaaec..euye.ce.ad\n",
-      "..ai.nmseph.msvsta..st.qh.ow.iiirden..iornp.pes.ec.eboigarxcrld.tslp.r.ahsw.sitsra.ortde..svt.a.ndne\n",
-      "b.rl.inacae.aeatel.yortuetl.l.fn.irr.rooe..e.s..dcv.vuytireypii.i.a.c.rlessdnoluvy.pcsggsidaim.aoect\n",
-      "u.loi.rerrr.nssacs.tuoaac.bp.y..iuakfdpr..egatsopasetznlapsni.nmf.zs.tynctrgrato..c.so.in.repnr.rbet\n",
-      "tgibps.idceott.nsi.ittnrntnalaesfsnnseysword.c..lrdedoygst.lrnggisi.xaoinoscvrcharsa.cngmesiamn.kkdu\n",
-      "tnkye.e.uusel..cat.lh.aaa.legabnaei.r...kinderou.y.pler.lksleeg.e.eevtteleaeezzaipddpis.nmntfgfo.csp\n",
-      "eietd..mpqankffh.yaie.gnt.....use.gallivants..ic.l.uydpuner.uyttdysinadlcrove....ee.tslu.geuijnrcipt\n",
-      "rbred..peri.usoe.srbayetimikespl.debrutrepnu.n.rkl.mb.npsera.fosm.dimieiscovsrd.vtyr.om...l..fioisiu\n",
-      "nbisl.e.or.a..rs.eoastrireitliugselttit.....g..e.u.pr..iadmsbnemil.gcrt..siepeclrrapteswovasidfvcgro\n",
-      "uupcer.o..y.d.gtstulte.ne...rtsicitnamoraincoatk.bfearedkhayyeutycacyc.hwlgrc.oeematr...vended.ei.i.\n",
-      "trxrm.msinimefe.tani.i.ih..i.....edutingamsnoynac..decay..ceagd.ara.a.celnie.vsndwo...pinup...l.dntd\n",
-      "sgeosdrenblurbscalda.o.nn.n..cimonoxatkinetic..e....narks.k.rl..pl.r.teaihe.eer.pwryly...tubes.e..g.\n",
-      "..saesuohdraug..ie.v.m.gig.ycnangiop.tawdrier..w....scallopedsesiwp.atstcl.ddo.astelfael..bumblers..\n",
-      ".t.krandomises..rr.a..gripestsivitcellocsbawsshapeliest..gnitontoofhylluftsaobwsocilac..located..s..\n"
-     ]
-    }
-   ],
-   "source": [
-    "print(show_grid(g))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 221,
-   "metadata": {},
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "Attempt 249 ; most common is [('scofflaw', 1)]\n"
-     ]
-    },
-    {
-     "data": {
-      "text/plain": [
-       "(True, [('scofflaw', 1)])"
-      ]
-     },
-     "execution_count": 221,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "padded = False\n",
-    "padding_attempts = 0\n",
-    "while not padded and padding_attempts < 10**6:\n",
-    "    clear_output(wait=True)\n",
-    "    padding_attempts += 1\n",
-    "    pg = pad_grid(g)\n",
-    "    pm = present_many(pg, ws)\n",
-    "    print('Attempt', padding_attempts, '; most common is', collections.Counter(p[0] for p in pm).most_common(1))\n",
-    "    if collections.Counter(p[0] for p in pm).most_common(1)[0][1] == 1:\n",
-    "        padded = True\n",
-    "        \n",
-    "padded, collections.Counter(p[0] for p in pm).most_common(1)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 222,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "249"
-      ]
-     },
-     "execution_count": 222,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "padding_attempts"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 230,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "851"
-      ]
-     },
-     "execution_count": 230,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "dws = decoys(pg, ws, ws_words, limit=2000, min_word_len=5)\n",
-    "len(dws)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 231,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "smuiclacphysicsihcnebrevilingdroskcabllupcsowygnitnacsipblustedpesnipilafeldrigclenquireddetnawnufly\n",
-      "eqdbmnutmegsvtzdtelbanimretanmelptseikwagewoodpeckerstirwaszbdrrdypicksnzikylhsiroobsuspectingsexevd\n",
-      "cgnittacdliwffisuoniallivsegasplraftstyevcsgcdemrofsnartrmlaydzescpopxehsfannysdiscriminationdoeypen\n",
-      "nnytimavwharfrepjstswashbucklerswklqimkeosulxnopratpsitaoorsrtrjtthnsmxrelabelesrssstribiscutsddvbrs\n",
-      "eidgkdesivedaiajshegdtgrgniyugyshohaabrmedgpantedsobeysodgmraoozdteosaboundgfjsmbttpygjujedorhdvboeh\n",
-      "tverediwtczdtlwdeiaryehacrierhsrmccosiantnnbestridikysreepegarotedadrpslaropausesubepnrdissoteiailld\n",
-      "narddypasjitligihpesubsrwewfgciuuhfsntizsgingivitislublefotkcuhschrmsensitisedeugnveleygbutsiyjcflud\n",
-      "eernefunuaiindrsilnsethiokutttaeiapgodsteknerdhlngemldlrslhtrhobnobsizsvdlocdtrszbnjnbpieoizwillkarf\n",
-      "shiensetnhaepslnnaietundowigvidtrptsrsayiewreogudoecniebbyofugamwhmtntwsufaulcdsmlptbeondrancoeersak\n",
-      "onhpnnktstsdovgsdicvevqeypblohdoaseomtcdrbaatgnrgdnaiaejspdtscrsoratzdntmrgenqnomiroixqgslltmsbfduee\n",
-      "lasxiiasehcnerdjomoidodedsoayvebrawnufhcrtrtsgiaxgdekmkrtfodkinoirfekkaagvsermuroalabsreraehsuxxnoet\n",
-      "grderahepeeweeusiutdirnohmaccsmardrztienunpdeehbomeyxruyralgeskucnoveltiesseirfdpyebuttocksntqlaodne\n",
-      "nrrsglsmxdupsdwrgoielalgmccuikisexoaaltwfniaidcbtgednzcpoeoatsqoszdgratefullytisportingsweepersaapys\n",
-      "iawlbpsleeyhgorhulnnstulleemntlgtnmttpssostidstienstcbfnnhggcstegsugaringinsighthrsniftersmmfwicdeoi\n",
-      "ntabemghsstenongideckefombnlrarlxynieuplplsznnendirswunfgsiehsuensdelbafetkzinterposexldsurtimreelhu\n",
-      "oegleoaeiusdrixklisecdiaiprovesoatllsdsayebsawrasieeterrlaesihztixsllihygrellapractisedatcneeavgggpr\n",
-      "sdebzczioferrsexdiadatergthrivelpdagearetrfhststsavrbyriymsrecharupocketbooktrotxextuvznwkunlkaqggtb\n",
-      "ayrewatmerseespumonebatlnoisemorhcdrnadaubistpoeehiouxcpogaesnsuuyratchetswishereatjingsepnfepckaose\n",
-      "eosafgcffsrrhsawretpadaspitgewuheaiggiivrllcaamkvgntrodtbsidtutpjnrgretemarapecnarussaugaylcfrpantet\n",
-      "rretarcurneicwgnpellagraupmsixcdswniodknelgnaaetinusmlomsgibehfedtslabprowldenimnushiedrkaqndltillss\n",
-      "ntoimlleatgbtlrcsxsehsesitengamedinkafgnonnxtladtabmvkifuentblwaaroeegniyartropieseitoobsnolemedtpuu\n",
-      "ubqfilentigrigafassevissimagingslgiryuoriitoarnsahaseigodniiyelwblmupwthguorbkobmilkiaxhfeedingspptr\n",
-      "nanyydnerxaewaryrriaemackintoshwftrsbnasnhsukntrksragasketrpcsraarliptereinterpretingieycoudeggiwtnp\n",
-      "msrgnylmnkraslitloeettosplinesobtihfgnlgtktmrxealwassetpiykusurbvgijzeejgpkxclrtssfdnrtonnaccordshoa\n",
-      "aihikersaebkawarrtssraodcrgckrpyekbruesuorhnpennaobwgmoversabidgriwcsketchesuesartetsicgswollefdebcs\n",
-      "zleticilliozaenkfuftsrnvzylogeldilsrrrcrinoautnitrlbroeidribuiwaeireakrstmioieiadxesnnlrolocsidazdms\n",
-      "srsyamajsmedlkssrdloyeagevapwanespcemorhucilkxamhroouevilamsidvarcemgtqggezgfdeaerosyygnideerbnquoit\n",
-      "reprobatesdiyruovasbsidboddubehksoehnssseevklieepuoaetlairetsigamtorocevinneedmspwtnpfincisesuhctulc\n",
-      "smvrnttsdldfysbcontrollablelfsraleaveseuslvpsavsgbtrshalvesylsuougibmaesesimcpgopavhshortensrszzazip\n",
-      "vebaeioliedpmsuesilangisgynainhcazingsyymqoqueryingdoreopenedhsendlessasolbbsqlrlsnikskcubetbrknifed\n",
-      "jiklruonsflefilbsnwodwohsnittupnitfstdretsenohlcrcvsmphngnimirgnidaetsemohgbbaamongstljykwucustomers\n",
-      "doionfghfaalsotejhlrgmewhiieelbbgniretnuasuqsuiouoazeggqrhrisnoituloswselppitueaowymrioutrrbfruitspa\n",
-      "veydjogonywisiutvosplithsejlhpesseieinveighingqymnlerlbukfpineappleeunkagfieensrealiseadelaarjeevell\n",
-      "rkertuiegvgcbodleoievtwhtiiyiomravrsetransducersafelaatemptspbjhkrudenifiudktdscalesfratreaopinionql\n",
-      "tddyoveterinaryoenrnedaebapgowjuiniepsalmistyxadtinnlenvdnakiebrashereatmneirdsnaecomfaeiidedpskfzii\n",
-      "kfpbgdtacoseizlfsrfgimrblebehopnrideraemsnfhropatdcdriuieyjnilvmschkhkweentaoutsmartedwlooaefiekydmb\n",
-      "fewestegwhcpuviacpfrenisreesbtgcktshueckfttuzbemteecaswlpggdaypipmrniakrqeasedoberofmrrqltnhphqdefpn\n",
-      "dyesightingateonspalfngsdqfbxcellistottrnscchhdesshlhefleindegaasmeatewnulcsekytmrgyoaoecoiilanlatao\n",
-      "hddrafobjectkatrsaehgdeertiprrzyalndegmreioascontrritspanloieinwiumlzwaoaiissziicnetuimidictatorialo\n",
-      "renemidmuiretcabgsnwrnhegnoigimletslrywdenreftmdiectrsygdmgrssvsealplyrobcllugxxibegusnmqebycrpsguap\n",
-      "npstekcolsopyhbnsthtschngpsteppeseesoadwcaibraesvsrhiireediprikvrcrlpydniapisenbibanaoicarlyagrflsss\n",
-      "epksewpfsbkymacinimincislpsvsvyifxrpaotoirdfzmtoreoomharntseseltiuazaeeslrxarebiajdahvalaslprnoarbez\n",
-      "soeykbongothistlektasssiidsregsleaiarlreogaiweevilggwznttagrwniaiddroasiioemsoinsaepnnavtrnadidllucs\n",
-      "illoloverwhelmednilnicneegeetcndjasdmduvrchpnnrfzlurdloarnasenilesabemtdtulestkxuiepctesaerrigdekiup\n",
-      "rpriyewmjoqxltmivbalqnrigdnglcniinfdamavaoitsgrskseaeyipikliserpcrtheoryysabushnolreerilpedknniesohw\n",
-      "oproponentsmetliekacotroinaoltrenlinnsidutbgrelrucqpgetgemdklciportosipuaegamitgeplpyautgefegoniarcu\n",
-      "ecaudalyokelrsttynoiifilipiklstsrrtftaenvoyeuristichnludtaqbgsewinngnirabrergentuleaugsnofgdfrgdlibd\n",
-      "hahconfigurationontntzghhtomrbtoteorfsgyguostsefninyoranpsaqtllumsaqodnbecrbdysseoluetatzxpdwhesieee\n",
-      "tpalsygrarcdeobivcsrscinapbtmanirsfmeuliuqnartodayebracpnneowyuaplncaninevnegxeduynrargueuieatllgngp\n",
-      "ixfleshyukesedteemeueruptingtahmlhirugmvrccontrastedhbehugniblpsueiayamsidadinrealahrenyyrrntcwantoy\n",
-      "fefmyoginsnnearnisieripenessjedsmethelnaabsromalgtentrrxnilrkgmjlemigfieryedopiwvttanwiafhnisrsseeth\n",
-      "nonhumanvcknnsnteayuemsncupolargiitapthigreideewosireipieirnooaespoanrcbqygkemwlfieefhdwsppehwmubdkw\n",
-      "bywordswjtosiohmetlestnemegagnedlnstcontyanlaprimessnbmshockerhleydesseheotossealraodauaascpraardpga\n",
-      "outlastedtaocsbbcrxmgjeenilefileeavgotsiulrfordssgtrsettautnessbdebbadieilppfurvpopwylleemnsiuoelksg\n",
-      "ddetsyrtemntalngnpwesuccocddyplqppdeisifmrlpimplyntzecggndsuitcaseskarksnflomdtnekrahecsuetsawfpnpcn\n",
-      "iawaitssbskoedamenelphzijeuhauwpieudrvzvennerraytudtcpasbsencactlocnrcaltifsretaehccsrnempollenagtii\n",
-      "essertsimdaehrsciagdrphststrcocrnvstesidiayejswheosedmerqhhltviuakacooksussocondoretsaocnofktptdnnls\n",
-      "ssrettabiesarptgciideyhitaeidodohbvcynenmsncoesiqyvgvrcuaxauclbcearhgiyhladhniblebiluncraakussenioli\n",
-      "retsimdtluweoolrssfaajxsendnszehoqaxoeesgdtpmoppetsgueeuamoseyumcyganhtlaibeodetoormoisterpejltolial\n",
-      "sbtrsyhbbdtprleinmtddesrtaetjhpilusrlrtdssoqderunettceirlteslhcsneofisxaenssregnifrettubudnodgasbtha\n",
-      "sfeergalebiamfsnouieiobattlaebebeicbdweejrruostolgpozsorslslvleiodefdrietvdniqtadjectivesswdrfgeaapr\n",
-      "widrisitultscrbdccninelelipahgnimeqeisldpjierweqianeubcetoiwsbikcusenerqniiceslaysxrpbmcedunupagnrnt\n",
-      "fcclimocleiasoaegsgignduearteudtutolkjugambolbnsrvyibvoxrerniipmupfdetezmysaatrcmpeatoaarfetmftaeuqn\n",
-      "okideokoslbcewnrxnrsospsnsszreeifelatrinemsnxnaeieeetbcsiurvgiesolqsrtcjyrlinaujstelsneqcpatceeyypte\n",
-      "owdmmeldeargisiraeipeatsenyecsnvfriilatticeworkndlrfesgnihsalpslagfosuunsprlvarnucjotkptardslassgpcc\n",
-      "tryltdndlgeehysamtuhtlcsoitmpscelcascadinghlsiceasiyrseovexeditsnghfshpaslpuadicsoasislliiumtocsguie\n",
-      "wynifnpseydscetdsofacyyiledfiqelihslanifbstslewrevevrycvygetxrhipnestsetoahdstaupsetxneascaearjmisvd\n",
-      "euamraessliuraeicccecnttmstneroynlstodopolansonsadetieeoinoeoeouwiegarrubqyaitovtdeposittdaatnarwael\n",
-      "apmeitrrussrarrazqaaraiosgypgbgagsgieunuteworpwartrnmcbrfdcoddsihrpnbearlusddlltpoesyrrtjsyljalwtghe\n",
-      "rpisasmtoutgidqlsuilctnlgnabiopsyngnbilacwsiibgepeiogstutfnheescseiimptaweiecoaegesdeuyuyfeynominees\n",
-      "aictrsiarorerromgdiipoirfiwgnilratsnibuohortcgnisaefzedrtslrreylcknlooelahckasrvregisdraeslatheriwhr\n",
-      "yekopuspalirtuneenfmresmonbslartueneiloqebeakoihstlhirruqapaptaaonilculirskrsqtnnsntaarttdetcartsbao\n",
-      "bsenobsrclcyamnmeiphrpleenufdeniapeptllnsvkvslkyamymceufsrmawussraneonasdaiutdylsasetmaeacanoesroefm\n",
-      "ruoejoioeatwptmrtkcaarqtgestappinggprodosicahfnmolimiydflecugtudihgvocieiunlerugpshietetniksgipdntmn\n",
-      "flierrooicsrliacagunfirejpwhimsdphaatngrreucasueufnrmnilisihiduinnlibetdnqgerfoceaodidsdewotwokrgals\n",
-      "latconnmtfoessepaimedcsatdeducesddshsvvaunfxnsrnvgszkugiettgdldtgrqnhqykgdnawnekrnilseisnoopingisgil\n",
-      "obmibsssylasirralfpameeviecerggeesemrbegecuebvtstoadspynveaelmhdiresonantgtanaugseitiiruolevtizfreao\n",
-      "uppgdarnsspegnicieersylbatonarpgfhrsodomychaiserelbmuhvgrtnsstseebedliwmoqlarpobncmpryenrapturetertv\n",
-      "tvawrdzsponccwtfsrnclennutrcainoaapnbhodepbfrolicsaktziuogrosseforpqfdbrazzesbolaopaneseifidocselgee\n",
-      "vesjeegvojmooeoeslsthukexwudrarnwanxlkestjacvhscgliatesrohcqsdellennekgiqnslueafsalbtkncttclawsrigrn\n",
-      "ozpbdbycrenekrsindekyasascetredsdodislbrejlrstgocnobscuredhhabsecurerechaliconsfnciacesixcoupledoanl\n",
-      "tlmeicsihqmaximaltedynnwsdstssldoemtiebeedmdnbnngvgnippohcaeetsmespodtfmesosdnesjaloperpetuatingbosi\n",
-      "eegggclassroomssniiralitlpsspsewbidtlelpduyedoicsgumgwfswdnmgfotopaetnrtvlsmovrnsfhfsmpilingcppuiafe\n",
-      "dahhjnprnhwepecnarpeetixyeeredsrtezeredeldmdepkrnmnpqfgsiucsunneaegsueotisaiecreisueyirknittingsbdbr\n",
-      "rtyeenickinglfygenlxrdigwsievneetfcevthaeeolnaceoiwispsenmedeielgrwblmncertrntdxsibdpsaostokenismdad\n",
-      "aeedlafgiuigoarnccgezonchnnlktihttfiasllggalwqitcpcencrpttmteldnnutixisbkiilhgeamyseprzkmrhnmldneild\n",
-      "tvwkibpeatnhwlozifgiigdugtwoafglrtrwizsnwpaiauleaencrorpoaaekiueoissoaihdszanryognhkaaeccceuyegcehad\n",
-      "ifaitnmsephymsvstaxfstrqhlowziiirdendhiornplpesyecbeboigarxcrldhtslpgrnahswasitsraiortdemysvtjaindne\n",
-      "berlyinacaepaeateliyortuetlclofnsirrdrooerleystfdcvlvuytireypiiaidamcyrlessdnoluvyzpcsggsidaimraoect\n",
-      "unloijrerrrcnssacsetuoaaccbpdymciuakfdpreuegatsopasetznlapsnirnmfkzsztynctrgratoeectsoainarepnrmrbet\n",
-      "tgibpsridceottensigittnrntnalaesfsnnseysworddcgtlrdedoygstrlrnggisimxaoinoscvrcharsapcngmesiamnmkkdu\n",
-      "tnkyeuejuuselpscatelhdaaarlegabnaeimriohkinderouaydplerylksleegheueevtteleaeezzaipddpismnmntfgfowcsp\n",
-      "eietdrimpqankffhpyaietgntwtyrbusesgallivantsdyicelxuydpunerjuyttdysinadlcrovejtloeeitsludgeuijnrcipt\n",
-      "rbredgyperimusoejsrbayetimikesplkdebrutrepnumnbrklwmbanpserahfosmtdimieiscovsrdrvtyraomissluafioisiu\n",
-      "nbisluelornaaorsteoastrireitliugselttitndxadgsweiufpreiiadmsbnemilqgcrtrnsiepeclrrapteswovasidfvcgro\n",
-      "uupceraowdyedtgtstulteoneucertsicitnamoraincoatkubfearedkhayyeutycacyclhwlgrcjoeematrvilvendedaeisin\n",
-      "trxrmgmsinimefestaniridihueiokfkdedutingamsnoynacqndecayswceagdoarakagcelniesvsndwomagpinupjyrlfdntd\n",
-      "sgeosdrenblurbscaldahomnnoncncimonoxatkineticrseqorhnarksokurlsqplrreteaiheeeerepwrylykpdtubesuerogi\n",
-      "qmsaesuohdraugzuiecvemsgigtycnangiopatawdrieroawjsonscallopedsesiwpratstclfddoiastelfaelihbumblersru\n",
-      "itekrandomisessvrraayrgripestsivitcellocsbawsshapeliestmjgnitontoofhylluftsaobwsocilacidlocatedlrsee\n"
-     ]
-    }
-   ],
-   "source": [
-    "print(show_grid(pg))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 232,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "2000"
-      ]
-     },
-     "execution_count": 232,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "len(dws) + len(ws)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 233,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": [
-    "with open('huge-wordsearch.txt', 'w') as f:\n",
-    "        f.write('{}x{}\\n'.format(len(pg[0]), len(pg)))\n",
-    "        f.write(show_grid(pg))\n",
-    "        f.write('\\n')\n",
-    "        f.write(lcat(sorted(ws + dws)))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 234,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "(1149, 1149)"
-      ]
-     },
-     "execution_count": 234,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "pm = present_many(g, ws)\n",
-    "pold = [w for w in ws if present(g, w)[0]]\n",
-    "len(pm), len(pold)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 235,
-   "metadata": {},
-   "outputs": [
-    {
-     "data": {
-      "text/plain": [
-       "(1149, 1149)"
-      ]
-     },
-     "execution_count": 235,
-     "metadata": {},
-     "output_type": "execute_result"
-    }
-   ],
-   "source": [
-    "ppm = present_many(pg, ws)\n",
-    "ppold = [w for w in ws if present(pg, w)[0]]\n",
-    "len(ppm), len(ppold)"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": 236,
-   "metadata": {
-    "scrolled": true
-   },
-   "outputs": [
-    {
-     "name": "stdout",
-     "output_type": "stream",
-     "text": [
-      "smuiclacphysics.hcnebrevilingd..skcabllup.s...gnitnacs..blusted.....pilafeldrig..enquireddetnawnu...\n",
-      "e....nutmegs.t..telbanimret...e..tseikwagewoodpeckerstirwas.b.r...picksn...ylhsiroobsuspectingsexevd\n",
-      "cgnittacdliw..isuoniallivsegas.lrafts.y.vcs..demrofsnart.mla...e.c....e..fannysdiscrimination.oe..e.\n",
-      "nnytima.wharfrep.stswashbucklersw....m.eos...noprat....ao.rs....t.h..m.relabele..sss...b.sc.ts..vb.s\n",
-      "eid..desivedaia.shegdtg.gniyugys.o..a.rme.gpantedsobeysodgm.a....t.osabound...s.bttp...uje.orhd.boe.\n",
-      "tverediw...dtlw.eiar.ehacrierhsrmccosiant.nbestridi..sreepegarotedadr.slaropauses..e..rdis.oteia.lld\n",
-      "nardd.p...itli.i.pesu.srwe...ciuuhfsnti.sgingivitislubl.fotkcuhs..rmsensitisedeu...eleygbutsiyjcf.u.\n",
-      "eerne.u..aiin.r.i.nset.ioku..taeia.gods.e.n..dh.n.emld.r.lht.hobnobsi.s..l.c.trs...jnb.ieoizw.llka.f\n",
-      "shiense.nhae.s.n.aietun.owig.idtrp.srsayi.w..ogu.oecnie..yo.u...whmt.t..u.a.lcds...tb.ondran.oeersa.\n",
-      ".nhpnnktsts...g.d.cve.qe.pblohdoaseomtc.r.a.tgnrgdnaiae.spd.sc.sora...nt.r.en.no..ro...g.l..msbfdue.\n",
-      ".asxiiasehcnerdj.moido.edsoayvebr.w.ufh.rtr.sgiaxgdekm.rtfo.k.noir.....ag.se..ur.al..sreraehsu.xnoet\n",
-      "gr.erah.peeweeu.i.tdir..h.acc.mard..tie.u.pdeehbo.eyx.u.ralge.kucnoveltiesseirfdp..buttocksn..laodne\n",
-      "nr.sgls..d..sdwrg.iela...c.uikise.o.altwf.i.idcbtged...poeoatsqo...gratefully..sportingsweepersaa..s\n",
-      "iaw.bp...e.hgor.ulnnstullee.ntl.t.mttps.os..d.tienstc...nhggcst.gsugaringinsight..snifters.....cde.i\n",
-      "nta..m..ssteno..i.eckef..b...ar..y.ieu.lpls.n.endirswu..gsiehs..n.delbaf....interpose..dsurt..r.el.u\n",
-      "oeg..oae.usdr..kl..ecd.aiproveso..llsdsayeb.a.ra.iee.er.l.esih.ti.sllihygrellapractisedatcneea..gg.r\n",
-      "sdeb.cziofe.r.e.d..da..rgthrive.p.agearetr.hs.stsavr..riy.srec.ar.pocketbooktrotxe.....nw.unlk..gg.b\n",
-      "a.re.a.m.rs.espumoneb.t..o.semorhc.rnadau.istp.eehio..cpoga.sn.uuyratchetswisher.....n.se..fepc.aos.\n",
-      "e.saf...fsrrh.a.retpada...t.....e.iggiiv.llcaam.vgnt.o.t.sidtu.pj.r.retemarapecnarussau.a.l.frpante.\n",
-      "rretarcurne.c.g.pellagra...s...d.wni.dk.elgnaae.inusm..msgibehfedtsl..prowldenimn.shiedrka...l.il.ss\n",
-      "n..i..leatgbt.rc..s..sesitengamedinkafgnonn.tladta.m....uentbl.aa.oeegniyartrop.eseitoobsnoleme.tpuu\n",
-      "ub.f.lent.gri.afassevissimagingslgiryuoriit...nsahaseigodniiyelwb..upwthguorb.obmil....hfeedings..tr\n",
-      ".a.yydne..aew.ryrri.emackintoshw.trsbnasnh.u..trksr.gasketrpc.raar..ptereinterpretingie....deggiwtnp\n",
-      ".s..nyl...raslitloeett.splinesobtih.gnlgtkt.r.ealwasset....usu.bvgi..eej......rtss.dnrtonnaccords.oa\n",
-      ".ihikers..bkawa.rtssrao...gc.r.yek..ues..rhn.ennaob.gmovers.bid.riwcsketches.esar.etsi.gswollefdebcs\n",
-      ".leticilli.zaen..uftsrnv..log..dils.rrc..noau.nitrlbr.eidrib.iwa.irea..st...ieiadxe.n.lrolocsid....s\n",
-      "sr...m....edl.s...loyeage.ap...e.pc....h..ilk.am.roouevilamsidv.r.e.gt..ge.gfdeaer.s.ygnideerbnquoit\n",
-      "reprobatesdiyruovasbs.d.oddu..hks..h.s..e..kliee.uoae.lairetsigamt.r..e..nneedmsp.t.p.incisesuhctulc\n",
-      "s.vr.t.sdld..s.controllablel.s.aleavese..l..s..s.btrshalvesylsuougibma.s.sim.pgo.avhshortensr.zzazip\n",
-      ".ebae.oliedpmsuesilangisg..a..hc.zingsyy..oqueryingdoreopened..endless...l.bs.lrlsnikskcub.t..knifed\n",
-      "jiklruons.lefilbsnwodwohsn.ttupnit..tdretsenohl..cvsm...gnimirgnidaetsemoh..baamongst..y.wucustomers\n",
-      "doionfgh.a.lsotej.....e.h.iee...gniretnuas..s..o.oa.e.g.r...snoitulos.selppitue..w...io.trrbfruits..\n",
-      ".eydj.g.n..i.iutvosplithsejlhp.s.eieinveighing..mnl.rlbu..pineapple....a.f.e.nsrealiseadel.ar.eevell\n",
-      "r.ertu.e..gc..dleoi....htiiyi.m.avr..transducers.fe.aatempts.b.....d.n.f.ud.t.scales.r.tr.aopinion.l\n",
-      ".d.yoveterinaryoenrn..a.bapg.wjuin..psalmist.x...innlenvd...iebrashereat.ne...snaeco..aeiide.ps...ii\n",
-      "..pb.dtacosei.l.sr.gim.b.eb.ho.nrideraems....opa.dcdri.ie..n.lv.sc.k.kweent.outsmartedwl.oaef.ek..mb\n",
-      "feweste....p.v.a.p..enisreesbtg..t.h.e.k.tt..bem.eecas.lpggday.ipmrn.akrqeasedoberofmrr.l.nhp..de.pn\n",
-      "dy.sighting...o.spalfngsd..b.cellistott.nscc.hdesshlhe.leinde.aas.ea.ewnulcsekytmrg.oa..co..la...tao\n",
-      ".ddr..object...r.aehg.ee..ipr......degmreioascontrrits.an.oieinw.umlzwaoa.iss..i.netu.midictatorialo\n",
-      ".e.em..muiretcab.sn.rnh.gnoigimletslry.denreftmdie.trsygdm.rssvsealplyrobcll.gx.i.egusnm..b.c.ps..ap\n",
-      ".pstekcolsopyh..s...schngpsteppes.esoadwcaib.aesvsrhiiree.iprikvrc.l.ydniapisenb.banaoicar.yagr...ss\n",
-      "ep.sew......macinimin.islp..s....xrpaotoirdf.mto.eoomharntse.elti.a.a.eslrxarebiajdahvalaslprnoarbez\n",
-      "so.ykbongothistlektass.iidsreg..e.ia.lreogaiweevilgg..n.tagrw.ia.d.r..s.ioemsoinsa.pnnavtr.adidllucs\n",
-      "il.oloverwhelmednilni.neegee.cnd.as.mduvrch.n.r..lurd.oarnasenilesab..t.tul.stkxuie.ctesae.rigd.....\n",
-      "rp..y.......l..ivbal.nrigdn.l.ni.n.damava..t.g...seaeyi.ik..se...rtheoryysab.shnolreeril.edknniesohw\n",
-      "oproponents.etli.kacotr.in.o.t.en.innsidu...relruc.pgetge.d.lciportosi...ega.itgeplpyautge.egon.ar..\n",
-      "ecaudalyokelrst.ynoiif.l.piklstsrrtf.aenvoyeuristichnludta.b.se.i.ngnirabrer.entuleaugsno.gd.rgdlibd\n",
-      "h..configurationontnt.g...omr.toteo.fsg.g..stsefni.yora.psa.t.l.msa.....e.rbd.sseol.e.at.x.dwhesieee\n",
-      "tpalsy.r..c.e..ivcsrscinap.tma.irsfm.uliuqnartoday..racp.neo..u.plncaninev.eg.eduynr.rg.e.ieat.lgngp\n",
-      "..fleshyuk.s.dteeme.eruptingtah.lhir.gm.r.contrastedhbe.ugni..p.uei.yamsidad.nreal..r.ny.rrntc.antoy\n",
-      "....yogins..earnis..ripeness.edsmethe.na.bsromalgte.trr.ni..k.m.lemigfieryed..iwvtta.wia.hnis.ss.eth\n",
-      "nonhuman..knnsnte...e...cupolargiitapt.igreideew.s.re.pie....oaespo.nrcb.y.ke.wlfiee.hdws.p...mu.d..\n",
-      "bywords...osiohme..estnemegagnedlnstcon.ya...primessn.mshockerhleyd..sehe.t.ssealra.daua.s....ar....\n",
-      "outlastedt.ocsb.c.x....enilefileeavgotsi.lrfordssgt..ettautnessbdebbadieil.p.ur.po.w.lle......oe.k.g\n",
-      "ddetsyrte.n..l.gnp.esuccocddypl.ppdeisi..rlpimplyn..ecg..dsuitcases.a.ksnfl.mdtnekrahecs.etsawfpn.cn\n",
-      "iawaitss.s..e.a.e..lp....euhauwpi.udrv.ve..er.a..udt..as.se...ctlocn.c.ltifsretaehcc.rnempollenag.ii\n",
-      "essertsimdaehrsci.gdr...tstrcocrn.stesidi..ejs...o.e..erq..lt.i.akaco.ksussocondoretsaocno....tdnnls\n",
-      "s.rettab.es.rptgc.ide..itaeidodohb.cynen.sn.o....y..vrcua..uclb.earhgiyhla.hn..lebil..c..ak..senioli\n",
-      "retsim.tlu.eoo.rssfaa.xsendns.ehoqa.oeesgdtpmoppets.ueeu.moseyu.cygan.tlaib..detoormoisterpe.l.olial\n",
-      "......hbbdtpr..inmt.desrtaetjhpilu.rlrtdsso.derunettceirltesl.csneofis.aenssregnifrettub...od.asbtha\n",
-      "sfeergalebia.f.noui.iobattlae.ebei.bdwe..r..os...gpoz.orslsl.le.odefdr..tvdn...adjectivess.dr.geaapr\n",
-      "....isitultscrbdccn.n.lelipa.gnime..is.dp....we..ane.b..toi..bikc.sener..ii.eslays.rp..c.du..pagnr.t\n",
-      "f..limocleiasoaegsgignduear..udtut.l...gambol.nsrv.ib.o.re.ni..mupfdete..ysa.t....ea.oa..fetm.taeu.n\n",
-      "o.ideokoslb.ewnr.nrso.psnss.reeifelatrinems....ei..etb.s..rvg...ol..rtc.y.lin.u..t.lsne.cp.tceeyypte\n",
-      "owd.mel.ear.isir.eipeatsenye.snvfr..latticeworkndlrfesgnihsalpslagf.suunsprlv...u..otk.tardslassgpcc\n",
-      "t.yltd.dl.e.hysam.uhtl.so.tm.scelcascadinghl..c.asiyrse.vexed.tsng.fshpaslpua..c.oasislliiumtocsguie\n",
-      "wynifnpseydscetdso.acyyi.e..i.elihslanifbstsle.r.vevrycv.....rhi.ne.tsetoahdstaupset..eascae.rj.isvd\n",
-      "euamrae.sliuraeicccecnttmstner.yn.st....olansonsade.ieeoi...oeo..i.ga.rubqyaito..deposittdaat.a.wael\n",
-      "apmeitr.ussrarra..aaraiosgy...g.g.gie...tewor.wart.n.cbrfd.odds.hrpnb.ar.usddlltpoesyrr.js.l...wt.he\n",
-      "rpisasmtoutgid.l..ilctnl.nabiopsy.gnbi..cwsii.gepei.g..u.fn.ee.cseiimptaweiecoae..s.euyu...ynominees\n",
-      ".ictrsiarorerr..gdiipoi.fiwgnilratsnibu.hortcgn.saef.e.rtslrre.lcknlooelahcka.rvre.isdraeslather...r\n",
-      "yekopuspalirtu.eenf.re.m.nbslartueneiloqebeakoihstlhi.ru...ap.aaonilculirskrs..nnsntaarttdetcartsbao\n",
-      ".s.n.bsrclcyamnmei.h.pl..nu.deniapeptllns.kvslky.mymce.fs.mawussrane.nasdaiut.ylsasetmae.canoes.oe.m\n",
-      "...e.oio.at.ptmrt.c..r...estappinggp.odos.cahfnm..imi.dfl.c.gtudihgv.cieiunlerugpshietetniksgipdnt..\n",
-      "flierroo.cs.liac.gunfire.pwhimsd..aa..grr.ucasue...rmn.lis.hidu.n..i.etdnqgerfoceaodidsdewotwokrgals\n",
-      "latconnm.f.e..epaimedc...deducesddshs..aunfx..rn....kugie.tgdl..g..n..y.g.nawn.krnilse.snoopingisgil\n",
-      "obmibsss..asir..l..a.eeviecerggee.em....ecue..tstoadspynveael....resonantgtan.ugseiti.ruolev...freao\n",
-      "u..gdarnsspegniciee.sylbatonarpgfhrsodomychaiserelbmuh.grtnsstseebedliw.o.la.p..ncmpr.enrapturetertv\n",
-      "t...rd...oncc.t.srnclennut.cainoaap...od..bfrolics.k....o.rosseforp...brazzesb.laopa.eseifidoc.elgee\n",
-      "v...ee..o..ooe.eslsth.ke...drarnwan.l.es..a...sc.liatesrohc.sdellennekgi..s.u.af.albtkn...clawsrigrn\n",
-      "o..bdbyc....krsindekyasa..etredsdodi.l.re.l..tgo.nobscuredhh..securere..al.c.nsfn.iace.i.coupledoanl\n",
-      "t.mei.si..maximaltedynn.sdstss.doem.iebe.dm.n.nng.gnippohca....m....dt..eso.dnes.a.operpetuatingbo.i\n",
-      "eegggclassroomss...ral.t.pssp.ewbidtlelpd.yedoic.g.....s.dnm..otopaetn.t.lsmov..sfh.s.piling....i..e\n",
-      "dahh.n...h..pecnarpeeti.yeeredsrte.ere.e..mdepkrn.np....iucsun..ae...eotisaie..eis.ey.rknittings..br\n",
-      "rt.eenickinglfy...l.rdig..ie.neet.cev.ha.eo.naceo.wispsenme.eie.gr..lmncertrntdxs.bdpsao.tokenismda.\n",
-      "...dla.g..i.oar.cc.e.onchnn.ktihttfi.s.lgg.lwqitcp.en.rpttmt.ldnn.ti.i.bkii.hgeamyseprzk.r..mld.e.l.\n",
-      ".vwkibp.a.n.wlo.ifg..g.ugtw.afglrtr.i..nwpa.auleae.crorpoaaek.ueo.ssoai.ds.a.ryognhkaaec..euye.ce.ad\n",
-      "..ai.nmseph.msvsta..st.qh.ow.iiirden..iornp.pes.ec.eboigarxcrld.tslp.r.ahsw.sitsra.ortde..svt.a.ndne\n",
-      "b.rl.inacae.aeatel.yortuetl.l.fn.irr.rooe..e.s..dcv.vuytireypii.i.a.c.rlessdnoluvy.pcsggsidaim.aoect\n",
-      "u.loi.rerrr.nssacs.tuoaac.bp.y..iuakfdpr..egatsopasetznlapsni.nmf.zs.tynctrgrato..c.so.in.repnr.rbet\n",
-      "tgibps.idceott.nsi.ittnrntnalaesfsnnseysword.c..lrdedoygst.lrnggisi.xaoinoscvrcharsa.cngmesiamn.kkdu\n",
-      "tnkye.e.uusel..cat.lh.aaa.legabnaei.r...kinderou.y.pler.lksleeg.e.eevtteleaeezzaipddpis.nmntfgfo.csp\n",
-      "eietd..mpqankffh.yaie.gnt.....use.gallivants..ic.l.uydpuner.uyttdysinadlcrove....ee.tslu.geuijnrcipt\n",
-      "rbred..peri.usoe.srbayetimikespl.debrutrepnu.n.rkl.mb.npsera.fosm.dimieiscovsrd.vtyr.om...l..fioisiu\n",
-      "nbisl.e.or.a..rs.eoastrireitliugselttit.....g..e.u.pr..iadmsbnemil.gcrt..siepeclrrapteswovasidfvcgro\n",
-      "uupcer.o..y.d.gtstulte.ne...rtsicitnamoraincoatk.bfearedkhayyeutycacyc.hwlgrc.oeematr...vended.ei.i.\n",
-      "trxrm.msinimefe.tani.i.ih..i.....edutingamsnoynac..decay..ceagd.ara.a.celnie.vsndwo...pinup...l.dntd\n",
-      "sgeosdrenblurbscalda.o.nn.n..cimonoxatkinetic..e....narks.k.rl..pl.r.teaihe.eer.pwryly...tubes.e..g.\n",
-      "..saesuohdraug..ie.v.m.gig.ycnangiop.tawdrier..w....scallopedsesiwp.atstcl.ddo.astelfael..bumblers..\n",
-      ".t.krandomises..rr.a..gripestsivitcellocsbawsshapeliest..gnitontoofhylluftsaobwsocilac..located..s..\n"
-     ]
-    }
-   ],
-   "source": [
-    "print(show_grid(g))"
-   ]
-  },
-  {
-   "cell_type": "code",
-   "execution_count": null,
-   "metadata": {
-    "collapsed": true
-   },
-   "outputs": [],
-   "source": []
-  }
- ],
- "metadata": {
-  "kernelspec": {
-   "display_name": "Python 3",
-   "language": "python",
-   "name": "python3"
-  },
-  "language_info": {
-   "codemirror_mode": {
-    "name": "ipython",
-    "version": 3
-   },
-   "file_extension": ".py",
-   "mimetype": "text/x-python",
-   "name": "python",
-   "nbconvert_exporter": "python",
-   "pygments_lexer": "ipython3",
-   "version": "3.5.2+"
-  }
- },
- "nbformat": 4,
- "nbformat_minor": 1
-}