ML Interview Q Series: Geometric Probability: Forming a Triangle from Random Stick Cuts
Browse all the Probability Interview Questions here.
Imagine you have a unit stick, and you choose two cut points randomly and uniformly along its length. What is the probability that the three resulting segments can form a valid triangle?
Short Compact solution
If both cut points happen to lie on the same side of the stick’s midpoint (either both on the left half or both on the right half), then one of the three segments will exceed half the stick’s total length, making a valid triangle impossible. The probability that both cuts fall on the same side of the midpoint is 1/2.
When the cut points lie on opposite sides of the midpoint, there is still a chance that the longer sub-segment formed between those cuts is more than half the stick. By a symmetry argument, this scenario leads to an additional 1/4 probability of failing to form a triangle. Therefore, the overall probability that no triangle can be formed is 3/4, leaving 1/4 as the probability that a valid triangle can be formed.
Comprehensive Explanation
One way to see why the probability is 1/4 begins with understanding the triangle inequality, which states that for three segments with lengths a, b, and c to form a valid triangle, the following must all hold:
a + b > c
b + c > a
c + a > b
In a simplified sense, none of the three segments can exceed the combined length of the other two. In the stick-breaking scenario, the most straightforward culprit that prevents a triangle is if one piece is strictly greater than 1/2 of the total stick length, because then it will always be longer than the sum of the other two pieces (since those other two must sum to less than 1/2).
Let the total stick length be 1. Randomly selecting two cut points X and Y along the stick divides the stick into three pieces. The most important part of the geometric argument is checking when a piece exceeds length 1/2. We examine two main cases:
Case 1: Both cut points land on the same side of the midpoint (0.5). In this situation, the piece on the other side of the midpoint from both cuts is longer than 1/2. This situation happens with probability 1/2.
Case 2: The cut points land on different sides of the midpoint, but the longer sub-segment spanning from X to Y still ends up being larger than 1/2. By symmetry, we find this occurs with probability 1/2 of the remaining 1/2 (since first we must be in the scenario that X and Y lie in different halves), giving another 1/4 chance of producing a segment longer than 1/2.
Summing these failure probabilities:
1/2 (for both cuts on the same side)
1/4 (for the case that the cuts are on different sides but the middle piece is still too long)
We get a total of 3/4 probability that no valid triangle can form. Thus, the complement of that is 1/4.
Here is the most concise statement of the final result:
How to verify via simulation
A quick way to check this numerically is to write a Python script that generates two uniform random numbers between 0 and 1, interprets them as cut points, sorts them to find the lengths of the three segments, and counts how often the triangle inequality holds. If you run a large number of trials, the empirical probability should approach 1/4.
import random
def can_form_triangle(a, b, c):
# Check triangle inequalities
return (a + b > c) and (b + c > a) and (c + a > b)
def simulate(num_samples=10_000_000):
valid_count = 0
for _ in range(num_samples):
x = random.random()
y = random.random()
left_cut, right_cut = min(x, y), max(x, y)
# Lengths of segments
a = left_cut
b = right_cut - left_cut
c = 1 - right_cut
if can_form_triangle(a, b, c):
valid_count += 1
return valid_count / num_samples
prob_estimate = simulate()
print("Estimated probability:", prob_estimate)
Running this simulation with a sufficiently large number of samples should yield a result close to 0.25.
Potential Follow-up Question: Why does a piece exceeding 1/2 length automatically invalidate the triangle?
If any of the three pieces is longer than 1/2, the remaining two pieces must sum to something less than 1/2. For a triangle, if we label the longest side as c, and the other two as a and b, we need a + b > c. If c > 1/2, then a + b = 1 - c < 1/2, and so it can never exceed c. This violates the triangle inequality.
Potential Follow-up Question: Can we view this problem from a geometric area approach?
Yes, we can interpret the two random cut points X and Y as a random point in the unit square with coordinates (X, Y). The valid region for forming a triangle corresponds to all points (x, y) such that 0 < x, y < 1, and none of the lengths is greater than 1/2. One can show that the area of this region, after accounting for symmetry and the constraints, is 1/4 of the entire unit square.
Potential Follow-up Question: Does the length of the stick matter if it's not 1?
It does not, because scaling a stick by any positive constant factor does not change the probabilities involved. If the stick were length L instead of 1, the question of breaking at two random points would scale all segments by L, but the condition for forming a triangle depends on relative proportions rather than absolute lengths. The probability remains the same (1/4).
Potential Follow-up Question: What if the cut points are not chosen uniformly?
Then the probability will differ. The uniform choice assumption is crucial for the straightforward geometric approach. If the cuts follow another distribution, we would need to integrate over that new distribution and check the resulting lengths under the triangle inequality. The final probability would be shaped by the specifics of how we sample those cut points. In practical terms, the nice 1/4 result applies strictly under the uniform distribution assumption.
Potential Follow-up Question: How can we extend this to more than two cuts or to polygons?
If we extend the problem to n cuts, resulting in n+1 segments, the question becomes whether these n+1 segments can form an (n+1)-sided polygon. The constraints for polygon formation are a generalization of the triangle inequality: no one segment can be longer than the sum of the others. There is a known result for a large number of cuts that the probability of forming a polygon tends to 0 quite rapidly, but the exact probability requires more elaborate combinatorial and geometric arguments. Each additional cut complicates the probability distribution of segment lengths.
Potential Follow-up Question: Is there a simple formula for the probability when the number of cuts increases?
For forming a polygon with n+1 segments, there are known results involving order statistics. While for three segments (the triangle case) the probability is 1/4, for larger n the probability expression grows more intricate. Though there are formulas in the literature involving multiple integrals or recurrences, they are not as simple as 1/4. Generally, the probability decreases with increasing n.
Potential Follow-up Question: Are there practical applications of this?
Yes, in some optimization or random partition problems, one might be interested in the distributions of segment lengths or the feasibility of certain constraints (like those akin to triangle inequalities). However, this classic puzzle is mostly a probability brainteaser illustrating how random segments rarely satisfy the strict inequalities needed for geometric construction. In real-world engineering or design, random partition constraints might appear in reliability testing or random network topologies where path lengths must meet certain conditions.
All in all, under the uniform break model, the probability to form a triangle from three random segments remains firmly at 1/4.
Below are additional follow-up questions
What if the cuts are placed sequentially? Does the order in which you make the cuts affect the result?
When choosing two cut points independently and uniformly along the stick’s length, we usually treat the selection as simultaneous. However, we could imagine first making one cut, then—conditional on the position of that first cut—making the second cut in the remaining portion.
In the standard problem, “simultaneous” and “sequential” with memoryless uniform sampling both yield the same probability, because either way you end up with two independent uniform positions along the stick. But a subtlety might arise if you interpret “sequential” as picking the second cut uniformly along whatever remains after the first cut is removed, rather than still referencing the original entire stick from 0 to 1. In that altered scenario, you must carefully derive the distribution of the second cut:
You make the first cut, say at a point X which is uniform on [0, 1].
Now if you treat the second cut as uniform on the [0, 1] interval again, ignoring the position of X, that’s the usual problem.
If you instead treat the second cut as uniform on the sub-interval from 0 to X (if the second cut is “to the left” of X) or from X to 1 (if it’s “to the right” of X), you end up with a different distribution for the sizes of the three pieces.
In the typical interpretation, we do not alter the distribution of the second cut based on the first cut’s outcome. Hence, the order in which the cuts are made has no impact on the final distribution of segment lengths, keeping the probability at 1/4. But if someone sets up a sequential rule that depends on the outcome of the first cut (for example, always cutting the shorter remaining segment again), that changes the distribution of lengths, and you must re-derive the probability. Generally, such a rule-based sequential approach can yield probabilities different from 1/4.
How does rounding or discretization of the cut positions affect the probability in practice?
In realistic physical situations or in computer simulations where floating-point precision is limited, you cannot pick points continuously along the stick. If you have a discretized grid of possible cut locations (for instance, if you can only cut at increments of 0.001), then the probability becomes an approximation to the continuous result.
This might create small boundary effects. For example:
If your grid does not allow you to get extremely close to 0 or 1 for the cut points, you reduce the chance of creating segments that are too tiny or too large.
If your grid is very coarse, you might systematically exclude certain length combinations that otherwise would occur with small (but nonzero) probability in the continuous case.
Despite these discretization nuances, as your grid spacing becomes finer, the resulting probability should converge to 1/4. In real-world experiments (e.g., physically cutting sticks), you might see minor deviations, but they should be close to 1/4 if the cutting is truly “random.”
What about using other metrics for “breaking” the stick, such as random angles or random chords?
Sometimes, a puzzle is stated in terms of picking random chords of a circle or random angles that correspond to arcs. Although one might think these are analogues to cutting a stick, each setup involves different probability distributions. For instance, the famed “Bertrand’s paradox” in geometry deals with different ways of picking a random chord in a circle, and each method can give different probabilities of forming an equilateral triangle.
Hence, if you interpret “cutting a stick” as picking angles rather than linear positions, the underlying distribution changes. Depending on how precisely you map angles to chord or segment lengths, you could arrive at a different final probability. This highlights a subtle but important fact in probability theory: how you choose to define a “random” selection of lengths can drastically affect the outcome.
What if the stick’s endpoints are not fixed, but we have a random total length first?
In the standard problem, the stick length is fixed to 1. Suppose instead we choose the total length L of the stick from some positive distribution (for example, an exponential distribution with mean 1), and then we pick the two cut points conditioned on that random length. Even though L is random, once that length L is realized, the two cut points along [0, L] can be normalized to a [0, 1] interval for analysis. The probability of forming a triangle is scale-invariant—if you know L, the probability is the same as if L = 1. Thus, conditioning on a random L first and then cutting does not change the overall fraction that yield valid triangles: it remains 1/4, assuming the two points are placed uniformly along the length of the stick once L is realized.
A pitfall arises if the distribution of L is correlated with how you choose cut points. For instance, if a longer L somehow encourages cutting near the ends more frequently, then the independence and uniformity assumptions break, altering the result. So you must be cautious about whether you truly scale the cut points uniformly to the new length L or whether you have a correlation.
Is there a version involving repeated cuts where you discard one piece each time?
A variation might be: “Cut the stick once, discard the smallest piece, then cut the remaining piece again at a random point, and repeat.” You might keep going until you have three segments total. The final question is: “What is the probability that these three segments form a triangle?”
This scenario is quite different from making two uniform cuts at once. Each cut is now conditional on having kept or discarded certain pieces, so the distribution of segment lengths changes drastically. The problem becomes more intricate: after each cut, the “stick” you retain is not uniformly distributed in length relative to the original. You would need to model the process step-by-step, potentially using recursion or Markov chain arguments. The probability might be smaller or larger than 1/4, depending on the details of the discard rule. Carefully analyzing this sequential approach reveals how prior discarding biases the distribution of the next cut, so the final probability will not remain 1/4.
Could the arrangement of cuts affect the probability of forming an isosceles or equilateral triangle?
If we add a constraint such as: “What is the probability that the three segments happen to form an isosceles triangle?” or “What is the probability that the three segments form an equilateral triangle?” then the problem changes.
For an equilateral triangle, you need all three segments to be exactly one-third of the total length. That event has probability zero in continuous space, because hitting exactly 1/3 for each piece requires that both cut points align perfectly at 1/3 and 2/3—a single point in the 2D space of (X, Y). A single point in a continuous plane has measure zero, so it is essentially an event of probability zero.
For an isosceles triangle (including equilateral as a special case), there are a set of conditions where two segments are equal, or all three are equal. This set, while larger than a single point, still has measure zero if your cuts are truly continuous and uniform, so the probability is again zero.
In an actual physical or discretized scenario, you might see a small nonzero probability for isosceles or equilateral because real measurements and cuts are not perfectly continuous. But in the idealized math model, these events have probability zero.
Does choosing the two random points from a nonuniform distribution over [0,1] always yield a single number as the answer?
Not necessarily. If the distribution is nonuniform (for instance, if the density for the first cut is heavily biased toward the center, and the second cut is independent but also biased in some way), different distributions can shift the probability. There is no single universal probability for “nonuniform” cases because it depends exactly on how the distribution is shaped. If your distribution is extremely biased toward generating lengths near 0 and 1 for each cut, you might end up often creating very tiny segments that improve or worsen your chances of forming a triangle—depending on the interplay with the other piece lengths. In that sense, each custom distribution would need its own derivation or simulation.
Can the question be generalized to a piecewise linear rod with variable density or thickness?
In a more physical scenario, the “length” might not be the only factor—maybe the rod has varying density or thickness along its length. If we are randomly choosing cut points by length alone, it might still be uniform in the sense of linear distance, but if the question were about total mass or moment of inertia, the problem changes. For instance, “Break the rod at two points chosen so that the mass on each side of the cut is uniform,” or “Pick the first cut point so that it divides the rod by half its total mass,” leads to complicated distributions of linear lengths. The standard 1/4 probability relies solely on geometry with uniform positions along the length. Introducing mass or thickness transforms the underlying random variable from uniform linear distances to something else. In these scenarios, there is no longer a straightforward 1/4 result; you would have to compute the distributions of segment lengths anew.
Would using a random number of cuts (not fixed at two) to produce exactly three segments matter?
Suppose you make a random (Poisson-distributed or geometrically distributed) number of cuts along the stick, but you only keep exactly three of the resulting pieces (maybe you choose them in some random fashion among all the pieces). This puzzle is no longer a simple “two uniform cuts” scenario. The lengths of the three retained segments would depend on how many total cuts got made, where those cuts occurred, and which segments were chosen. Because each piece’s length is now conditioned on a more complex random structure, the probability of forming a triangle would differ from 1/4. Typically, analyzing such a problem requires enumerating or integrating over the random number of cuts, the positions of those cuts, and the selection of the three segments. These additional layers of randomness and choice almost certainly yield a different probability.
Could the problem shift if we allow degenerate triangles?
Sometimes, a question is posed about allowing degenerate triangles, which are straight lines where the sum of two side lengths equals the third. In standard geometry, a degenerate triangle is not considered a real triangle, but you could theoretically ask, “What is the probability that we form a triangle or a degenerate triangle?” That would shift the strict inequalities (a + b > c) to non-strict inequalities (a + b ≥ c).
In that slightly modified problem, the measure of the set where a + b = c is still zero in continuous space. The probability of exactly matching the condition a + b = c in a continuous random setting remains zero, so the probability would not increase from 1/4. In discrete or physical approximations, there could be some small fraction of outcomes that produce a near-degenerate shape. But for the ideal mathematical scenario, the degenerate boundary is still a set of measure zero, so the probability does not change.