implementation of triangle