Skip to content
Advertisement

Display the type of triangle

This is the problem:

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

I’ve tried this solution:

The above solution does not work.

Whereas the solution given below works

I feel both solutions are the same except swapping the side of the operands while I also appropriately changed the operator so as to not change the meaning. Can someone please explain why solution 1 doesn’t work?

Advertisement

Answer

  • Simple Case for each situation
  • The order here is important for accurate results
  • Important: <= condition is not clearly shown in Hacker rank question for ‘Not a Triangle’, This may be your issue
User contributions licensed under: CC BY-SA
10 People found this is helpful
Advertisement