# Three people wearing hats

Ms. Doha gave hats with different non-zero single digits (two of which are factors of the third) to Ms. Haha, Ms. Lola and Mr. Hehe. The three of them can't see the digits on their own hat though they know of the rule that two are factors of the third.

The following conversation ensues.

Ms. Haha: I don't know my number.
Ms. Lola: I don't know my number.
Mr. Hehe: I knew my number before either of you spoke.
Ms. Haha and Ms. Lola: Now we both know our digits.

What are their digits?

• Do they know that the hats have single digits before hand? What about the fact that they are different? Do they know that the numbers are greater than zero? Can they see each other's hats? Sorry question is too vague. – Deepthinker101 Dec 4 '19 at 6:30
• Like other hat puzzles are they standing in a line? Who can see other hats? – sudhackar Dec 4 '19 at 6:42
• Actually you did not state whether the numbers are greater than zero even – Deepthinker101 Dec 4 '19 at 6:53
• In the last step, do Haha and Lola both know that they both know their numbers? Or does each one just know that she knows her number, without knowing about the other one? – Rand al'Thor Dec 4 '19 at 7:53
• @JiK see the 6th word. ( the one starting with letter "d") – user63710 Dec 5 '19 at 21:26

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.

No hat can have a 5 or 7, because they are prime and only have one strict divisor (viz. 1), and no multiples that are also a single digit, so there are no valid triplets that use either number.

Mr. Hehe can deduce his number.
He can't see 1 and 2, cause then he could have 4 or 8 and wouldn't know his number.
He can't see 1 and 3, cause then he could have 6 or 9 and wouldn't know his number.
He can't see 1 and 4, cause then he could have 2 or 8 and wouldn't know his number.
He can't see 1 and 6, cause then he could have 2 or 3 and wouldn't know his number.
He can't see 1 and 8, cause then he could have 2 or 4 and wouldn't know his number.
He can't see 1 and 9, cause then he would correctly deduce he had 3, but the person seeing 3 and 9 would also have been able to deduce their number at the start.
Therefore he does not see a 1.

Suppose he sees two numbers divide each other.
If he sees $$a$$ and $$a*b$$ where $$a,b$$ are distinct and not 1, then he could have 1 or $$b$$, so wouldn't know his number.
If $$a,b$$ above are not distinct, then he sees 2,4 or 3,9. In the first case he could have 1 or 8, so wouldn't know his number. In the second case he must have 1, but then the person seeing 1,9 would also have been able to deduce their number from the start.
Suppose he sees two numbers that are not coprime.
If he sees $$a*b$$ and $$a*c$$ where $$a,b,c$$ are not 1, then he could have 1 or $$a$$, so wouldn't know his number.
Therefore Hehe sees two numbers which are coprime, and he has a number which is divisible by both.

The only remaining possibility is that he sees 2,3 and has 6 on his hat. All other coprime pairs have a lowest common multiple that is greater than 9.

Let's check this answer in a different way, simply by enumerating all possible triplets. They are:

1,2,4
1,2,6
1,2,8
1,3,6
1,3,9
1,4,8
2,3,6
2,4,8

The only pairs of numbers that occur on this list exactly once are:
1,9 -> 3
2,3 -> 6
3,9 -> 1
So the only triplets that allow for a deduction are 2,3,6 and 1,3,9. The latter triplet however allows two people to deduce their number. Therefore only 2,3,6 is a valid solution.

• Why the downvote? Is this answer incorrect? – Rand al'Thor Dec 4 '19 at 8:09
• I don't understand why you use 1 anywhere in there, because 1 * X will always give X and the numbers have to be different. Also, why would 2, 3 and 6 be the solution when 2, 4 and 8 seem equally plausible? – Technoh Dec 4 '19 at 19:58
• @Technoh If two of the numbers are 1 and x, it does not mean that the third number has to be x (which would be invalid of course since they must all be different), as it can be any multiple of x. For example, 1,2,4 is a perfectly valid triplet since both 1 and 2 are factors of 4. With 2,4,8 - the person seeing 2,4 does not know if they have 1 or 8; the person seeing 2,8 does not know if they have 1 or 4; the person seeing 4,8 does not know if they have 1 or 2. No one can therefore deduce their own number. – Jaap Scherphuis Dec 4 '19 at 20:26
• @JaapScherphuis I think my answer has a slightly simpler method of getting to the first 8 triplets – Chronocidal Dec 5 '19 at 10:35
• You could just start your answer from the enumeration, I guess? It is clean and short and easy to follow. – justhalf Dec 9 '19 at 0:23

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 might have 1 as well. That means that a possible solution is 2,3,6.

