Implementation of isTriangle