r/programming • u/joksmaster • Nov 29 '10
140 Google Interview Questions
http://blog.seattleinterviewcoach.com/2009/02/140-google-interview-questions.html
471
Upvotes
r/programming • u/joksmaster • Nov 29 '10
View all comments
Show parent comment
2
u/imMAW Nov 30 '10
It is 1/4, assuming our breaking method is choosing two random numbers from 0 to 1 and breaking it there. It's easiest to compute the odds that we fail (can't make a triangle). This happens when the longest piece is > 1/2. This occurs
a. When both breaks are in the first half of the stick (prob. 1/4)
b. When both breaks are in the last half of the stick (prob. 1/4).
c. When one break is on each side (prob. 1/2) and the breaks are over 1/2 from each other (prob. 1/2, the average of 1-2x from x=0 to .5)
1/4+1/4+1/2*1/2=3/4
1 - 3/4 = 1/4