Sometimes, riddles can be great fun. But what if they were a matter of life and death? The fine folks of TED decided to propose a riddle to the internet, which is that of the “prisoner hat” riddle. We’ll let the video explain, but suffice to say that it will hopefully get you thinking.

We’re sure lots of people came up with a solution of some kind (such as fighting your way to freedom), but the answer they give that saves everyone’s lives is borderline mind-blowing. It’s an ingenious and fool-proof solution to a highly unlikely situation, but it’s fascinating nonetheless. Can you solve this riddle? Let us know in the comments what you thought the solution was!

via TED-Ed