Dcoder icon

Equable Triangles @ Dcoder

By Lochard | As a newbie programmer | 23 May 2023


Title: Equable Triangles

Problem: An Equable Triangle is a triangle which has its area equals to the sum of its sides. 

You are given with the sides of a triangle, your task is to write a code which will return 'True'. if the triangle is equable, otherwise 'False' without quotes.

Input: First line of input will contain 'n' that is the number of test cases.

Next n lines of the input will contain the length of the sides of triangle separated by a space each.

Output: The output will return 'True' if the triangle is equable, and 'False' otherwise.

Constraints: Number of test cases = n and 0 < n < 100.

And the length of each side of triangle is 's', 0 < s < 10000.  

Sample Input: 1

6 8 10

Sample Output: 

True

from math import sqrt
for i in range(int(input())):
  m, n, o = map(int, input().split())
  s = (m + n + o) / 2
  print('True' if s * 2 == sqrt(s * (s-m) * (s-n) * (s-o)) else 'False')

How do you rate this article?

1


Lochard
Lochard

20240228 Arrived in the UK for about 2 week. All my fears persist. Some are even getting worse. https://github.com/locharp/asylum_diary/


As a newbie programmer
As a newbie programmer

Sharing entry level codes. My snippets on GitHub https://github.com/locharp/code-snippets

Publish0x

Send a $0.01 microtip in crypto to the author, and earn yourself as you read!

20% to author / 80% to me.
We pay the tips from our rewards pool.