Roll three dice and imagine that the three top numbers represent ‘lengths’. Can the three lengths form a triangle? Most people, without thinking, say “yes.’ But the answer is that not all whole numbers, taken as triplets, form triangles. For example, the whole numbers 2, 3, and 6 do not form a triangle but 3, 5, and 6 do form a triangle. This is easily seen by studying the following diagram.
This becomes an interesting programming problem. There are 216 (6 x 6 x 6) possible number triplets formed by rolling ordinary, six-sided dice. Those combinations can be checked by hand (a laborious but doable activity) but what if the dice are icosahedrons like those used in Dungeons and Dragons. That’s 8 thousand combinations!
My Scratch project Triangle Triplets quickly computes which number triplets do form triangles for 4, 6, 8, 12, and 20-sided dice. The program also counts equilateral, scalene, and isosceles triangles for each set of three dice. Using this data one can compute the probability of the number triplets forming a triangle, an equilateral triangle, a scalene triangle, or an isosceles triangle.
The problem has quite a history and a copy of the mathematics underlying the problem and an annotated Scratch algorithm can be had on request by sending an email to