checkmypythons
"What is the 50th letter in macbeth?" could easily be interpreted as "How would you go about finding the 50th letter in macbeth?" which is plenty relevant to basic scripting.
"Do I have a source I can pull macbeth from?", "How does that source work?", "Can I query it for individual characters/words/chapters/etc.?"
I think a fundamental problem a lot of people in the comments section are missing is that these interviews are designed to examine the approach to solving problems, not the actual answer to the problem. Sure, if you get a question about traversing a tree, they probably just want you to repeat some basic knowledge.
Maybe something that will illustrate my point: If you happened to know the 50th letter of macbeth off the top of your head, it would defeat the purpose of the question. The point is to examine your problem solving process. If you were to just answer "r", then the interview would quickly pivot to: "Ok, what is the 307th?" or "Ok, what is the 50th letter of Othello?" The point is not to answer the question, so much as to establish the person's ability to answer questions. Any answer that was a straight up answer isn't useful in any way.
There are all sorts of ways your example could be expanded into a useful examination of someone's programming abilities. If prompted, the interviewer might provide: "Let's say we have an api for querying the text of a given shakespeare work" "Could we expand that to other historical plays?" "What if we wanted a service to provide an arbitrary letter from an arbitrary play?" "What if we wanted to allow the user to specify between several options for the api we might use?" "How could we handle differing responses from different apis?" "Should we be counting punctuation or whitespace?"
It isn't so much that a certain subject (historical plays) might be relevant to the job requirements, it's that these questions are more about examining problem solving approaches.
The interviewer sounds probably bad. After the person made it clear they didn't know about number theory, they should have moved to a different topic. But still, answering "Optimus prime" just suggests immaturity or even combativeness in the face of a difficult situation, which isn't someone you want to hire. There are a thousand better answers. Even snarky answers are fine as long as the person is meaningfully engaging.
"I don't know. Probably a lot"
"Maybe infinite. I'm not sure."
"It's an interesting question. Am I allowed to look it up?"
(As someone else said) "Definitely more than 10. Outside of that I'm not sure."
"I don't know. But here is how I would write a script to figure it out"
It comes back to the "move mt. fuji" style questions mentioned in the article. The point of an interview is not to determine whether you would be able to move mt. fuji anymore than whether you are able to answer the number of primes. It's about how you communicate and approach a problem. "Optimus prime" is such a non-starter that it doesn't even allow for a discussion.
I'm speaking as someone who passed a google interview and worked there for several years, so there may be some reason to believe my feelings around interview approaches are based in fact.