Updated text about sample problme
authorNeil Smith <neil.git@njae.me.uk>
Mon, 12 Jun 2017 08:35:12 +0000 (09:35 +0100)
committerNeil Smith <neil.git@njae.me.uk>
Mon, 12 Jun 2017 08:35:12 +0000 (09:35 +0100)
04-word-search/wordsearch-solving.ipynb

index 86b1d9c018b43e25eb53d6ac5c75406d9134772c..758380a3f7511bcc39222ba879d1ad3e7136b4f8 100644 (file)
     "\n",
     "Decoys: adapting bombing boor brick cackles carnal casino chaplets chump coaster coccyxes coddle collies creels crumbled cunt curds curled curlier deepen demeanor dicier dowses ensuing faddish fest fickler foaming gambol garoting gliding gristle grunts guts ibex impugns instants kielbasy lanyard loamier lugs market meanly minuend misprint mitts molested moonshot mucking oaks olives orgasmic pastrami perfect proceed puckered quashed refined regards retraces revel ridges ringlet scoff shinier siren solaria sprain sunder sunup tamped tapes thirds throw tiller times trains tranquil transfix typesets uric wariness welts whimsy winced winced\n",
     "\n",
+    "Decoys: fickler, adapting, chump, foaming, molested, carnal, crumbled, guts, minuend, bombing, winced, coccyxes, solaria, shinier, cackles\n",
+    "\n",
+    "All words: adapting, apace, bombing, cackles, carnal, chump, coccyxes, cowhides, crazies, crumbled, dock, fickler, foaming, guts, knows, lived, minuend, molested, mown, pears, probed, rhubarb, rioted, shinier, solaria, staple, tops, wide, winced\n",
+    "\n",
     "Directions:  [('probed', '`(True, 3, 0, <Direction.down: 4>)`'), ('staple', '`(True, 9, 1, <Direction.right: 2>)`'), ('rioted', '`(True, 6, 7, <Direction.upleft: 5>)`'), ('cowhides', '`(True, 8, 3, <Direction.up: 3>)`'), ('tops', '`(True, 7, 4, <Direction.right: 2>)`'), ('knows', '`(True, 8, 2, <Direction.up: 3>)`'), ('lived', '`(True, 2, 4, <Direction.downright: 8>)`'), ('rhubarb', '`(True, 2, 9, <Direction.down: 4>)`'), ('crazies', '`(True, 7, 1, <Direction.up: 3>)`'), ('dock', '`(True, 8, 5, <Direction.up: 3>)`'), ('apace', '`(True, 5, 8, <Direction.up: 3>)`'), ('mown', '`(True, 0, 5, <Direction.right: 2>)`'), ('pears', '`(True, 0, 3, <Direction.downright: 8>)`'), ('wide', '`(True, 4, 4, <Direction.upright: 6>)`')]"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 6,
-   "metadata": {},
+   "execution_count": 4,
+   "metadata": {
+    "collapsed": true
+   },
    "outputs": [],
    "source": [
     "import string\n",
@@ -86,7 +92,7 @@
   },
   {
    "cell_type": "code",
-   "execution_count": 7,
+   "execution_count": 5,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 8,
+   "execution_count": 6,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 9,
+   "execution_count": 7,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 10,
+   "execution_count": 8,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 11,
+   "execution_count": 9,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 12,
+   "execution_count": 10,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 13,
-   "metadata": {},
+   "execution_count": 11,
+   "metadata": {
+    "collapsed": true
+   },
    "outputs": [],
    "source": [
     "def read_wordsearch(fn):\n",
   },
   {
    "cell_type": "code",
-   "execution_count": 14,
+   "execution_count": 12,
    "metadata": {
     "scrolled": true
    },
        "  'zings'])"
       ]
      },
-     "execution_count": 14,
+     "execution_count": 12,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 15,
+   "execution_count": 13,
    "metadata": {
     "scrolled": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 16,
+   "execution_count": 14,
    "metadata": {
     "scrolled": true
    },
        " 'zings']"
       ]
      },
-     "execution_count": 16,
+     "execution_count": 14,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 17,
+   "execution_count": 15,
    "metadata": {},
    "outputs": [
     {
        "'fortification'"
       ]
      },
