I have a row of 8 boxes labelled A, B, C, …, H. Each box contains a card with a number on it. The contents of the boxes are one of the following 17 possibilities:

13683641, (that is, 1 in A, 3 in B, 6 in C, …, 1 in H)

14187438,

15286227,

22832116,

24216228,

27255464,

33717335,

47644974,

51368742,

58161493,

61236227,

66787332,

75592512,

78893173,

82625966,

85371799,

93612651.

And here are four more facts:

P. Given the above facts, if I now tell you the number in box A then you can work out the number in box D.

Q. Given the above facts, if I now tell you the number in box B then you can work out the number in box H.

R. Given the above facts, if I now tell you the number in box F then you can work out the number in box C.

S. Given the above facts, if I now tell you the number in box G then you can work out the number in box E.

Unfortunately, I have forgotten what order the for facts P, Q, R, S should be in. I do remember that when they are in the right order you can work out the contents of the boxes. Also that there is only one order that allows you to do that.

What order should the four facts be in? And what are the contents of the boxes?

We can use the

filter_unique()function from theenigma.pylibrary to solve this puzzle.This Python program runs in 77ms.

Run:[ @repl.it ]Solution:The facts should be in order R, P, Q, S. The contents of the 8 boxes are: A=5, B=1, C=3, D=6, E=8, F=7, G=4, H=2.There are three other orderings that narrow the candidates down to a single possibility:

But these all narrow the candidate list down to the same possibility, so can be discarded, as in the correct scenario there is only a single order that works.

Here’s a simple program to demonstrate that considering the statements in the order R, P, Q, S, does indeed give a single answer:

From the initial 17 candidates, statement R narrows the list down to 14. Then statement P further narrows it down to 8. Statement Q to 3. And finally statement S to a single answer.