Three Hat Puzzle

As three people enter a room, a hat is placed on each head.

The color of each hat (red or blue) is determined by a coin toss.

Each can see the other hats, but not his own.

They are not allowed to communicate once the game begins.

After looking at the other hats, all must simultaneously guess the color of their own hats or pass.

The group shares a big prize if at least one guesses correctly and none guess incorrectly.

For example, if one guesses “Red” and others “pass” gives 50% chance.

What strategy should the three agree on to maximize their chances?

What color is my hat?

What color is my hat?



If you see 2 red hats, then guess that yours is blue.

If you see 2 blue hats, then guess that yours is red.

Otherwise, you see one red and one blue, then pass.

Your team of 3 will only fail if all hats are red or all are blue.

You lose 2 out of 8 possible outcomes, your chances of winning are 75%.

Categories: Story Tags: Tags: , , ,

Mad Scientist Puzzle

A mad scientist captures 5 close friends in his dungeon.

He tells them that at dawn the next morning he will return and line them up facing the wall, one behind the other so that each will only be able to see his friends that are in front of him.

Then he will place hats on each of their heads.

The hats will be either black or white.

Each of the five must guess the color of their own hat.

If they guess wrong, they will be immediately executed,

otherwise they will be set free after all five have made their choices.

He leaves them alone to plan their strategy.

How does the group work together to maximize the number of survivors?

What color is your hat?

What color is your hat?


The last guy can see the hats on his 4 friends.

He guesses that his hat is the same color as the friend in front of him.

He has 50% chance to live.

His friend in front of him knows his hat color from what his friend said, he is safe.

The third person in line gives the color of the hat in front of him and has 50% chance.

We can expect 3.5 of 5 survivors.

Is there a better answer?

Categories: Story Tags: Tags: , , ,

Fusing nationality, pet, house color, drinks, and smokes

Five people of different nationalities live in five houses of different colors.
None have the same pet, smoke the same cigar, or drink the same drink.
Brit lives in red house
Swede keeps dogs
Dane drinks tea
Green house is left of white
Green house owner drinks coffee
Smoker of Pall Mall rears birds
Owner of yellow house smokes dunhill
Man living in center house drinks milk
Norwegian lives in the first house
Smoker of blends lives next to the one who keeps cats
Keeper of horses lives next to smoker of dunhill
Smoker of bluemaster drinks beer
German smokes prince
Norwegian lives next to blue house
Smoker of blend has a neighbor who drinks water
Who owns the fish?

Combine various properties to solve the puzzle

Combine various properties to solve the puzzle


The German in the 4th green house who drinks coffee and smokes prince.


Categories: Story Tags: Tags: , , ,

Burning Fuse Puzzle

You are given a lighter and two fuses, each takes 60 minutes to burn end-to-end. How do you use these 3 items to measure exactly 45 minutes? The fuses do not burn at a constant rate, so you cannot cut one in half for 30 minutes, or quarters for 15 minutes. (No cutting of fuses.) Hint: It does not matter which end you light, either way the fuse takes 60 min to burn.

45 minutes?

45 minutes?


To get 45 min from two 60 min fuses, light 3 of the 4 ends. The fuse lit at both ends will burn out after 30 min. At this time, light the other end of the other fuse which would have had 30 min left. It will burn out in 15 min for a total of 45 min.

The answer

The answer

Categories: Story Tags: Tags: , , ,

Traveling Salesman Puzzle

A salesman knocks on the door of a house.

When a woman answers the door, he asks her how many children she has.

She replies, “3”.

He then asks their ages.

Offended, she replies obscurely, “The product of their ages is 36.”

He says that he needs more information.

She replies, “The sum of their ages is the address of the house next door.”

Even though he is a gifted amateur mathematician, he explains that this is still not enough information.

She replies, “My oldest plays the piano.”

He says “Thank you.”, and writes their name in his notebook.

What are the ages (integer years) of the three children?


My solution:

Possible ages of 3 kids whose product is 36 (I*J*K=36) are:

(1 1 36), (1 2 18), (1 3 12), (1 4 9), (1 6 6), (2 2 9), (2 3 6), (3 3 4)

Sums of these possible age sets are:

(I+J+K) = 38, 21, 16, 14, 13, 13, 11, 10

That you need to know that there is an oldest child (who plays piano) suggests that you need to decide between (1 6 6) and (2 2 9) which both sum to 13.

My answer for kids ages are 2, 2, and 9.

Categories: Story Tags: Tags: , , ,

Circles in a Rectangle

Geometry Puzzle:

You have a 6×7 rectangle with a 6 diameter circle cut from one side.

What is the largest circle that you can cut from the remaining material?

Find the largest circles that fit in the rectangle.

Find the largest circles that fit in the rectangle.



(r + 3)² = (4 – r)² + (3 – r)²

0 = r² – 20 r + 16

r = 10 – sqrt(100 – 16) ~ 0.834849

Categories: Geometry Tags: Tags: , ,

IDL for Rapid Scripting of Image Processing

Interactive Data Language (IDL) is a language environment for rapidly scripting algorithms for processing imagery. IDL is closely tied to the more graphical ENvironment for Visualizing Images (ENVI) image processing environment from the same company. This simple high-level scripting language, supported by extensive tools, enables quickly hacking algorithms to find workable solutions.


IDL enables rapidly roughing out ideas at a high level by freeing developers from first building an extensive tool-kit of common image processing routines. As with most scripting languages, there is no need to declare variables with specific data types as in lower-level languages like C/C++. This level of control is available for optimizing performance on large arrays of data.

IDL is interactive, allowing the developer to enter and execute code fragments line by line without compiling and linking. Once the code fragment matures to being useful, it is simple to edit into a text file that can be run as a function or program within the IDL environment. Although the IDL library of functions is extensive, there will always be more functions that you will want to add.

As functions in IDL mature, they can be ported to lower level languages and compiled into binary executable code or libraries to improve speed and reduce memory requirements.

You can continue running algorithms in IDL as long as you have a licensed copy. But applying your algorithms more broadly on machines that do not have IDL, will require porting to another language.

Although there is an open-source version of MatLab, Octave, I have not heard of an open-source version of IDL. IDL does have a virtual machine that enables running IDL code “compiled” on a fully licensed version.