Can any of the number be 1?

Well, if Mr. Hehe sees a 1 and another number (a) , in order to enable him determine his own number, the following should apply: ab or a/b and ac or a/c cannot be integers <10 both at the same time (if b and c are any random positive unequal integers).Since 5 or 7 cannot make up any kind of triplet, from this the only possibility is a=9 and Mr. Hehe having 3. But in this case one of the others should be able to determine her own number too without hearing any speak, so this is what makes this "special situation" (1,3,9) impossible.

If Mr Hehe does not see 1, but he has 1, following the previous thinking both other numbers should satisfy the rule that there exist ab or a/b and ac or a/c both<10, so that the first two speakers cannot decide, but obviously in this case Mr. Hehe wouldn't be able to tell his own either.

So 1 cannot be a number on any of the hats.

Therefore the solution is definitely 2,3,6

We saw that the number 1 theoretically can be a factor, it is just the situation that makes 1 impossible to be a number on a hat, and this only we know, they don't. In fact, they realize that after Mr. Hehe speaks. Namely, that none of them has 1, their case is not our "special situation", because then one of the first two should have spoken otherwise, and so Mr. Hehe's speach is exactly what enables them to realize that Mr. Hehe really saw coprimes, which explains the last part "Ms. Haha and Ms. Lola: Now we both know our digits", because there is only one possibility for that (2,3).

• How do you know that "Mr.Hehe sees 2 and 3" ? While you show that this is a valid solution, it does not show there are no other solutions, e.g. why could Mr. Hehe, not see a 1? If he sees 1 and 9 for example, then he knows that he must have a 3. Why is it obvious he cannot see two numbers with gcd>1? For example, if he sees 3,9 (which have gcd 3), he knows his own number is 1. – Jaap Scherphuis Dec 4 '19 at 22:59
• @JaapScherphuis Mr Hehe must see 2 and 3 because we are told that he is able to work out his number. If he saw a 1 he would not have enough information to work out his number, therefore he did not see a 1. Only because we are given the meta information that he found the solution are we also able to find that solution. – jla Dec 4 '19 at 23:46
• @jla If the sees 1 and 9, then he can work out his number. It must be 3. – Jaap Scherphuis Dec 4 '19 at 23:50
• Yes, true, 1,3,9 needs special attention. Here Mr. Hehe cannot have the highest, because from seeing 1,3 he wouldn't be able to choose between 6 and 9. Also, the one who sees the highest and another number, would be able to tell his own before Mr. Hehe speaks. That is why 1,3,9 is not possible, but I definitely didn't include this option. – balazs.com Dec 5 '19 at 0:08
• @balazs.com "Not including this option" is not much of an explanation: this answer effectively jumps in half way through, without showing how you determined several key steps. – Chronocidal Dec 5 '19 at 10:28

What combinations of numbers are possible?

