Showing posts from June, 2018

Cheating at Word Cookies with Python

Ok, so this isn't really a Cheminformatics post, but it's kind of about combinatorial optimization, which is the sort of thing we tend to do a lot of.  Lately, my family has been obsessed with an iOS game called "Word Cookies".  The game is simple (an example is shown below), given a set of 5 letters, you have to construct a set of 3, 4 and 5 letter words.  My wife and daughters are really good at this game, I'm not.  It's funny that the hard part, at least for me, is coming up with the shorter words.   Anyway, being a data geek, I immediately thought about how I could write a Python script to solve this puzzle.  If you think about it, it's pretty easy to just brute force a solution.   Generate all 3, 4 and 5 letter permutations Check each permutation to see if it's a word  Fortunately, there are lots of useful Python libraries and we can do this in just a few lines of code.  Let's take a look.  First off, we want to generate permuta