Beta

Integer Triangles I: Maximum Number of Integer Triangles with the Smallest Perimeter

Description:

An integer triangle is one which its side values a, b, c are integers.

As all the triangles, the values sides fulfills the condition a > b + c, if a is the greater side

The perimeter p of the triangle is such that p = a + b + c.

When p = 7, we have the lowest perimeter in having more than 1 integer triangle and are [3, 2, 2], [3, 3, 1] and the amount of them is 2.

Doing some math we may demonstrate that the amount of integer triangles n will be equal to:

  • if p is even, the closest integer to p²/48

  • if p is odd, the closest integer to (p+3)²/48

We need a function, that may give the smallest perimeter that has more integer triangles than a given amount.

Fot our example

int_triang(1) == [[[3, 2, 2], [3, 3, 1]], 2, 7]

For the amount 2 and 3 will be:

int_triang(2) == [[[3, 3, 3], [4, 3, 2], [4, 4, 1]], 3, 9]

int_triang(3) == [[[4, 4, 3], [5, 3, 3], [5, 4, 2], [5, 5, 1]], 4, 11]

Note that each triangle [a, b, c] is such that a ≤ b ≤ c and the triangles should be sorted.

Fundamentals
Number Theory
Data Structures
Mathematics
Geometry
Logic

Stats:

CreatedMar 26, 2016
PublishedMar 26, 2016
Warriors Trained138
Total Skips10
Total Code Submissions225
Total Times Completed7
Python Completions7
Total Stars5
% of votes with a positive feedback rating50% of 1
Total "Very Satisfied" Votes0
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes0
Total Rank Assessments1
Average Assessed Rank
6 kyu
Highest Assessed Rank
6 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • raulbc777 Avatar
  • kazk Avatar
Ad