Browsing the archives for the Probability category

Red and Blue Marbles

Tweet Question: You have 50 red marbles, 50 blue marbles and 2 jars. One of the jars is chosen at random and then one marble will be chosen from that jar at random. How would you maximize the chance of drawing a red marble? What is the probability of doing so? All 100 marbles should […]

The Ant Problem

Tweet 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 […]

13 Comments

Pick a Random Byte

Tweet 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 […]

Boys and Girls

Tweet 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 […]

Probability of a Car Passing By

Tweet Question: The probability of a car passing a certain intersection in a 20 minute windows is 0.9. What is the probability of a car passing¬†the intersection in a 5 minute window? (Assuming a constant probability throughout) Answer: This is one of the basic probability question asked in a software interview. Let’s start by creating […]

12 Comments