-     "execution_count": 17,
+     "execution_count": 15,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 18,
+   "execution_count": 16,
    "metadata": {},
    "outputs": [
     {
        "'justification'"
       ]
      },
-     "execution_count": 18,
+     "execution_count": 16,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 19,
+   "execution_count": 17,
    "metadata": {},
    "outputs": [
     {
        "57"
       ]
      },
-     "execution_count": 19,
+     "execution_count": 17,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 20,
+   "execution_count": 18,
    "metadata": {
     "scrolled": true
    },
        "         'z': 1})"
       ]
      },
-     "execution_count": 20,
+     "execution_count": 18,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 21,
+   "execution_count": 19,
    "metadata": {
     "scrolled": true
    },
        " 'wardrobes']"
       ]
      },
-     "execution_count": 21,
+     "execution_count": 19,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 22,
+   "execution_count": 20,
    "metadata": {
     "scrolled": true
    },
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "ancestor Counter({'c': 1, 'a': 1, 't': 1, 's': 1, 'r': 1, 'n': 1, 'e': 1, 'o': 1})\n",
-      "baritone Counter({'a': 1, 'r': 1, 'i': 1, 'b': 1, 't': 1, 'e': 1, 'o': 1, 'n': 1})\n",
-      "bemusing Counter({'g': 1, 'i': 1, 's': 1, 'u': 1, 'b': 1, 'm': 1, 'n': 1, 'e': 1})\n",
-      "blonds Counter({'d': 1, 's': 1, 'b': 1, 'n': 1, 'l': 1, 'o': 1})\n",
-      "conciseness Counter({'s': 3, 'c': 2, 'n': 2, 'e': 2, 'i': 1, 'o': 1})\n",
-      "consequent Counter({'n': 2, 'e': 2, 'c': 1, 't': 1, 's': 1, 'u': 1, 'q': 1, 'o': 1})\n",
-      "cuddle Counter({'d': 2, 'c': 1, 'e': 1, 'l': 1, 'u': 1})\n",
-      "dashboards Counter({'a': 2, 's': 2, 'd': 2, 'r': 1, 'h': 1, 'b': 1, 'o': 1})\n",
-      "*despairing Counter({'i': 2, 'g': 1, 'a': 1, 'r': 1, 's': 1, 'p': 1, 'd': 1, 'e': 1, 'n': 1})\n",
-      "dint Counter({'d': 1, 'i': 1, 't': 1, 'n': 1})\n",
-      "employer Counter({'e': 2, 'r': 1, 'm': 1, 'p': 1, 'l': 1, 'y': 1, 'o': 1})\n",
-      "freakish Counter({'s': 1, 'a': 1, 'i': 1, 'r': 1, 'k': 1, 'h': 1, 'f': 1, 'e': 1})\n",
+      "ancestor Counter({'e': 1, 'a': 1, 's': 1, 'c': 1, 'n': 1, 'o': 1, 'r': 1, 't': 1})\n",
+      "baritone Counter({'i': 1, 'e': 1, 'a': 1, 'n': 1, 't': 1, 'o': 1, 'r': 1, 'b': 1})\n",
+      "bemusing Counter({'i': 1, 'e': 1, 's': 1, 'g': 1, 'n': 1, 'b': 1, 'u': 1, 'm': 1})\n",
+      "blonds Counter({'n': 1, 'l': 1, 's': 1, 'd': 1, 'o': 1, 'b': 1})\n",
+      "conciseness Counter({'s': 3, 'e': 2, 'n': 2, 'c': 2, 'i': 1, 'o': 1})\n",
+      "consequent Counter({'e': 2, 'n': 2, 'c': 1, 's': 1, 'q': 1, 'o': 1, 'u': 1, 't': 1})\n",
+      "cuddle Counter({'d': 2, 'l': 1, 'e': 1, 'u': 1, 'c': 1})\n",
+      "dashboards Counter({'a': 2, 's': 2, 'd': 2, 'o': 1, 'h': 1, 'r': 1, 'b': 1})\n",
+      "*despairing Counter({'i': 2, 'n': 1, 'e': 1, 'a': 1, 'p': 1, 'g': 1, 's': 1, 'd': 1, 'r': 1})\n",
+      "dint Counter({'i': 1, 'd': 1, 'n': 1, 't': 1})\n",
+      "employer Counter({'e': 2, 'p': 1, 'l': 1, 'y': 1, 'o': 1, 'm': 1, 'r': 1})\n",
+      "freakish Counter({'f': 1, 'i': 1, 'e': 1, 'a': 1, 's': 1, 'k': 1, 'h': 1, 'r': 1})\n",
       "*gall Counter({'l': 2, 'g': 1, 'a': 1})\n",