You can use the formula a * b * k = c where a, b, and c are the three single digit numbers and k is another possible factor of c. In this case, c will be larger than a and b so it cannot be 1 or 2. Let's look at factors of 3-9:
3: 1,3 - impossible because there are only 2 unique numbers
4: 1,2,4 - could be 1,2,4 (1 * 2 * 2 = 4 , so a and b could be 1 and 2 and c could be 4
5: 1,5 - impossible because there are only 2 unique numbers
6: 1,2,3,6 - could be 1,2,6 or 1,3,6 or 2,3,6
7: 1,7 - impossible because there are only 2 unique numbers
8: 1,2,4,8 - could be 1,2,8 or 1,4,8 or 2,4,8
9: 1,3,9 - could be 1,3,9

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.

1,2 - could be 4 or 8
1,3 - could be 6 or 9
1,4 - could be 2 or 8
1,6 - could be 2 or 3
1,8 - could be 2 or 4
1,9 - has to be 3 (1,3,9)
2,3 - has to be 6 (1,2,3)
2,4 - could be 1 or 8
2,6 - could be 1 or 3
2,8 - could be 1 or 4
3,6 - could be 1 or 2
3,9 - has to be 1 (1,3,9)
4,8 - could be 1 or 2

Now we have 3 possibilities for two single digit numbers that would allow someone to deduce their own number.

If I see 1 and 9, I know I am a 3. If I see a 3 and 9, I know I am a 1. If I see a 2 and a 3, I know I am a 6.

But two of those possibilities are for the same set of three numbers. That cannot be the case here because two of the people could not deduce what their numbers were.

If Mr. Hehe saw a 1 and 9, he would know he is a 3. The problem is one of the other two would see a 3 and a 9 and could deduce their were a 1. So that cannot be the case.

So now they all know that Mr. Hehe was able to deduce his number. That lets the first people know the three digits, otherwise Mr. Hehe could not have deduced his number. Since they can see the other two digits, they know what their own digit must be.

The other two are interchangeable for this problem, so let's assume Ms. Haha is 2 and Ms. Lola is 3:
Ms. Haha: I don't know my number. (sees 3 and 6, she could be a 1 or a 2)
Ms. Lola: I don't know my number. (sees 2 and 6, she could be a 1 or a 3)
Mr. Hehe: I knew my number before either of you spoke. (the only possible condition is if he saw a 2 and 3 and deduced he was a 6)
Ms. Haha and Ms. Lola: Now we both know our digits. (They can deduce that the combination is 2,3,6 because if either were a 1, Mr. Hehe wouldn't know for certain what his number was before anyone spoke. And since they can see 6 and the other person's number, they know they are the remaining number of the trio)

First, we know that that Hehe's and Lola's number must be factors of each other - if the number would be 2 and 3 for example, Haha would know his number is 6. The same goes for Lola.

Then, Hehe saw that Haha's and Lola's number are not factors of each other or if they were, there would be only one solution for the third number. The possibilities are: (2,3) => 6, (1,9) => 3.

The latter can't be correct, because Haha would see (9,3) and the only remaining possibility for his number is 1.

The first example however, is correct, because Haha would see (3,6), which would mean either 1 or 2 for him, and Lola would see (2,6), which would mean (1,3) for her. But Hehe's only option would be 6.

Below I explain all the deductions I have been seeing until I reach the solution:

Possibilities:

The possibilities being two-digit factors of the third would be these (excluding prime numbers):

1x1 = 1
1x2 = 2
1x3 = 3
1x4 = 4
1x6 = 6
1x8 = 8
1x9 = 9
2x2 = 4
2x3 = 6
2x4 = 8
3x3 = 9

Doubts and deductions:

I have doubts with the statement where it is said that Ms. Doha gave hats with different digits, but analyzing it I think it refers to only different from non-zero because otherwise the possibilities would be these:
2x3 = 6
2x4 = 8
and the possible hats with numbers that delivered these:
(2,3,4,6,8)
and there would be no single solution.
Therefore, I deduce that you can have repeated numbers and the possible numbers these because the number 1 plays an important role:
(1,2,3,4,6,8,9)

Description:

Mr. Haha does not know because he is seeing (6) of Mr. Hehe and (3) of Ms. Lola and does not know if his is a 1 or a 2, both factors of 6.
Ms. Lola does not know because she is seeing (6) of Mr. Hehe and (2) of Mr. Haha and does not know if his is a 1 or a 3, both factors of 6.
Mr. Hehe knows what he has before the others speak because he is seeing a: (2 and 3) and therefore knows that the only possibility is that he has a 6.
Saying Mr. Hehe that he already knows, the others already deduce that they have a 2 Mr. Haha and a 3 Ms.Lola, discarding the possibilities (1x2=6) or (1x3=6), since number 1 also being a factor of 6.

Solution and vision of each:

(2,3,6)
Mr. Hehe has (6) and sees (2 and 3) and knows he has 6.
Mr. Haha has (2) and sees (3 and 6) yours could be 1 or 2.
Ms. Lola has (3) and sees (2 and 6) yours could be 1 or 3.

Note: the solution is (2,3,6) but it is not known exactly what number Mr. Haha and Mrs. Lola have, they could have 2 and 3 or 3 and 2 respectively.

• Ms. Doha gave hats with different non-zero single digits – Ardweaden Dec 4 '19 at 11:26
• @Ardweaden yes, "different non-zero single digits", read the deductions I put? I think it diferents only refers to nonzero digits not different between the numbers themselves – borchvm Dec 4 '19 at 11:47

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 triplets consist of 3 unique numbers:

1 | 2 | 4
1 | 2 | 6
1 | 3 | 6
2 | 3 | 6
1 | 2 | 8
1 | 4 | 8
2 | 4 | 8
1 | 3 | 9

Half of these consist entirely of powers of 2 - however, there are 4 different powers of 2 in the digits 1-9, so seeing any pair of those leaves you with two possible numbers on your own hat (i.e. if you see 2 and 4, then your hat can be either 1 or 8) - this means that no participant would be able to guess their number correctly. We are reduced to 4 possible triplets:

1 | 2 | 6
1 | 3 | 6
2 | 3 | 6
1 | 3 | 9

If we refactor this as visible pairs - ignoring whether Mr Hehe is wearing the largest hat or not - you get the following 8 combinations:

1 | 2 : appears 1 time (6)
1 | 6 : appears 2 times (2, 3)
2 | 6 : appears 2 times (1, 3)
1 | 3 : appears 2 time (6, 9)
3 | 6 : appears 2 times (1, 2)
2 | 3 : appears 1 time (6)
1 | 9 : appears 1 time (3)
3 | 9 : appears 1 time (1)

4 of these pairs appear more than once, which means that there is more than 1 number Mr HeHe could be wearing. Of the remaining 4:

1 | 2 : Mr Hehe could be wearing 2, 4 or 8 - any even number less than 10
2 | 3 : Mr Hehe can only be wearing 6, as the next common multiple of the primes 2 and 3 is 12
1 | 9 : Mr Hehe can only be wearing 3, as 9 is the square of a prime number
3 | 9 : Mr Hehe can only be wearing 1, as 9 is the square of a prime number

Since 1, 3 and 1, 9 are both from the same triplet, this means that either Ms Haha or Ms Lola would have already been able to also guess their number correctly. So, as should be obvious, the hats are

2, 3 and 6, with Mr Hehe wearing number 6

• Where are 1|3, 1|9 and 3|9 on your visible pairs list? – Jaap Scherphuis Dec 5 '19 at 10:52
• @JaapScherphuis Bleh, I seem to have forgotten to split the second and fourth triplets properly. Fixed now - thanks – Chronocidal Dec 5 '19 at 11:59

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):

1, 2 -> 4, 6, 8
1, 3 -> 6, 9
1, 4 -> 2 (factor), 8 (product)
1, 5 -> impossible
1, 6 -> 2 (factor), 3 (factor)
1, 7 -> impossible
1, 8 -> 2, 4
1, 9 -> 3 (factor)
2, 3 -> 6 (product)
2, 4 -> 8 (product), 1 (factor)
2, 5 -> impossible
2, 6 -> 3 (factor), 1 (factor)
2, 7 -> impossible
2, 8 -> 4 (factor), 1 (factor)
2, 9 -> impossible
3, 4 -> impossible
3, 5 -> impossible
3, 6 -> 2 (factor), 1 (factor)
3, 7 -> impossible
3, 8 -> impossible
3, 9 -> 1 (factor)
4, 5 -> impossible
4, 6 -> impossible
4, 7 -> impossible
4, 8 -> 2 (factor), 1 (factor)
4, 9 -> impossible
5, 6 -> impossible
5, 7 -> impossible
5, 8 -> impossible
5, 9 -> impossible
6, 7 -> impossible
6, 8 -> impossible
6, 9 -> impossible
7, 8 -> impossible
7, 9 -> impossible
8, 9 -> impossible

So we only keep some of these entries:

1, 2 -> 4, 6, 8
1, 3 -> 6, 9
1, 4 -> 2 (factor), 8
1, 6 -> 2 (factor), 3 (factor)
1, 8 -> 2 (factor), 4 (factor) 1, 9 -> 3 (factor)
2, 3 -> 6 2, 4 -> 8, 1 (factor)
2, 6 -> 3 (factor), 1 (factor)
2, 8 -> 4 (factor), 1 (factor)
3, 6 -> 2 (factor), 1 (factor)
3, 9 -> 1 (factor)
4, 8 -> 2 (factor), 1 (factor)

And just consider:

1. Hehe knows his number even before the other ones talk. This means: a-priori he knows, with no ambiguity, the number on his hat.
2. The other ones know their own hats after Hehe talks, and not before.

We only keep combinations (1, 9), (3, 9), (2, 3) for Hehe to observe, because they lead Hehe to only one answer, according to point 1.
- (1, 9) will be discarded, since one of them could see (3, 9) in the others and infer 1.
- (3, 9) will be discarded, since one of them could see (1, 9) in the others and infer 3.
- (2, 3) is the good one, because they will observe (2, 6) -> foresee {1, 3} and observe (3, 6) -> foresee {1, 2}. Since they get that 6 (hehe) easily gets his number, they get that it must be because the combination is (2, 3) for them.

This gives quite a simple solution:

For one person to know their number by looking at the other two, neither must be a factor of the other, and therefore they can deduce their number. This immediately discounts 1. 5-9 are discounted by the fact that 2 multiplied by them are above 9. This leaves 2,3 2,4 and 3,4. 2 Is a factor of 4, and 3 & 4 are common factors of 12. Therefore the answer must be 2,3 which are common factors of 6. Final answer: 2,3,6

• Your explanation fails to account for being able to see the number 9, and either 1 or 3 – Chronocidal Dec 5 '19 at 19:54
• No it doesn't, as seeing either of those numbers doesn't guarantee your number. The only way to guarantee your number is if the numbers you see don't share a common factor. – WittierDinosaur Dec 6 '19 at 13:20
• If Mr Hehe sees the numbers 9 and 1, then he knows his number must be 3 - because, the only factors of 9 are 1, 3 and 9, and neither 1 nor 9 can be repeated. (However, in this case, either Ms Haha or Ms Lola would have seen 9 and 3, so would already know their number was 1, by the same logic) – Chronocidal Dec 6 '19 at 13:22
• Yes, but then whoever sees 3 & 9 knows theirs is 1, therefore it isn't a unique solution – WittierDinosaur Dec 6 '19 at 13:35
• Then edit that into your answer - as they most likely once told you at school: "show your working", and don't skip steps. – Chronocidal Dec 6 '19 at 13:45

When you tag a problem with [mathematics] you should adhere to the standards.

So Example Solution:

Ms. Haha: 7 Ms. Lola: 7 Mr. Hehe: 1

Checks:

All three numbers are non-zero: check All three numbers are digits: check The three numbers are different: check (They are not the same.) Two are factors of the third: check (Both Mr. Hehe's and Ms. Lola's numbers are factors of Ms. Haha's.)

Reasoning:

Ms. Haha: Sees 1 and 7. 7 can only be factor of 7 or multiple of 7 and 1. That leaves 7 and 1, two opportunities, no certainty. Ms. Lola: Same as above. The 1 can not be excluded by Ms. Hahas statement as 1 would leave even more possibilities (about 8). Mr. Hehe: Sees 7 and 7. For same reasons as above ends up with options 1 and 7. 7 would make numbers same, so excluded. Only option is 1. Hence certainty. Ms. Haha and Ms. Lola: Can exclude 1 now as it would not lead to certainty for Mr. Hehe. Are both independently left with 7, so certainty.

Do not read things in the question that are not there! Adhere to definitions when tagging!