Cover image for Amazon Lab126

Amazon Lab126

Part of Amazon
Engaged Employer

Amazon Lab126

Add an Interview

Interview Question

Hardware Design Engineer Interview


Amazon Lab126

Parallel lines are drawn on the floor, 1 inch apart. A toothpick 1 inch long is dropped randomly on the floor. How would you calculate the probability that the toothpick crosses one of the lines?

Interview Answers

2 Answers


There is a mathematical solution but in the interest of time, you could suggest tossing the toothpick a number of times and counting the number of crosses divided by the total number of tosses.

Anonymous on


The above solution is probably not ideal given that you did not demonstrate any thinking skills behind it. First you need to ask how large is the floor. If the floor is as large as the surface of the earth, then the probability is almost 0. Then the interviewer might define the floor as the space demarcated by the two lines. In this case, you need to define the position of the toothpick by its center position and its angle/orientation. The center of the toothpick as and its orientation follow a uniform distribution. The more difficult part is to analyze what combination of the two parameters counts as a 'crossing' event. For example, if the center of the toothpick is the middle between the two lines, then whatever the angle you have, the toothpick does not cross the two lines. Conversely, if the center of the toothpick falls on one of the lines, then it's going to cross the line no matter what. For the intermediate cases, use trigo to find an expression for the angle. In the end, you need to do an integral and get the probability out.

John Zhang on

Add Answers or Comments

To comment on this, Sign In or Sign Up.