Better puzzle creation
[ou-summer-of-code-2017.git] / wordsearch / wordsearch-creation.ipynb
index 03c8033c9631404c98bc1e9058c21c87bdcd5a60..c4ca081eb93d2397cdec1ddc2f804ca3a87882fe 100644 (file)
   },
   {
    "cell_type": "code",
-   "execution_count": 43,
+   "execution_count": 51,
    "metadata": {
-    "collapsed": true
+    "collapsed": false
    },
    "outputs": [],
    "source": [
     "def decoys(grid, words, all_words, limit=60):\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 not present(grid, d)[0]:\n",
+    "        if d not in words and len(d) < dlen_limit and not present(grid, d)[0]:\n",
     "            decoy_words += [d]\n",
     "    return decoy_words"
    ]
   },
   {
    "cell_type": "code",
-   "execution_count": 45,
+   "execution_count": 52,
    "metadata": {
     "collapsed": false
    },
     {
      "data": {
       "text/plain": [
-       "['blindfolding',\n",
-       " 'televised',\n",
-       " 'climaxed',\n",
-       " 'autumns',\n",
-       " 'aquaria',\n",
-       " 'bilks',\n",
-       " 'psychologies',\n",
-       " 'sparkled',\n",
-       " 'dorkiest',\n",
-       " 'corollas',\n",
-       " 'polygons',\n",
-       " 'accessioning',\n",
-       " 'bubbled',\n",
-       " 'astringency',\n",
-       " 'debunking',\n",
-       " 'cannery',\n",
-       " 'exhilarates',\n",
-       " 'overzealous',\n",
-       " 'primping',\n",
-       " 'geckos',\n",
-       " 'admiration',\n",
-       " 'misconstructions']"
+       "['ditches',\n",
+       " 'fuzes',\n",
+       " 'antivirals',\n",
+       " 'chronology',\n",
+       " 'yacked',\n",
+       " 'percentages',\n",
+       " 'heftier',\n",
+       " 'inimitably',\n",
+       " 'conveys',\n",
+       " 'remaindered',\n",
+       " 'retaken',\n",
+       " 'reckoned',\n",
+       " 'emery',\n",
+       " 'squats',\n",
+       " 'tenderfoots',\n",
+       " 'sociology',\n",
+       " 'arbutuses',\n",
+       " 'betook',\n",
+       " 'coniferous',\n",
+       " 'gambled',\n",
+       " 'crouching']"
       ]
      },
-     "execution_count": 45,
+     "execution_count": 52,
      "metadata": {},
      "output_type": "execute_result"
     }
   },
   {
    "cell_type": "code",
-   "execution_count": 46,
+   "execution_count": 53,
    "metadata": {
     "collapsed": false,
     "scrolled": true
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "wombs (True, 1, 19, <Direction.downleft: 7>)\n",
-      "persimmons (True, 14, 7, <Direction.upright: 6>)\n",
-      "computerisation (True, 15, 18, <Direction.left: 1>)\n",
-      "ascribes (True, 14, 17, <Direction.left: 1>)\n",
-      "coopering (True, 1, 11, <Direction.down: 4>)\n",
-      "goalies (True, 17, 12, <Direction.left: 1>)\n",
-      "beamed (True, 3, 0, <Direction.down: 4>)\n",
-      "modifying (True, 11, 19, <Direction.down: 4>)\n",
-      "insets (True, 13, 2, <Direction.right: 2>)\n",
-      "cigarets (True, 12, 3, <Direction.up: 3>)\n",
-      "statures (True, 2, 7, <Direction.left: 1>)\n",
-      "libels (True, 6, 7, <Direction.down: 4>)\n",
-      "remarked (True, 3, 19, <Direction.down: 4>)\n",
-      "baggy (True, 13, 11, <Direction.right: 2>)\n",
-      "juxtaposes (True, 19, 17, <Direction.left: 1>)\n",
-      "mesdames (True, 7, 13, <Direction.up: 3>)\n",
-      "grumpiness (True, 4, 17, <Direction.down: 4>)\n",
-      "artefacts (True, 16, 6, <Direction.right: 2>)\n",
-      "skeins (True, 10, 2, <Direction.down: 4>)\n",
-      "assizes (True, 6, 12, <Direction.up: 3>)\n",
-      "inflow (True, 6, 5, <Direction.upright: 6>)\n",
-      "depleting (True, 7, 1, <Direction.down: 4>)\n",
-      "beeped (True, 11, 16, <Direction.left: 1>)\n",
-      "reneges (True, 18, 17, <Direction.left: 1>)\n",
-      "interning (True, 12, 13, <Direction.left: 1>)\n",
-      "yellowish (True, 2, 10, <Direction.down: 4>)\n",
-      "regicides (True, 19, 0, <Direction.right: 2>)\n",
-      "eyelids (True, 18, 5, <Direction.right: 2>)\n",
-      "cools (True, 7, 9, <Direction.upleft: 5>)\n",
-      "orgy (True, 7, 18, <Direction.up: 3>)\n",
-      "nifty (True, 8, 4, <Direction.up: 3>)\n",
-      "knottier (True, 0, 9, <Direction.left: 1>)\n",
-      "destroyers (True, 8, 0, <Direction.down: 4>)\n",
-      "unfurls (True, 14, 18, <Direction.up: 3>)\n",
-      "tinctured (True, 1, 0, <Direction.right: 2>)\n",
-      "bigamy (True, 4, 2, <Direction.down: 4>)\n",
-      "winos (True, 17, 14, <Direction.right: 2>)\n",
-      "essays (True, 11, 9, <Direction.left: 1>)\n",
-      "blindfolding (False, 0, 0, <Direction.left: 1>)\n",
-      "televised (False, 0, 0, <Direction.left: 1>)\n",
-      "climaxed (False, 0, 0, <Direction.left: 1>)\n",
-      "autumns (False, 0, 0, <Direction.left: 1>)\n",
-      "aquaria (False, 0, 0, <Direction.left: 1>)\n",
-      "bilks (False, 0, 0, <Direction.left: 1>)\n",
-      "psychologies (False, 0, 0, <Direction.left: 1>)\n",
-      "sparkled (False, 0, 0, <Direction.left: 1>)\n",
-      "dorkiest (False, 0, 0, <Direction.left: 1>)\n",
-      "corollas (False, 0, 0, <Direction.left: 1>)\n",
-      "polygons (False, 0, 0, <Direction.left: 1>)\n",
-      "accessioning (False, 0, 0, <Direction.left: 1>)\n",
-      "bubbled (False, 0, 0, <Direction.left: 1>)\n",
-      "astringency (False, 0, 0, <Direction.left: 1>)\n",
-      "debunking (False, 0, 0, <Direction.left: 1>)\n",
-      "cannery (False, 0, 0, <Direction.left: 1>)\n",
-      "exhilarates (False, 0, 0, <Direction.left: 1>)\n",
-      "overzealous (False, 0, 0, <Direction.left: 1>)\n",
-      "primping (False, 0, 0, <Direction.left: 1>)\n",
-      "geckos (False, 0, 0, <Direction.left: 1>)\n",
-      "admiration (False, 0, 0, <Direction.left: 1>)\n",
-      "misconstructions (False, 0, 0, <Direction.left: 1>)\n"
+      "freckled (False, 0, 0, <Direction.left: 1>)\n",
+      "transcripts (False, 0, 0, <Direction.left: 1>)\n",
+      "dinnering (False, 0, 0, <Direction.left: 1>)\n",
+      "insulating (False, 0, 0, <Direction.left: 1>)\n",
+      "regurgitates (False, 0, 0, <Direction.left: 1>)\n",
+      "drouthes (False, 0, 0, <Direction.left: 1>)\n",
+      "cocky (False, 0, 0, <Direction.left: 1>)\n",
+      "stodgy (False, 0, 0, <Direction.left: 1>)\n",
+      "bestrides (False, 0, 0, <Direction.left: 1>)\n",
+      "perceives (False, 0, 0, <Direction.left: 1>)\n",
+      "waned (False, 0, 0, <Direction.left: 1>)\n",
+      "pisses (False, 0, 0, <Direction.left: 1>)\n",
+      "alienating (False, 0, 0, <Direction.left: 1>)\n",
+      "hyperbolas (False, 0, 0, <Direction.left: 1>)\n",
+      "yeshivoth (False, 0, 0, <Direction.left: 1>)\n",
+      "allured (False, 0, 0, <Direction.left: 1>)\n",
+      "outstaying (False, 0, 0, <Direction.left: 1>)\n",
+      "bureaus (False, 0, 0, <Direction.left: 1>)\n",
+      "tragedians (False, 0, 0, <Direction.left: 1>)\n",
+      "wooed (False, 0, 0, <Direction.left: 1>)\n",
+      "unwary (False, 0, 0, <Direction.left: 1>)\n",
+      "provoking (False, 0, 0, <Direction.left: 1>)\n",
+      "curies (False, 0, 0, <Direction.left: 1>)\n",
+      "deviltry (False, 0, 0, <Direction.left: 1>)\n",
+      "wooly (False, 0, 0, <Direction.left: 1>)\n",
+      "abysmally (False, 0, 0, <Direction.left: 1>)\n",
+      "ladled (False, 0, 0, <Direction.left: 1>)\n",
+      "tamable (False, 0, 0, <Direction.left: 1>)\n",
+      "minors (False, 0, 0, <Direction.left: 1>)\n",
+      "aortas (False, 0, 0, <Direction.left: 1>)\n",
+      "souses (False, 0, 0, <Direction.left: 1>)\n",
+      "heinously (False, 0, 0, <Direction.left: 1>)\n",
+      "cardiac (False, 0, 0, <Direction.left: 1>)\n",
+      "peons (True, 17, 1, <Direction.right: 2>)\n",
+      "karate (False, 0, 0, <Direction.left: 1>)\n",
+      "tansy (False, 0, 0, <Direction.left: 1>)\n",
+      "unruly (False, 0, 0, <Direction.left: 1>)\n",
+      "absently (False, 0, 0, <Direction.left: 1>)\n",
+      "pads (False, 0, 0, <Direction.left: 1>)\n",
+      "ditches (False, 0, 0, <Direction.left: 1>)\n",
+      "fuzes (False, 0, 0, <Direction.left: 1>)\n",
+      "antivirals (False, 0, 0, <Direction.left: 1>)\n",
+      "chronology (False, 0, 0, <Direction.left: 1>)\n",
+      "yacked (False, 0, 0, <Direction.left: 1>)\n",
+      "percentages (False, 0, 0, <Direction.left: 1>)\n",
+      "heftier (False, 0, 0, <Direction.left: 1>)\n",
+      "inimitably (False, 0, 0, <Direction.left: 1>)\n",
+      "conveys (False, 0, 0, <Direction.left: 1>)\n",
+      "remaindered (False, 0, 0, <Direction.left: 1>)\n",
+      "retaken (False, 0, 0, <Direction.left: 1>)\n",
+      "reckoned (False, 0, 0, <Direction.left: 1>)\n",
+      "emery (False, 0, 0, <Direction.left: 1>)\n",
+      "squats (False, 0, 0, <Direction.left: 1>)\n",
+      "tenderfoots (False, 0, 0, <Direction.left: 1>)\n",
+      "sociology (False, 0, 0, <Direction.left: 1>)\n",
+      "arbutuses (False, 0, 0, <Direction.left: 1>)\n",
+      "betook (False, 0, 0, <Direction.left: 1>)\n",
+      "coniferous (False, 0, 0, <Direction.left: 1>)\n",
+      "gambled (False, 0, 0, <Direction.left: 1>)\n",
+      "crouching (False, 0, 0, <Direction.left: 1>)\n"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 47,
+   "execution_count": 54,
    "metadata": {
     "collapsed": false
    },
      "name": "stdout",
      "output_type": "stream",
      "text": [
-      "tuiababblerssknalbft\n",
-      "gnewerodeswskrowerif\n",
-      "nballooningosfriedum\n",
-      "iuebksidesaddlessldt\n",
-      "mrncdbmnnyllasuaceet\n",
-      "udiesnettirwtsohglli\n",
-      "uepoeyremeenoyreveum\n",
-      "cnuselitnegfatterbdp\n",
-      "asslmulleveiadieneer\n",
-      "visnmewsrelrsbtleddi\n",
-      "crouchinghogetrzooms\n",
-      "dstrihstaewseteaotoo\n",
-      "vkssrdovulatesrldgon\n",
-      "snnvengefullyuiawets\n",
-      "uiofendelleuferrcosi\n",
-      "ahsdenoixelpmocluitt\n",
-      "vcdauthorisesnfsnenp\n",
-      "eyoelmferociouslypng\n",
-      "lngimmpauperisedtnon\n",
-      "ytnthstnemecitnehhpc\n",
-      "38 words added;  7 directions\n",
-      "Present: abrades authorises babblers ballooning blanks causally chinks complexioned crouching deluded emery enticements erodes everyone fatter ferociously fireworks fried gentiles ghostwritten godsons imprisons mews ovulates owlets pauperised refuelled retracing sidesaddles suavely supine sweatshirts unburdens vacuuming vellum vengefully yeti zooms\n",
-      "Decoys: chastened doodling ethnologists executrixes freelancing generously halfheartedness harries kinswoman mangles narrowly optimising oversimplifies polystyrene recounts riffing slicking smackers squashy thirsting tiebreakers unexampled\n"
+      "ihaceglstcongealedim\n",
+      "locnlanmecdwsieyieyp\n",
+      "uslrbacimdmedruyirfo\n",
+      "hyacaascsatireeaiefm\n",
+      "epyatooheutryldpifum\n",
+      "chiuantaedrivgeouihe\n",
+      "diehehdftsionrsdmoil\n",
+      "ylrnpsounaonhspadtrs\n",
+      "linhegiglgirgcidagug\n",
+      "gsaornesallliseilnwo\n",
+      "nlnenigpsnnhllsrlins\n",
+      "ityvuprergselipdohyi\n",
+      "mstismocwduusngeygsw\n",
+      "oextoooincnhksshsuci\n",
+      "cmiiprvfanedcwuctook\n",
+      "ersnptyiaclippingsur\n",
+      "biauindcemostlysietd\n",
+      "rflpebesmsskrepppsil\n",
+      "yssorgnileereouepyna\n",
+      "taeaeweathercockswgs\n",
+      "36 words added;  7 directions\n",
+      "Present: acceding alloys annulled becomingly chorusing chugs clashes clayier clippings congealed dullness espies firmest groovy groupers hogans huffy kiwis matins mostly outmoded perks pommels punitive reeling scouting sixty soppier soughing specifics syphilis taillights tromping unrepeatable weathercocks wispy\n",
+      "Decoys: belittled buzzwords climbs congaed criterions drifters exteriors filial flattery gambolling haversacks insiders interferon leukaemia liabilities mavens mentalities padlocking ptarmigans puking retarded seaming skimpiness wanderers\n"
      ]
     }
    ],
   },
   {
    "cell_type": "code",
-   "execution_count": 49,
+   "execution_count": 55,
    "metadata": {
     "collapsed": false
    },