# Enigmatic Code

Programming Enigma Puzzles

From New Scientist #995, 8th April 1976 [link]

At the AGM of the Mutual Admiration Society the six officers go in for a fair bit of self-congratulation. They also pat each other on the back. This is only prudent, since compliments are on a strictly reciprocal basis.

The President had kept above the recent scandal and was loud in his praise of all the others. The Vice-President too had been scarcely involved and felt free to congratulate all but one of his colleagues. The Treasurer, having pocketed so much else, managed to pocket his pride and speak well of four of the others. But the Secretary, the Press Officer and the Master of Ceremonies each omitted two of his comrades for his public list of adulatory mentions.

The Secretary was positively fulsome about the Press Officer. Whom did the Master of Ceremonies fail to praise?

[tantalizer444]

### One response to “Tantalizer 444: Mutual admiration”

1. Jim Randell 3 October 2018 at 7:47 am

A bit of analysis:

There are 6 jobs, so there are T(6 – 1) = 15 different pairs that can mutually praise each other. So potentially there are 2^15 = 32768 possible praise relations, but we can reduce this search space.

For a start we know the pairs (Pr+VP, Pr+Tr, Pr+Se, Pr+PO, Pr+MC, Se+PO) must be in the praise relation, and the total number of praises (in both directions) is 22, so there are only 11 pairs in the praise relationship. As we already have 6, we can just choose 5 from the remaining possible pairs. C(9, 5) = 126 so there aren’t that many possibilities to consider.

This Python program runs in 76ms.

Run: [ @repl.it ]

```from itertools import combinations
from enigma import irange, icount, partition, diff, join, printf

# the 6 jobs (as bit masks)
jobs = (Pr, VP, Tr, Se, PO, MC) = tuple((1 << i) for i in irange(0, 5))

# 6 pairs are already decided
d_pairs = (Pr+VP, Pr+Tr, Pr+Se, Pr+PO, Pr+MC, Se+PO)

# 9 pairs are undecided (and we need 5 of them)
u_pairs = (VP+Tr, VP+Se, VP+PO, VP+MC, Tr+Se, Tr+PO, Tr+MC, Se+MC, PO+MC)

# remaining number of recipients of praise for each job
praise = { VP: 3, Tr: 3, Se: 1, PO: 1, MC: 2 }

# choose remaining pairs to make the "praise" relation
for u in combinations(u_pairs, 5):
# check the praise counts match
if not all(icount(u, (lambda x: k & x)) == v for (k, v) in praise.items()): continue

# output solution
s = u + d_pairs
label = { Pr: "Pr", VP: "VP", Tr: "Tr", Se: "Se", PO: "PO", MC: "MC" }
fmt = lambda js: join((label[j] for j in js), sep=" ")
for i in jobs:
# jobs praised/not-praised by job i
(ps, ns) = partition((lambda j: i + j in s), diff(jobs, [i]))
printf("{i}: praised=({ps}), ignored=({ns})", i=fmt([i]), ps=fmt(ps), ns=fmt(ns))
printf()
```

Solution: The Master of Ceremonies did not praise the Secretary or the Press Officer.

There are two scenarios of mutual praising:

President: Vice-President, Treasurer, Secretary, Press Officer, Master of Ceremonies (5)
Vice-President: President, Treasurer, Secretary, Master of Ceremonies (4 – not Press Officer)
Treasurer: President, Vice-President, Press Officer, Master of Ceremonies (4 – not Secretary)
Secretary: President, Vice-President, Press Officer (3 – not Treasurer, Master of Ceremonies)
Press Officer: President, Treasurer, Secretary (3 – not Vice-President, Master of Ceremonies)
Master of Ceremonies: President, Vice-President, Treasurer (3 – not Secretary, Press Officer)

President: Vice-President, Treasurer, Secretary, Press Officer, Master of Ceremonies (5)
Vice-President: President, Treasurer, Press Officer, Master of Ceremonies (4 – not Secretary)
Treasurer: President, Vice-President, Secretary, Master of Ceremonies (4 – not Press Officer)
Secretary: President, Treasurer, Press Officer (3 – not Vice-President, Master of Ceremonies)
Press Officer: President, Vice-President, Secretary (3 – not Treasurer, Master of Ceremonies)
Master of Ceremonies: President, Vice-President, Treasurer (3 – not Secretary, Press Officer)

But in both cases the Master of Ceremonies interactions are the same.

The explanation with the published solution says: “If you treat them as a map of six stations connected by lines, you will find that the V-P praised all but the Treasurer”, but that’s not the case in either of the scenarios.

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