How I [arguably] defeated Medium’s #WordSearchWednesday

Drew Cuthbertson
3 min readFeb 12, 2015

Browsing through Medium earlier, I stumbled across this challenge. Naturally, my first thought was, “Oh, I could write a script for that…”

So I did.

And here’s what it took:

  • The word search provided my Medium
  • A simple script in javascript that could traverse the puzzle
  • A dictionary for the script to check words against

If you’re curious to see the code, you can find it on my GitHub page. In either case, here’s the logic behind it:

1. Translate the letters into something the computer can make sense of. I chose to morph the letters into a matrix.2. Traverse the entire matrix
a. Consider each point to be the start of a word
i. From that start, move in each of 8 directions (north, northwest, west, …)
ii. For each direction, add the adjacent letter in that direction… iii. If the current series of letters is three letters or longer, check if it’s actually a word by seeing if it’s in a handy dictionary object [that I just happened to already have that contains all 250,000 words in the English language…]
a. If it is a word, add it to a list of words
b. If it’s not a word, continue as if nothing happened
iv. Either way, take those letters, repeat steps 2.a.ii through 2.a.iv by continuing to move in the direction we already started in— do not change directions! (words found in word searches, unlike boggle, are always in straight lines.) This continues until we hit the edge of the word search matrix./* Yes, it’s important that even if it’s a word we found that we keep looking, because that might only be a smaller word within the larger word, and we don’t know which one we want */ b. Once we’ve recursed through all 8 directions for every letter in the matrix, we’re done!3. Finally, return a list of all the words// Now we have a list of words! Hopefully we have exactly the ones we want, but we’ll probably have a few extra.

Unfortunately, this script was about 10 times too accurate. Instead of finding the 40 words (previously reported to be 55…) Medium was looking for, it found 501. The one optimization I did was sorting the list by word length— that way all the pesky 3 letter words were pushed behind the bigger and [ostensibly] more intentional words. If I were more clever, I would have updated the script to not include words that fit certain criteria, or I would have done something more absurd like using natural language processing to see if the word pertains to writing. (that sounds possible, right?) Rather, I went through the 501 words manually and picked out the 49 that seemed arguably relevant to writing. (To not get in your way, I’ve put those words down below.)

Anyway, that’s all for me! Thanks for playing along and letting me find.. ahem… an alternative solution to your challenge, Medium.

The 49 [arguably] relevant words:

  • anachronism
  • euphemism
  • pun
  • aphorism
  • oxymoron
  • antithesis
  • synopsis
  • monologue
  • alliteration
  • narrative
  • personification
  • simile
  • discourse
  • juxtaposition
  • climax
  • epithet
  • cliche
  • sarcasm
  • innuendo
  • synecdoche
  • edit
  • onomatopoeia
  • ambiguity
  • hypothesis
  • ode
  • cacophony
  • soliloquy
  • catharsis
  • tone
  • anecdote
  • metaphor
  • plot
  • irony
  • allegory
  • connotation
  • motif
  • exposition
  • thesis
  • hook
  • denotation
  • ink
  • assonance
  • meter
  • line
  • context
  • arc
  • line
  • end
  • position
Unlisted

--

--

Drew Cuthbertson

Dancer | Climber | Cyclist | Musician | Traveler | Adventurer