7 kyu

Acute, Obtuse, or Right?

Description:

In this Kata, you will be given an array of side lengths for a triangle.Your job is to figure out whether the triangle should be classified as Right, Acute, or Obtuse. To learn more about Right, Acute, or Obtuse triangles see here - Acute and Obtuse Triangles

Recall that a in a right triangle, one of the three angles has a value of 90°, in an obtuse angle one of the three angles has a value greater than 90°, and in an acute triangle all three of the angles have measures less than 90°.

The array given will always contain 3 positive integers, and the order of the integers may be random. The side lengths may not produce a valid triangle.

Recall that the sum of the 2 shortest sides of the triangle must be greater than the largest side (hypotenuse) in order for a triangle to be considered valid.

Your function will contain a single array as an argument, such as -

function obtRhtAct([SIDE_LEN_1,SIDE_LEN_2,SIDE_LEN_3]) {
    //your code here
    return -1
}

Your function should return the following values -

if (triangle is obtuse) => 0
if (triangle is right) => 1
if (triangle is acute) => 2
if (triangle is invalid) => -1
Algorithms
Geometry
Mathematics

Stats:

CreatedDec 11, 2017
PublishedDec 11, 2017
Warriors Trained290
Total Skips2
Total Code Submissions577
Total Times Completed160
JavaScript Completions160
Total Stars3
% of votes with a positive feedback rating83% of 59
Total "Very Satisfied" Votes41
Total "Somewhat Satisfied" Votes16
Total "Not Satisfied" Votes2
Total Rank Assessments3
Average Assessed Rank
7 kyu
Highest Assessed Rank
7 kyu
Lowest Assessed Rank
8 kyu
Ad
Contributors
  • bgibbz Avatar
  • kazk Avatar
  • JohanWiltink Avatar
Ad