Programmers and Coins

One programmer draws on a sheet of paper several circles in a line, representing coins, and puts his thumb on the first circle, covering the rest with his hand. Then he asks another programmer to guess how many different head-tail combinations are possible if someone flips all the (imaginary) coins on the paper. The second programmer, without knowing the number of circles, takes the pen and writes down a number. Then the first programmer lifts his hand and sees that the correct answer is written on the paper. How did the second programmer manage to do this?

The second programmer wrote down “1” in front of the first circle. When the second programmer lifted his hand, he saw the number “10…00”, which is exactly the number of possible head-tail combinations in binary system.

The Pasta Puzzle

You have 10 strings of pasta left on your plate. You randomly start tying up their ends, until there are no loose ends anymore. What is the average number of loops which are created?

The expected (average) number of loops at the end of the procedure is equal to the expected number of loops created after the first tying, plus the expected number of loops created after the second tying, etc. After each tying, the number of non-loop strings decreases by 1, and then the probabilities to create a new loop are 1/19, 1/17, 1/15, etc. Therefore, the answer is the sum 1/19 + 1/17 + 1/15 + … + 1/3 + 1/1 ~ 2.1.