Enigmatic Code

Programming Enigma Puzzles

Enigma 1747: Mind your Ps and Qs

From New Scientist #2915, 4th May 2013 [link]

I applied for a job and had two interviews. The two interviewers had to decide independently whether or not I was suitable. Only after both interviews were the two decisions announced and the approval of both was needed to get the job. Apparently the first interviewer approved one in every P applicants (where P is a whole number) and decided that the rest were unsuitable. Then, for any of the first interviewer’s decisions, there was only a one in Q chance that the second interviewer agreed with the first (where Q is a larger integer). After the second interview, the interviewer told me that he had approved my application. However, he warned me not to get too excited because there was only a one in P+Q chance that I had got the job.

What are the values of P and Q?



One response to “Enigma 1747: Mind your Ps and Qs

  1. Jim Randell 1 May 2013 at 7:20 pm

    I think this is relatively straightforward (although probabilities aren’t my favourite thing). The solution also turned out to be the first pair of numbers I tried as an example to get the idea. Here’s a simple Python program to compute the answer.

    from itertools import count
    from enigma import printf
    def solve():
      for q in count(1):
        for p in range(1, q):
          if p + q == 1 + (p - 1) * (q - 1):
            return (p, q)
    (p, q) = solve()
    printf("p={p} q={q}")

    Solution: P = 3, Q = 4.

Leave a Comment

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: