Fix: Ensure all skills are tracked as files, not submodules
This commit is contained in:
@@ -0,0 +1,17 @@
|
||||
def triangle_area(a, b, c):
|
||||
'''
|
||||
Given the lengths of the three sides of a triangle. Return the area of
|
||||
the triangle rounded to 2 decimal points if the three sides form a valid triangle.
|
||||
Otherwise return -1
|
||||
Three sides make a valid triangle when the sum of any two sides is greater
|
||||
than the third side.
|
||||
Example:
|
||||
triangle_area(3, 4, 5) == 6.00
|
||||
triangle_area(1, 2, 10) == -1
|
||||
'''
|
||||
if a + b <= c or a + c <= b or b + c <= a:
|
||||
return -1
|
||||
|
||||
s = (a + b + c) / 2
|
||||
area = (s * (s - a) * (s - b) * (s - c)) ** 0.5
|
||||
return round(area, 2)
|
||||
Reference in New Issue
Block a user