Integer triangles

The question

A farmer has 27 meters of fence and wants a triangular pen whose three sides are each a whole number of meters.

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.
  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. That is 19 different triangles.

How it works.

  1. 01

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

  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

    That is 19 different triangles.