-      "hopelessness Counter({'s': 4, 'e': 3, 'h': 1, 'p': 1, 'n': 1, 'l': 1, 'o': 1})\n",
-      "*impales Counter({'s': 1, 'a': 1, 'm': 1, 'p': 1, 'i': 1, 'l': 1, 'e': 1})\n",
-      "infix Counter({'i': 2, 'f': 1, 'n': 1, 'x': 1})\n",
-      "inflow Counter({'i': 1, 'w': 1, 'l': 1, 'n': 1, 'f': 1, 'o': 1})\n",
-      "innumerable Counter({'n': 2, 'e': 2, 'a': 1, 'l': 1, 'r': 1, 'm': 1, 'u': 1, 'b': 1, 'i': 1})\n",
-      "intentional Counter({'n': 3, 't': 2, 'i': 2, 'a': 1, 'l': 1, 'e': 1, 'o': 1})\n",
-      "*jerkin Counter({'r': 1, 'i': 1, 'j': 1, 'n': 1, 'e': 1, 'k': 1})\n",
-      "justification Counter({'i': 3, 't': 2, 'c': 1, 'a': 1, 'j': 1, 's': 1, 'u': 1, 'f': 1, 'o': 1, 'n': 1})\n",
-      "leaving Counter({'g': 1, 'a': 1, 'v': 1, 'i': 1, 'l': 1, 'n': 1, 'e': 1})\n",
-      "locoweeds Counter({'e': 2, 'o': 2, 'c': 1, 's': 1, 'w': 1, 'l': 1, 'd': 1})\n",
-      "monickers Counter({'c': 1, 'r': 1, 'i': 1, 's': 1, 'm': 1, 'n': 1, 'e': 1, 'o': 1, 'k': 1})\n",
-      "originality Counter({'i': 3, 'g': 1, 'a': 1, 'r': 1, 't': 1, 'n': 1, 'l': 1, 'y': 1, 'o': 1})\n",
-      "outings Counter({'g': 1, 'n': 1, 'i': 1, 'u': 1, 's': 1, 't': 1, 'o': 1})\n",
-      "pendulous Counter({'u': 2, 'd': 1, 's': 1, 'p': 1, 'l': 1, 'n': 1, 'e': 1, 'o': 1})\n",
-      "pithier Counter({'i': 2, 'r': 1, 'h': 1, 'p': 1, 't': 1, 'e': 1})\n",
-      "randomness Counter({'s': 2, 'n': 2, 'a': 1, 'r': 1, 'm': 1, 'd': 1, 'e': 1, 'o': 1})\n",
-      "rectors Counter({'r': 2, 'c': 1, 's': 1, 't': 1, 'e': 1, 'o': 1})\n",
-      "redrew Counter({'r': 2, 'e': 2, 'd': 1, 'w': 1})\n",
-      "reformulated Counter({'r': 2, 'e': 2, 'a': 1, 'l': 1, 'm': 1, 'u': 1, 't': 1, 'f': 1, 'd': 1, 'o': 1})\n",
-      "remoteness Counter({'e': 3, 's': 2, 'r': 1, 'm': 1, 't': 1, 'o': 1, 'n': 1})\n",
-      "rethink Counter({'r': 1, 'i': 1, 'h': 1, 'k': 1, 't': 1, 'e': 1, 'n': 1})\n",
-      "scowls Counter({'s': 2, 'c': 1, 'l': 1, 'o': 1, 'w': 1})\n",
-      "sequencers Counter({'e': 3, 's': 2, 'c': 1, 'r': 1, 'u': 1, 'q': 1, 'n': 1})\n",
-      "serf Counter({'e': 1, 'f': 1, 'r': 1, 's': 1})\n",
-      "shook Counter({'o': 2, 'k': 1, 's': 1, 'h': 1})\n",
-      "spottiest Counter({'t': 3, 's': 2, 'i': 1, 'p': 1, 'e': 1, 'o': 1})\n",
+      "hopelessness Counter({'s': 4, 'e': 3, 'n': 1, 'p': 1, 'l': 1, 'h': 1, 'o': 1})\n",
+      "*impales Counter({'i': 1, 'e': 1, 'a': 1, 'p': 1, 'l': 1, 's': 1, 'm': 1})\n",
+      "infix Counter({'i': 2, 'f': 1, 'x': 1, 'n': 1})\n",
+      "inflow Counter({'f': 1, 'i': 1, 'n': 1, 'l': 1, 'w': 1, 'o': 1})\n",
+      "innumerable Counter({'e': 2, 'n': 2, 'i': 1, 'a': 1, 'l': 1, 'r': 1, 'b': 1, 'u': 1, 'm': 1})\n",
+      "intentional Counter({'n': 3, 'i': 2, 't': 2, 'e': 1, 'a': 1, 'l': 1, 'o': 1})\n",
+      "*jerkin Counter({'i': 1, 'e': 1, 'n': 1, 'k': 1, 'j': 1, 'r': 1})\n",
+      "justification Counter({'i': 3, 't': 2, 'f': 1, 'a': 1, 's': 1, 'c': 1, 'j': 1, 'o': 1, 'u': 1, 'n': 1})\n",
+      "leaving Counter({'g': 1, 'i': 1, 'e': 1, 'a': 1, 'n': 1, 'l': 1, 'v': 1})\n",
+      "locoweeds Counter({'e': 2, 'o': 2, 'w': 1, 'l': 1, 'c': 1, 's': 1, 'd': 1})\n",
+      "monickers Counter({'i': 1, 'e': 1, 'n': 1, 'c': 1, 's': 1, 'k': 1, 'o': 1, 'm': 1, 'r': 1})\n",
+      "originality Counter({'i': 3, 'a': 1, 'n': 1, 'l': 1, 'y': 1, 'g': 1, 't': 1, 'o': 1, 'r': 1})\n",
+      "outings Counter({'i': 1, 'n': 1, 's': 1, 'g': 1, 't': 1, 'o': 1, 'u': 1})\n",
+      "pendulous Counter({'u': 2, 'e': 1, 'n': 1, 'l': 1, 's': 1, 'p': 1, 'd': 1, 'o': 1})\n",
+      "pithier Counter({'i': 2, 'e': 1, 'p': 1, 't': 1, 'h': 1, 'r': 1})\n",
+      "randomness Counter({'n': 2, 's': 2, 'e': 1, 'a': 1, 'd': 1, 'o': 1, 'r': 1, 'm': 1})\n",
+      "rectors Counter({'r': 2, 'e': 1, 's': 1, 'c': 1, 't': 1, 'o': 1})\n",
+      "redrew Counter({'e': 2, 'r': 2, 'w': 1, 'd': 1})\n",
+      "reformulated Counter({'e': 2, 'r': 2, 'f': 1, 'a': 1, 'l': 1, 'u': 1, 't': 1, 'd': 1, 'o': 1, 'm': 1})\n",
+      "remoteness Counter({'e': 3, 's': 2, 'n': 1, 't': 1, 'o': 1, 'r': 1, 'm': 1})\n",
+      "rethink Counter({'i': 1, 'e': 1, 'n': 1, 'k': 1, 't': 1, 'h': 1, 'r': 1})\n",
+      "scowls Counter({'s': 2, 'o': 1, 'l': 1, 'w': 1, 'c': 1})\n",
+      "sequencers Counter({'e': 3, 's': 2, 'n': 1, 'q': 1, 'c': 1, 'u': 1, 'r': 1})\n",
+      "serf Counter({'f': 1, 'e': 1, 's': 1, 'r': 1})\n",
+      "shook Counter({'o': 2, 'h': 1, 's': 1, 'k': 1})\n",
+      "spottiest Counter({'t': 3, 's': 2, 'i': 1, 'e': 1, 'p': 1, 'o': 1})\n",
       "stood Counter({'o': 2, 't': 1, 's': 1, 'd': 1})\n",
