코딩테스트/HackerRank

[Advanced Select] Type of Triangle

봉두두 2022. 6. 26. 23:07
728x90
Skill : Advanced Select

 

간과한 것.

case when 순서가 중요한데, not a triangle이 Scalene보다 먼저여야 함.

a+b <= c 만 생각한것..? 세 변 모두 했어야지!😇

 

아무튼.. 문제 난이도는 쉽다.

 

select case when a=b and b=c then 'Equilateral'
when a+b<=c or a+c<=b or b+c<=a then 'Not A Triangle'
when a=b or b=c or a=c then 'Isosceles'
else 'Scalene' end
from TRIANGLES;
728x90
728x90