Enigmatic Code

Programming Enigma Puzzles

Tantalizer 408: Test question

From New Scientist #958, 17th July 1975 [link]

As a tailpiece to his psychology test Professor Plato invited each of the five candidates to compare the likely performance of three of the others. He got these five pairs of answers:

1. Bill will do better than Edward. Charles will do better than Bill.
2. Debbie will do better than Charles. Arthur will do better than Debbie.
3. Edward will do better than Arthur. Charles will do better than Edward.
4. Bill will do better than Edward. Debbie will do better than Bill.
5. Charles will do better than Bill. Arthur will do better than Charles.

Pleasingly, the winner was wholly right, the boy who came bottom wholly wrong and the others each made exactly one correct prediction. (There were no ties).

What is the order of merit on the professor’s test?

[tantalizer408]

2 responses to “Tantalizer 408: Test question

  1. Jim Randell 1 April 2020 at 10:19 am

    Assuming that Debbie is not a boy gives us a unique solution.

    This Python program runs in 94ms.

    Run: [ @repl.it ]

    from enigma import subsets, irange, chunk, map2str, printf
    
    # all statement are of the form: "P < Q, R < S" -> "PQRS"
    statement = { 1: "BECB", 2: "DCAD", 3: "EACE", 4: "BEDB", 5: "CBAC" }
    
    # find possible maps of statements to people: number -> person
    ss = list()
    for s in subsets(statement.keys(), size=len, select="P"):
      d = dict(zip("ABCDE", s))
      if any(k in statement[v] for (k, v) in d.items()): continue
      ss.append(d)
    
    # count number of true statements
    # p = map person -> position
    # s = statements
    count = lambda p, s: sum(p[x] < p[y] for (x, y) in chunk(s, 2))
    
    # choose an ordering: p: person -> position, r: position -> person
    for s in subsets(irange(1, 5), size=len, select="P"):
      p = dict(zip("ABCDE", s))
      r = dict(zip(s, "ABCDE"))
      # person in position 5 is not D
      if r[5] == 'D': continue
    
      # check the possible statements
      for d in ss:
        # check the statements for each position
        if not all(count(p, statement[d[r[k]]]) == v for (k, v) in enumerate([2, 1, 1, 1, 0], start=1)): continue
    
        printf("positions: {r} [statements: {d}]", r=map2str(r, enc=""), d=map2str(d, enc=""))
    

    Solution: 1st: Debbie; 2nd: Arthur; 3rd: Edward; 4th: Charles; 5th: Bill.

    Debbie made prediction 5. (2 correct)
    Arthur made prediction 1. (1 correct)
    Edward made prediction 2. (1 correct)
    Charles made prediction 4. (1 correct)
    Bill made prediction 3. (0 correct)

    There are only 2 ways the predictions can be assigned to the students. And only 2 ways that students can be assigned positions that give the required number of correct predictions. But one of those ways has Debbie placed 5th and we are told that a boy came bottom.

  2. Tessa Fullwood 16 April 2020 at 5:09 pm

    Somewhat eccentric, I know, but here is a set of instructions for an excel spreadsheet.

    First off using some help from stack overflow on the Internet, we populate cells with the permutations of the numbers 12345. There is no function to do this in Excel.

    Open a blank worksheet and paste the following formula into cell A1. (I included line breaks for readability.)
    = IF(ROW()=FACT(ROW($A$2:$A$10)))+0)+1),
    IF(COLUMN()=(SUMPRODUCT(((ROW()-1)>=FACT(ROW($A$2:$A$10)))+0)+2),1,COLUMN()+1))))

    Simply drag this formula over N columns and then down N! rows in order to generate a full permutation table of order N.

    Here N is 5. Next set up a small table of three rows and five columns to encode logical statements, for all the 5 pairs of statements. Place the XOR() in column 1, the AND() in column 2, and the NOT( OR()) in column 3, acting on one of the 120 possible rankings. At the foot of the column, COUNT the number of TRUE statements in the column. In another cell write the IF statement that if the COUNT in column 1 =3, COUNT in column 2 =1, COUNT in column 3 =1: write “solution” in the cell.

    Repeat for all the permutations.

    Finally check that in the solution, the student ranked 5 is a boy.

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 )

Google photo

You are commenting using your Google 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: