# Cut the stick simulation

The problem:

You have a stick that is one meter long, and you cut it at two arbitrarily chosen points. What is the probability that you will be able to form a triangle with the three pieces?

The first thing to resolve is: "What does it mean that the three pieces form a triangle?" As many remarked in the discussion board, in order to have a triangle, it must be the case that no piece is longer than the sum of the lengths of the other two pieces. In particular, for us it means that all three pieces must be less than half a meter in length.

This program is a simulation of doing the experiment of cutting many one-meter sticks at random and determining whether a triangle can be made with the pieces. The computer chooses random numbers between 0 and 1 to be the places to cut. If the experiment is repeated a large number of times, the proportion of "successful" triangles to the total number of experiments should approximate well the actual probability of being able to make a triangle with the pieces.