Possible Triangles
Start Timer
0:00:00
We’re given a list of at least three numbers named sides
. Each entry in sides
represents the length of a side of a triangle.
Write a function possible_triangles
to determine the number of possible triangles that can be formed using the given side lengths.
In the case that more than three side lengths are given, there may be several possible triangles.
Note: If there are multiple equal side lengths in the list, we consider them as distinct sides.
Examples:
Input:
#Example 1:
sides = [3, 3, 3]
def possible_triangles(sides) -> 1
#Example 2:
sides = [3, 3, 3, 3]
def possible_triangles(sides) -> 4
#Example 3:
sides = [1, 2, 3.5]
def possible_triangles(sides) -> 0
Recommended questions for you
Personalized based on your user activity, skill level, and preferences.
.
.
.
.
.
.
.
.
.
Comments