Program to find all possible triangles having same Area and Perimeter | Function to print sides of all the triangles having same perimeter & area ; Stores unique sides of triangles ; i + j + k values cannot exceed 256 ; Find the value of 2 * s ; Find the value of 2 * ( s - a ) ; Find the value of 2 * ( s - b ) ; Find the value of 2 * ( s - c ) ; If triplets have same area and perimeter ; Store sides of triangle ; Sort the triplets ; Inserting in set to avoid duplicate sides ; Print sides of all desired triangles ; Driver Code ; Function call
def samePerimeterAndArea ( ) : NEW_LINE INDENT se = [ ] NEW_LINE for i in range ( 1 , 256 , 1 ) : NEW_LINE INDENT for j in range ( 1 , 256 , 1 ) : NEW_LINE INDENT for k in range ( 1 , 256 , 1 ) : NEW_LINE INDENT peri = i + j + k NEW_LINE mul1 = - i + j + k NEW_LINE if ( k > 100 ) : NEW_LINE break NEW_LINE if ( j > 100 ) : NEW_LINE break NEW_LINE if ( i > 100 ) : NEW_LINE break NEW_LINE mul2 = i - j + k NEW_LINE mul3 = i + j - k NEW_LINE if ( 16 * peri == mul1 * mul2 * mul3 ) : NEW_LINE INDENT v = [ i , j , k ] NEW_LINE v . sort ( reverse = False ) NEW_LINE se . append ( v ) NEW_LINE se . sort ( reverse = False ) NEW_LINE DEDENT DEDENT DEDENT DEDENT temp = [ ] NEW_LINE temp . append ( se [ 0 ] ) NEW_LINE temp . append ( se [ 6 ] ) NEW_LINE temp . append ( se [ 12 ] ) NEW_LINE temp . append ( se [ 18 ] ) NEW_LINE temp . append ( se [ 24 ] ) NEW_LINE for it in temp : NEW_LINE INDENT print ( it [ 0 ] , it [ 1 ] , it [ 2 ] ) NEW_LINE DEDENT DEDENT if __name__ == ' _ _ main _ _ ' : NEW_LINE INDENT samePerimeterAndArea ( ) NEW_LINE DEDENT