Clock

​Suppose I have a 10-digits lock. The lock has the following rule: The first digit of the code is the number of occurrences of the digit '0' in the password The second digit of the code is the number of occurrences of the digit '1' in the password The third digit of the code is … Continue reading Clock

Boys-Girls

Question: In a country where everyone wants a boy, each family continues having babies till they have a boy. After some time, what is the proportion of boys to girls in the country? (Assuming probability of having a boy or a girl is the same) Answer: This is a very simple probability question in a software interview. … Continue reading Boys-Girls

Bytes

Question: You have a stream of bytes from which you can read one byte at a time. You only have enough space to store one byte. After processing those bytes, you have to return a random byte. Note: The probability of picking any one of those bytes should be equal. Answer: Since we can only store one … Continue reading Bytes

Ants

Question: Three ants are sitting at the three corners of an equilateral triangle. Each ant starts randomly picks a direction and starts to move along the edge of the triangle. What is the probability that none of the ants collide? Answer: So let’s think this through. The ants can only avoid a collision if they all decide … Continue reading Ants