updated with invalid triangle checking

using formula:
(a+b)>c
(b+c)>a
(a+c)>b