반응형

@notepad_jj2

츄르사려고 코딩하는집사입니다.


1. [HackerRank] Type of Triangle 오라클(Oracle)

 

2. 문제 출처

https://www.hackerrank.com/challenges/what-type-of-triangle/problem

 

Type of Triangle | HackerRank

Query a triangle's type based on its side lengths.

www.hackerrank.com

 

3. 문제

Write a query identifying the type of each record in the TRIANGLES table using its three side lengths. Output one of the following statements for each record in the table:

  • Equilateral: It's a triangle with  sides of equal length.
  • Isosceles: It's a triangle with  sides of equal length.
  • Scalene: It's a triangle with  sides of differing lengths.
  • Not A Triangle: The given values of A, B, and C don't form a triangle.Input FormatExplanation
  • Values in the tuple  form an Isosceles triangle, because .
    Values in the tuple  form an Equilateral triangle, because . Values in the tuple  form a Scalene triangle, because .
    Values in the tuple  cannot form a triangle because the combined value of sides  and  is not larger than that of side .
  • Sample Output
  • Isosceles Equilateral Scalene Not A Triangle
  • The TRIANGLES table is described as follows:Each row in the table denotes the lengths of each of a triangle's three sides.
  • Sample Input

 

4. 풀이

 

5. 소스 코드

 

SELECT
    CASE WHEN A+B <= C OR A+C <= C OR B+C <= A THEN 'Not A Triangle'
    ELSE CASE WHEN A=B and B=C and A=C then 'Equilateral'
    ELSE CASE WHEN A=B or B=C or A=C then 'Isosceles'
    ELSE 'Scalene'
    END END END
FROM Triangles;

 


반응형
  • 네이버 블러그 공유하기
  • 네이버 밴드에 공유하기
  • 페이스북 공유하기
  • 카카오스토리 공유하기