From Puzzles to Programming

Puzzles and Programming

  1. You have three boxes, one containing 2 white marbles, one containing 2 black marbles, and a third containing one balck marble and one white marble. The boxes were labeled as WW, BB, and BW respectively according to their contents. For some reason, the labels were switched and every box is now wrongly labeled. Can you determine the contents of all the boxes from the color of one marble that you draw from a particular box without looking inside?

 

Answer

 

If you draw from the box labeled BW a black marble then since it is wrongly labeled, it must have 2 black marbles. The box labeled WW contains a white marble and a black marble and the box labeled BB contains 2 white marbles.

 

If the marble drawn from BW labeled box is white then this box has to contain 2 white marbles. The box labeled WW contains 2 black marbles and the BB labeled box contains one black marble and one white marble.

2. Can you cover the table of squares below with 2 sided dominos so that each square is covered by one side of a domino?

 

 

 

 

Answer:

No. It is not possible because the number of squares in the table is 47 an odd number making one side of a domino not covering any square.

Another way to look onto the problem is to color it alternatively with white and black as follows:

 

 

Here, the number of black squares is 24 and white squares 23, thus leaving a white square uncovered by a side of a domino.

 

3. You have several red balls and yellow balls in a box at a ratio of 3 to 5. How many balls do you have to take from the box so that a pair of them will have the same color?

 

Answer:

It is simple one. Actually, it has to do more with intuition than to do with probability. You need to take out only 3 balls because at least two of the three balls will have the same color. There are only 2 colors to deal with.

 

Neither a closed mind nor an empty one is likely to produce much that would qualify as effective reasoning. Nickerson (1986)