This was trickier than it looked. I have a feeling that there should be a quicker way to find the answer than the list of cases I worked through.
Note: I interpret "two of which are factors of the third" to mean that two of the numbers divide the third, and that either of those two factors might be 1.
If "factor" cannot be 1, then 2,4,8 and 2,3,6 remain as two options, but they cannot be a solution, because all of the people should be able to know their number at the first sight. Conclusion: "factor" can be 1.
Mr.Hehe sees 2 and 3 so he knows he has 6 before all. The others see 2,6 and 3,6 so they don't know their number because they both think they ...
Say the starting point is row number $n>1$, column letter $l$, and exactly one cell is omitted. The ant's journey can be described as follows:
The only possible starting point is
It is not possible to do this in 12 steps. In fact, a simple argument shows that at least 20 steps are necessary:
Tiles 1 and 8 need to be swapped. They are however a distance of 3 moves apart, so each tile needs to be moved at least 3 times. Similarly, tiles 2 and 7 also each need 3 moves to reach their goal locations. So these 4 tiles together need at ...
With the following code let prolog search the results - X, Y, Z are the coefficients for each bag.
list_allperms(L, Ps) :- bagof(P, permutation(L,P), Ps).
f(X,Y,Z,R) :- R #= 10 * X + 11 * Y + 12 * Z.
fit(X,Y,Z) :- f(X,Y,Z,R), R #< 51.
fit_limit(L) :- nth0(0,L,X),nth0(1,L,Y),nth0(2,L,Z),fit(X,Y,Z).
fit_unique(L,R) :- nth0(...
What combinations of numbers are possible?
From this list of possibilities, we need to find one where one person can know what their number is by seeing two of the other numbers. Here are the possible numbers a person could see others having (lowest number first), and the possible numbers that the person could be.
Now we have 3 possibilities for two ...
I took a slightly different approach to Jaap Scherphuis:
The two smaller numbers are factors of the largest number, and all 3 numbers are different. This means that the largest number cannot be prime - ruling out 1,2,3,5,7, and leaving us with 4, 6, 8, and 9.
There are 32 possible pairs of factors of the numbers 4, 6, 8, and 9, but only 8 of these ...
Since Hehe knows his own number by watching the others, one can test the different factors that could lead to it (watched hats, with ascending sort -> possible hats Hehe could have):
So we only keep some of these entries:
And just consider:
Hehe knows his number even before the other ones talk. This means: a-priori he knows, with no ambiguity, the number ...