-      "surtaxing Counter({'g': 1, 'a': 1, 'i': 1, 'r': 1, 's': 1, 'u': 1, 'x': 1, 't': 1, 'n': 1})\n",
-      "wardrobes Counter({'r': 2, 'a': 1, 'b': 1, 's': 1, 'w': 1, 'd': 1, 'e': 1, 'o': 1})\n"
+      "surtaxing Counter({'x': 1, 'i': 1, 'a': 1, 's': 1, 'g': 1, 't': 1, 'n': 1, 'u': 1, 'r': 1})\n",
+      "wardrobes Counter({'r': 2, 'e': 1, 'a': 1, 'w': 1, 's': 1, 'd': 1, 'o': 1, 'b': 1})\n"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 23,
+   "execution_count": 21,
    "metadata": {},
    "outputs": [
     {
        "10"
       ]
      },
-     "execution_count": 23,
+     "execution_count": 21,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 24,
+   "execution_count": 22,
    "metadata": {},
    "outputs": [
     {
        "'despairing'"
       ]
      },
-     "execution_count": 24,
+     "execution_count": 22,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 25,
-   "metadata": {},
+   "execution_count": 23,
+   "metadata": {
+    "collapsed": true
+   },
    "outputs": [],
    "source": [
     "def do_wordsearch_tasks(fn, show_anyway=False):\n",
   },
   {
    "cell_type": "code",
-   "execution_count": 26,
+   "execution_count": 24,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 27,
+   "execution_count": 25,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 28,
+   "execution_count": 26,
    "metadata": {
     "scrolled": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 29,
+   "execution_count": 27,
    "metadata": {
     "scrolled": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 59,
+   "execution_count": 28,
    "metadata": {
     "collapsed": true
    },
   },
   {
    "cell_type": "code",
-   "execution_count": 41,
+   "execution_count": 29,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'fickler, adapting, chump, foaming, molested, carnal, crumbled, guts, minuend, bombing, winced, coccyxes, solaria, shinier, cackles'"
+      ]
+     },
+     "execution_count": 29,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "', '.join(decoy_words)"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 30,
+   "metadata": {},
+   "outputs": [
+    {
+     "data": {
+      "text/plain": [
+       "'adapting, apace, bombing, cackles, carnal, chump, coccyxes, cowhides, crazies, crumbled, dock, fickler, foaming, guts, knows, lived, minuend, molested, mown, pears, probed, rhubarb, rioted, shinier, solaria, staple, tops, wide, winced'"
+      ]
+     },
+     "execution_count": 30,
+     "metadata": {},
+     "output_type": "execute_result"
+    }
+   ],
+   "source": [
+    "', '.join(sorted(present_words + decoy_words))"
+   ]
+  },
+  {
+   "cell_type": "code",
+   "execution_count": 31,
    "metadata": {},
    "outputs": [
     {
        "[(7, 5), (2, 3), (3, 5)]"
       ]
      },
-     "execution_count": 41,
+     "execution_count": 31,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 42,
+   "execution_count": 32,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 45,
+   "execution_count": 33,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 63,
+   "execution_count": 34,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 54,
+   "execution_count": 35,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 64,
+   "execution_count": 36,
    "metadata": {},
    "outputs": [
     {
   },
   {
    "cell_type": "code",
-   "execution_count": 65,
+   "execution_count": 42,
    "metadata": {},
    "outputs": [
     {
       ".i..h.npn.\n",
       "b......okr\n"
      ]
+    },
+    {
+     "data": {
+      "text/plain": [
+       "'aaabeffhhhiiijknnoppqqrsuvw'"
+      ]
+     },
+     "execution_count": 42,
+     "metadata": {},
+     "output_type": "execute_result"
     }
    ],
    "source": [
     "for w in present_words:\n",
     "    _, r, c, d = present(grid, w)\n",
     "    set_grid(unused_grid, r, c, d, '.' * len(w))\n",
-    "print(show_grid(unused_grid))"
+    "print(show_grid(unused_grid))\n",
+    "cat(sorted(c for l in unused_grid for c in l if c in string.ascii_letters))"
    ]
   },
   {