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 top²/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.
Similar Kata:
Stats:
Created | Mar 26, 2016 |
Published | Mar 26, 2016 |
Warriors Trained | 138 |
Total Skips | 10 |
Total Code Submissions | 225 |
Total Times Completed | 7 |
Python Completions | 7 |
Total Stars | 5 |
% of votes with a positive feedback rating | 50% of 1 |
Total "Very Satisfied" Votes | 0 |
Total "Somewhat Satisfied" Votes | 1 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 1 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 6 kyu |
Lowest Assessed Rank | 6 kyu |