Enigmatic Code

Programming Enigma Puzzles

Tantalizer 310: Miss Prism

From New Scientist #861, 30th August 1973 [link]

Miss Prism, being duly sworn, was asked for her age but remained mulishly silent.

“Come, come, my good woman”, snapped the judge, “you must answer the court’s questions”.

Counsel intervened smoothly. “I understand, M’Lud, that she is certainly over 40 and under 50, if it pleases you, M’Lud”.

“It does not please me, Sir Ambrose; I am thinking of having her committed”.

This threat overcame some of Miss Prisms reticence and she hastily deposed as follows: “When I stop speaking, I shall have made exactly two true statements. My age is divisible by 2. It is a perfect square. It is not 42. It is a prime number. It is divisible by three”. At this point she stopped speaking.

“Perjury, I fancy”, sniffed the judge.

“With respect, M’Lud, I fancy she has answered the question, if Your Lordship will attend carefully to the various possibilities”.

How old is the lady?


2 responses to “Tantalizer 310: Miss Prism

  1. Jim Randell 25 January 2023 at 11:31 am

    Miss Prism makes 6 statements.

    For age 48, three of the last 5 statements are true, so the first statement is false (along with 2 of the others).

    For the other ages, two of the last 5 statements are true (and 3 of them are false), so the value of the first statement is undefined.

    Either way Miss Prism has made several false statements while under oath, so it seems the judge is correct.

    I expect each of the statements is to be assessed as either true or false, and this can only be done for age 48, hence this is the required age.

    This Python program examines the possibilities

    Run: [ @replit ]

    from enigma import (irange, is_square_p, is_prime, printf)
    # consider possible ages A
    for A in irange(41, 49):
      # statements (other than the first)
      ss = [
        # "My age is divisible by 2"
        (A % 2 == 0),
        # "It is a perfect square"
        # "It is not 42"
        (A != 42),
        # "It is a prime number"
        # "It is divisible by 3"
        (A % 3 == 0),
      n = sum(ss)
      # if the first statement is true, then exactly 1 of the others must be
      if n == 1:
        printf("age = {A} {ss}", ss=[True] + ss)
      # if the first statement is false, then exactly 2 of the others cannot be true
      if n != 2:
        printf("age = {A} {ss}", ss=[False] + ss)

    Solution: She is 48.

  2. GeoffR 25 January 2023 at 8:15 pm
    %  Age  Divisible by 2  Square  Not 42  Prime  Divisible by 3  total 'Y's'
    %  41        N            N       Y       Y        N              2
    %  42        Y            N       N       N        Y              2
    %  43        N            N       Y       Y        N              2
    %  44        Y            N       Y       N        N              2
    %  45        N            N       Y       N        Y              2
    %  46        Y            N       Y       N        N              2
    %  47        N            N       Y       Y        N              2
    %  48        Y            N       Y       N        Y              3 <<<
    %  49        N            Y       Y       N        N              2
    %   48 is the only age distinguishable from the other ages. 

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 )

Connecting to %s

This site uses Akismet to reduce spam. Learn how your comment data is processed.

%d bloggers like this: