Count of Equilateral Triangles of unit length possible from a given Hexagon | Function to calculate the the number of Triangles possible ; Regular Hexagon ; Irregular Hexagon
function calculateTriangles ( sides ) { let count = Math . pow ( sides [ 0 ] + sides [ 1 ] + sides [ 2 ] , 2 ) ; count -= Math . pow ( sides [ 0 ] , 2 ) ; count -= Math . pow ( sides [ 2 ] , 2 ) ; count -= Math . pow ( sides [ 4 ] , 2 ) ; return ( count ) ; } let sides = [ 1 , 1 , 1 , 1 , 1 , 1 ] ; document . write ( ( calculateTriangles ( sides ) ) + " " ) ; let sides1 = [ 2 , 2 , 1 , 3 , 1 , 2 ] ; document . write ( ( calculateTriangles ( sides1 ) ) + " " ) ;