# Enigmatic Code

Programming Enigma Puzzles

## Enigma 300: Changes, etc

From New Scientist #1448, 21st March 1985 [link]

The five officers of the Enigma Thinkers Club (ETC) are, in decreasing order of rank, President, Vice-president, Treasurer, Secretary and Entertainments Officer. The five previous holders of these offices recently all changed roles, each taking over one of the five positions which he had not previously held.

The Vice-president’s predecessor and the person who formerly held the Vice-president’s predecessor’s new job both agree that the new Entertainments Officer suffered the worst drop in rank.

The man who filled the post vacated by the person who took over the new President’s old job says that he is now senior to someone to whom he was previously junior.

The Secretary says that in neither administration has he been junior to the former Secretary.

The reshuffle has rewarded the honest: all those who were promoted aways tell the truth, and all those who were demoted always lie.

What, in order, were the previous positions held by the current President, Vice-president, Treasurer, Secretary and Entertainments Officer?

[enigma300]

### 2 responses to “Enigma 300: Changes, etc”

1. Jim Randell 5 August 2015 at 10:01 am

The main difficulty here is in not getting lost when decoding the conditions in the puzzle.

This Python program runs in 30ms.

```from itertools import permutations
from enigma import irange, printf

# label people by their current position
# President, Vice President, Treasurer, Secretary, Entertainments Officer
positions = (P, V, T, S, E) = irange(0, 4)

# consider previous positions
for p in permutations(positions):

# comparative positions
c = tuple(x - i for (i, x) in enumerate(p))

# no-one keeps their position
if 0 in c: continue

# trustworthiness
t = tuple(c[x] > 0 for x in positions)

# statement 1: "the new E suffered the worst drop in rank"
s1 = all(c[x] > c[E] for x in positions if x != E)
# V's predecessor and the person who formerly held X's new job agree with s1
#(       X       )   (                Y                       )
X = p.index(V)
Y = p.index(X)
if not(s1 == t[X] == t[Y]): continue

# the man who filled the post vacated by the person who took over P's old job...
#    (                Y                 (                 X                  ))
X = p[P]
Y = p[X]
# ... says he is now senior to someone to whom he was previously junior
s2 = any(p[Y] > p[x] for x in positions if Y < x)
if not(s2 == t[Y]): continue

# S says in neither administration was he junior to the former S
#                                                  (      X     )
# i.e. S says in both administrations he was senior to X
X = p.index(S)
s3 = (S < X) and (p[S] < S)
if not(s3 == t[S]): continue

# output a solution
jobs = "PVTSE"
printf("{p}", p=' '.join(jobs[i] + '<-' + jobs[x] for (i, x) in enumerate(p)))
```

Solution: The new President was formerly the Secretary. The new Vice President was formerly the Entertainments Officer. The new Treasurer was formerly the Vice President. The new Secretary was formerly the President. The new Entertainments Officer was formerly the Treasurer.

We can see this by considering:

Now: President = Andy, Vice President = Bob, Treasurer = Col, Secretary = Dave, Entertainments Officer = Ed.
Prev: President = Dave, Vice President = Col, Treasurer = Ed, Secretary = Andy, Entertainments Officer = Bob.

The number of places moved in the reshuffle is:

Andy: +3, Bob: +3, Col: -1, Dave: -3, Ed: -2.

So Andy and Bob tell the truth. Col, Dave and Ed lie.

The first statement is that the new Entertainments Officer (Ed) suffered the worst drop in rank. He didn’t – he only dropped 2 places, Dave dropped 3 places. So only liars can agree with the statement.

The Vice President’s predecessor, Col, is a liar, so would agree. And the person who formerly held Col’s new job, i.e. the former Treasurer, Ed, is also a liar, so he too would agree.

So the first condition holds.

The man who filled the post vacated by the person who took over the new President’s old job is Andy. (President Andy’s old job is Secretary, and the person who took over as Secretary is Dave. Dave vacated the President’s job, and the President’s job was filled by Andy). Andy (who tells the truth) says he is now senior to someone that he was previously junior to. He is now president, so he is senior to everyone else. And formerly he was Secretary, so junior to President Dave, Vice President Col and Treasurer Ed.

So the second condition holds.

The new secretary is Dave, who is a liar. The former secretary is Andy. So Dave says he was not junior to Andy in either administration. But in the new administration Secretary Dave is junior to President Andy.

So the third condition holds.

Hence this is indeed a solution.

2. Julian Gray 5 August 2015 at 4:18 pm

Congratulations Jim – 300 – another milestone on the way up.

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