Integer triangles, step by step

Three whole-number sides that add up to twenty — how many different triangles can you make?

The question

How many differently shaped triangular pens can be built? (Turning or flipping a pen over does not make it a new one.)

Order the sides, then keep only the ones that close up

perimeter:27
keep only:a + b > c
kept:19
triangles:19
  1. We want triangles with whole-number sides adding to 27, counting a triangle and its mirror as one. Nothing is counted yet.
  2. Put the sides in order, a ≤ b ≤ c. Three lengths only close into a triangle when a + b > c — the two shorter sides must out-reach the longest. A lopsided split like (1, 1, 25) fails that and is not a triangle at all.
  3. Walk the shortest side up from 1, and for each one take the middle side as far as it can go with b ≤ c. Keeping just the splits that pass the rule: (1, 13, 13), (2, 12, 13), (3, 11, 13), (3, 12, 12), (4, 10, 13), …, (9, 9, 9).
  4. Counting them, that is 19 different triangles — and the lopsided splits the rule threw out are exactly the ones a hurried count would have kept.

How it works.

  1. 01

    We want triangles with whole-number sides adding to 27, counting a triangle and its mirror as one. Nothing is counted yet.

  2. 02

    Put the sides in order, a ≤ b ≤ c. Three lengths only close into a triangle when a + b > c — the two shorter sides must out-reach the longest. A lopsided split like (1, 1, 25) fails that and is not a triangle at all.

  3. 03

    Walk the shortest side up from 1, and for each one take the middle side as far as it can go with b ≤ c. Keeping just the splits that pass the rule: (1, 13, 13), (2, 12, 13), (3, 11, 13), (3, 12, 12), (4, 10, 13), …, (9, 9, 9).

  4. 04

    Counting them, that is 19 different triangles — and the lopsided splits the rule threw out are exactly the ones a hurried count would have kept.