In case you’re keeping score, I was NOT selected to play the puzzle on the air for my last
set of correct answers. There were a surprisingly large number of correct answers. I didn’t
know there were so many Python programmers out there puzzling away /s.
This week’s question is:
Approach
I need to do a few things:
Get a list of famous actors
Split the name into first and last name
Generate all permutations of a last name
Check the first name and permutations of the last name against books of the Bible
Generating Permutations of a Name
I know how to generate permutations of words from the last puzzle that I did. Here’s the snippet:
Checking Names Against Books of the Bible
Now, I could be lame and just find a list of books of the Bible online and cut/paste it
into a string in my script.
Problem is, I spent a LOT of time last time reworking the regular expression to parse my
cut/pasted data, so I’m looking for any available data.
I found something: python-scriptures. It’s a library for identifying references to scripture within blocks of text. Looking through the
documentation, I see something useful right away:
So, all I have to do to find books of the Bible is run this regex against my string and see
if there are any matches. Perfect.
And it’s so cool to have a Python library for this.
I installed python-scriptures by downloading the tar file from here.
Then, I installed it like this:
Next, I tested it by adding
into my script and ran it to make sure it didn’t error out. It didn’t, so it’s installed correctly.
Then, I worked up this function:
Pretty complicated huh? I tested it out like this: