Phil Marius

Data Scientist, Data Engineer, Linux, and OSS Fan

14 Feb 2021

A Mathematician, a Physicist, and Four Men in Hats

Eleven year old me was staring perplexedly at the whiteboard at the front of the room. My form tutor at the time, Mr Freeman, had drawn a logic puzzle that had successfully stumped 30 of us. And all it consisted of was four men in hats.

The puzzle is not unique and is a common brainteaser in some online communities. Recently, I decided to run this puzzle past two friends of mine; one is a mathematician and the other is a physicist. Whilst both eventually arrived at the correct solution, their respective approaches differed wildly and will be the topic of today’s blog.

The Puzzle

I’m a fan of logic puzzles, even if I’m not very good at them as Mr Freeman can probably attest to, he’d probably chastise me for spending my time stacking glue sticks instead of paying attention. However, the four men in hats puzzle has stuck with me for well over a decade now and the premise is as follows.

Four men are buried up to their necks in sand, let’s call them A, B, C, and D.

The arrows indicate the direction in which they’re looking. A is separated from B, C, and D via a wall none can see through. None of them can move so can only look the direction the arrow is pointing. However, they do know they are buried in the alignment pictured: A and B cannot see anyone, C sees B and his hat, and D sees both B and C and their hats. They know, as a group, that there are two black hats and two white hats between them however they don’t know the colour of the hat on their own head.

Their captors propose a solution to their predicament. To be freed from the sand and to avoid further punishment, one of them needs to correctly guess their hat colour. However, they are not allowed to communicate amongst themselves and the only thing they’re allowed to say is the one word colour of their hat.

After 10 or so minutes, one of them calls out the colour of their hat correctly and they’re all set free.

Which of these men calls out the colour of their hat and how can they guess with 100% confidence?

Adding a bunch of whitespace here if you wish to puzzle this out for yourself. Scroll for solution.

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

 

The Solution

Let’s go through a process of elimination to work this out:

  • A → can’t see anyone else so is afraid to guess
  • B → same as A, can’t see anyone else
  • C → can only see B, only knows there are two black and one white hat left to choose from
  • D → if both had the same colour hat in front of him, he’d be able to guess, however the hats are of different colours so stays silent as he’s got a 5050 chance

Initially, it seems like they’re in a sticky situation and no one is able to guess. The trick to this is D’s silence. C is also aware that D would be able to guess with 100% certainty were B and C to have the same colour hat. However, D remains silent, which indicates that this is because they have different colour hats. So C, with 100% certainty, knows that he’s wearing a black hat.

If, like me, you didn’t get this right first time, then don’t worry I’ve somehow done alright in life it’s not the end of the world.

My two mates both got it right (after some discussion) but it’s their respective approaches I want to address.

The Mathematician

After explaining the rules and clarifying certain bits like the mens’ abilities to move, whether the wall is opaque or not, etc; the mathematician got quickly to work with a similar process of elimination detailed above. After reaching D, he paused and asked to clarify the process of escaping again.

“One person can only say one word, the colour of their own hat” I said. “No other communication.”

He looked down and said aloud “Well D can’t say anything as the hats in front of him are different”. Then he paused.

“Well it has to be C then as D isn’t saying anything”.

All in all he took around 5 minutes to work it out.

The Physicist

The physicist took a totally different approach.

“Is it daytime?” He asks.

“Sorry?” I’m confused.

“Is it daytime? Is the sun up?”

“I guess so?” I say in return.

“Ah, then those with black hats will work out that their heads get hotter as they absorb more heat.”

Annoyingly, he’s not wrong.

“There’s a roof,” I draw a lazy line over the top of the men.

“What’s it made out of?”

At this point I have to interject, “this is a logic puzzle, mate, not a physics exam. Start with A, can he guess what his hat is?”

After a brief back and forth, he reaches the same answer as the mathematician. This also took around 5 minutes.

My Thoughts on the Approaches

I pitched the problem in the same order as this blog is written, mathematician first followed by the physicist (on completely separate days may I add). Following the physicist’s answer, I was instantly intrigued by their totally different approaches to a problem I thought was relatively simple. They can be summarised as the following:

The mathematician used all the information presented in the initial puzzle to explore possible solutions to it. The physicist, however, tried exploring the initial puzzle to identify the solution, the instructions were simply a starting point to go from.

If we call the initial puzzle “the environment” and the instructions presented as “the rules”, then the mathematician used the environment rules to explore solutions whereas the physicist used the rules as a starting point to explore the environment.

STEM careers (Science, Technology, Engineering, Maths) are renowned for being black and white or right or wrong. I remember taking the piss out of humanities at school for a myriad of reasons, one of which was “there’s no right answer, just say it’s ‘your opinion’, it’s not wrong”. However, what this logic puzzle has led me to believe is that the idea of “no right answer” can be applied to STEM too.

If you remove the context from this puzzle (in that it’s a logic puzzle to be solved) then both the mathematician and the physicist were right, but in completely different ways. If you include the context, then the mathematician’s approach was “correct” and it could be argued the physicist “overcomplicated” it. This isn’t meant as a criticism of his solution by the way.

A theory to their differing solutions could lie in their respective skill-sets. Mathematics is all about using mathematics itself to redefine how we view the world. Physics is the study of nature from a physical perspective (instead of biological or chemical) and is all about exploring the world to uncover new rules to physics. So, essentially, mathematics is the using the environment (mathematics as we know it) rules to explore solutions within it whereas physics is using the rules we currently have (past physics discoveries) to uncover new unknowns in our environment.

I don’t know about you but this fascinates me.

There is another argument to be made that the different skill-sets lend to the different ways people’s minds work. Once I had started the exercise with the physicist, I had to adapt my description of the problem to adjust to the way he thinks. This is a technique I picked up when I used to tutor A Levels. By rephrasing the question so that the physicist could better interpret it, he was able to understand what I wanted better and answer accordingly.

This, in turn, may indicate how some are disenfranchised from learning more about STEM. Time and time again I hear people comment that they’re “not a tech person” and that they’ll “never understand this kind of stuff” yet I doubt that every time. I’ve heard that good teachers can totally transform a subject for a student, so, could it be that, due to poor or single-minded teaching, a person could lose interest in STEM as they need the teaching to be rephrased to suit the way their mind works? It’s constantly joked about that tech is filled with a certain stereotype of person and could that be due to all the teachers being that kind of person and teaching in a way that singularly suits that kind of person?

Before I get too existential, I would like to wrap this up by saying this. This is why diversity and representation matters. Without it, whole industries will be dominated by similarly minded people with similar needs and interests and, most importantly, similar biases. And that can lead to all sorts of trouble.