Given four arrays of 3 numbers each which represents sides and angles of two triangles. The task is to check if the two triangles are Congruent or not. Also print the theorem by which they are congruent.

**Note:** All sides and angles given as input are for valid triangles.

**Examples:**

Input :side1 = [3, 4, 5] angle1 = [90, 60, 30] side2 = [4, 3, 5] angle2 = [60, 30, 90]Output:Triangles are congruent by SSS SAS ASA AAS HL.Input :side1 = [3, 5, 6] angle1 = [80, 50, 50] side2 = [1, 1, 1] angle2 = [60, 60, 60]Output:Triangles are not congruent

Congruent triangles are two or more triangles that have all corresponding sides that are equal or a pair of sides and between angle are equal or a pair of angle and side between are equal or a pair of angle and other side are equal or hypotenuse and one side are equal.

The congruency of triangles can be proved by the following theorems:

**Side-Side-Side (SSS) Congruency criteria:**If all the sides of a triangle are equal to the sides of another triangle then the triangles are said to be congruent by the property of*Side-Side-Side*(SSS).

In above triangle ABC and A’B’C’ if, AB=A’B’ and BC=B’C’ and CA=C’A’ then, triangles are congruent.**Side-Angle-Side (SAS) Congruent criteria:**If two sides of the two triangles are equal and the angle between them is same in both triangle then the triangles are said to be congruent by the property of*Side-Angle-Side*(SAS). In above triangle ABC and A’B’C’ if, AB=A’B’ and BC=B’C’ and = triangles are congruent.**Angle-Side-Angle (ASA) Congruent criteria :**If two angles of the two triangles are equal and the length of side between them is same in both triangle then the triangles are said to be congruent by the property of*Angle-Side-Angle*(ASA).In above triangle ABC and A’B’C’ if, =

and = and BC=B’C’ then, triangles are congruent.**Angle-Angle-Side (AAS) Congruent criteria :**If two angles of the two triangles are equal and the length of other side is same in both triangle then the triangles are said to be congruent by the property of*Angle-Angle-Side*(AAS). In above triangle ABC and A’B’C’ if, = and = and CA=C’A’ then, triangles are congruent.**Hypotenuse-Leg (HL) Congruent criteria :**

If the hypotenuse of the two triangles are equal and the length of any other one side is same in both triangle then the triangles are said to be congruent by the property of*Hypotenuse-Leg*(HL).

Below is the implementation of the above theorems.

`# Python program to check ` `# similarity between two triangles. ` ` ` `# Function for SAS congruency ` `def` `cong_sas(s1, s2, a1, a2): ` ` ` ` ` `s1 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s1] ` ` ` `s2 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s2] ` ` ` `a1 ` `=` `[` `float` `(i) ` `for` `i ` `in` `a1] ` ` ` `a2 ` `=` `[` `float` `(i) ` `for` `i ` `in` `a2] ` ` ` ` ` `s1.sort() ` ` ` `s2.sort() ` ` ` `a1.sort() ` ` ` `a2.sort() ` ` ` ` ` `# Check for SAS ` ` ` ` ` `# angle b / w two smallest sides is largest. ` ` ` `if` `s1[` `0` `] ` `=` `=` `s2[` `0` `] ` `and` `s1[` `1` `] ` `=` `=` `s2[` `1` `]: ` ` ` ` ` `# since we take angle b / w the sides. ` ` ` `if` `a1[` `2` `] ` `=` `=` `a2[` `2` `]: ` ` ` `return` `1` ` ` ` ` `if` `s1[` `1` `] ` `=` `=` `s2[` `1` `] ` `and` `s1[` `2` `] ` `=` `=` `s2[` `2` `]: ` ` ` `if` `a1[` `0` `] ` `=` `=` `a2[` `0` `]: ` ` ` `return` `1` ` ` ` ` `if` `s1[` `2` `] ` `=` `=` `s2[` `2` `] ` `and` `s1[` `0` `] ` `=` `=` `s2[` `0` `]: ` ` ` `if` `a1[` `1` `] ` `=` `=` `a2[` `1` `]: ` ` ` `return` `1` ` ` ` ` `return` `0` ` ` `# Function for ASA congruency ` `def` `cong_asa(s1, s2, a1, a2): ` ` ` ` ` `s1 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s1] ` ` ` `s2 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s2] ` ` ` `a1 ` `=` `[` `float` `(i) ` `for` `i ` `in` `a1] ` ` ` `a2 ` `=` `[` `float` `(i) ` `for` `i ` `in` `a2] ` ` ` ` ` `s1.sort() ` ` ` `s2.sort() ` ` ` `a1.sort() ` ` ` `a2.sort() ` ` ` ` ` `# Check for ASA ` ` ` ` ` `# side b / w two smallest angle is largest. ` ` ` `if` `a1[` `0` `] ` `=` `=` `a2[` `0` `] ` `and` `a1[` `1` `] ` `=` `=` `a2[` `1` `]: ` ` ` ` ` `# since we take side b / w the angle. ` ` ` `if` `s1[` `2` `] ` `=` `=` `s2[` `2` `]: ` ` ` `return` `1` ` ` ` ` `if` `a1[` `1` `] ` `=` `=` `a2[` `1` `] ` `and` `a1[` `2` `] ` `=` `=` `a2[` `2` `]: ` ` ` `if` `s1[` `0` `] ` `=` `=` `s2[` `0` `]: ` ` ` `return` `1` ` ` ` ` `if` `a1[` `2` `] ` `=` `=` `a2[` `2` `] ` `and` `a1[` `0` `] ` `=` `=` `a2[` `0` `]: ` ` ` `if` `s1[` `1` `] ` `=` `=` `s2[` `1` `]: ` ` ` `return` `1` ` ` ` ` `return` `0` ` ` `# Function for AAS congruency ` `def` `cong_aas(s1, s2, a1, a2): ` ` ` ` ` `s1 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s1] ` ` ` `s2 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s2] ` ` ` `a1 ` `=` `[` `float` `(i) ` `for` `i ` `in` `a1] ` ` ` `a2 ` `=` `[` `float` `(i) ` `for` `i ` `in` `a2] ` ` ` ` ` `s1.sort() ` ` ` `s2.sort() ` ` ` `a1.sort() ` ` ` `a2.sort() ` ` ` ` ` `# Check for AAS ` ` ` ` ` `# side other two smallest angle is smallest or 2nd smallest. ` ` ` `if` `a1[` `0` `] ` `=` `=` `a2[` `0` `] ` `and` `a1[` `1` `] ` `=` `=` `a2[` `1` `]: ` ` ` ` ` `# since we take side other than angles. ` ` ` `if` `s1[` `0` `] ` `=` `=` `s2[` `0` `] ` `or` `s1[` `1` `] ` `=` `=` `s2[` `1` `]: ` ` ` `return` `1` ` ` ` ` `if` `a1[` `1` `] ` `=` `=` `a2[` `1` `] ` `and` `a1[` `2` `] ` `=` `=` `a2[` `2` `]: ` ` ` `if` `s1[` `1` `] ` `=` `=` `s2[` `1` `] ` `or` `s1[` `2` `] ` `=` `=` `s2[` `2` `]: ` ` ` `return` `1` ` ` ` ` `if` `a1[` `2` `] ` `=` `=` `a2[` `2` `] ` `and` `a1[` `0` `] ` `=` `=` `a2[` `0` `]: ` ` ` `if` `s1[` `0` `] ` `=` `=` `s2[` `0` `] ` `or` `s1[` `2` `] ` `=` `=` `s2[` `2` `]: ` ` ` `return` `1` ` ` ` ` `return` `0` ` ` `# Function for HL congruency ` `def` `cong_hl(s1, s2): ` ` ` ` ` `s1 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s1] ` ` ` `s2 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s2] ` ` ` `s1.sort() ` ` ` `s2.sort() ` ` ` ` ` `# Check for HL ` ` ` `if` `s1[` `2` `] ` `=` `=` `s2[` `2` `]: ` ` ` `if` `s1[` `1` `] ` `=` `=` `s2[` `1` `] ` `or` `s1[` `0` `] ` `=` `=` `s2[` `0` `]: ` ` ` `return` `1` ` ` ` ` `return` `0` ` ` `# Function for SSS congruency ` `def` `cong_sss(s1, s2): ` ` ` ` ` `s1 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s1] ` ` ` `s2 ` `=` `[` `float` `(i) ` `for` `i ` `in` `s2] ` ` ` `s1.sort() ` ` ` `s2.sort() ` ` ` ` ` `# Check for SSS ` ` ` `if` `(s1[` `0` `] ` `=` `=` `s2[` `0` `] ` `and` `s1[` `1` `] ` `=` `=` `s2[` `1` `] ` `and` `s1[` `2` `] ` `=` `=` `s2[` `2` `]): ` ` ` `return` `1` ` ` ` ` `return` `0` ` ` ` ` `# Driver Code ` `s1 ` `=` `[` `3` `, ` `4` `, ` `5` `] ` `s2 ` `=` `[` `4` `, ` `3` `, ` `5` `] ` ` ` `a1 ` `=` `[` `90` `, ` `60` `, ` `30` `] ` `a2 ` `=` `[` `60` `, ` `30` `, ` `90` `] ` ` ` `# function call for SSS congruency ` `sss ` `=` `cong_sss(s1, s2) ` ` ` `# function call for SAS congruency ` `sas ` `=` `cong_sas(s1, s2, a1, a2) ` ` ` `# function call for ASA congruency ` `asa ` `=` `cong_asa(s1, s2, a1, a2) ` ` ` `# function call for AAS congruency ` `aas ` `=` `cong_aas(s1, s2, a1, a2) ` ` ` `# function call for HL congruency ` `hl ` `=` `cong_hl(s1, s2, ) ` ` ` `# Check if triangles are congruent or not ` `if` `sss ` `or` `sas ` `or` `asa ` `or` `aas ` `or` `hl : ` ` ` `print` `"Triangles are congruent by"` `, ` ` ` `if` `sss: ` `print` `"SSS"` `, ` ` ` `if` `sas: ` `print` `"SAS"` `, ` ` ` `if` `asa: ` `print` `"ASA"` `, ` ` ` `if` `aas: ` `print` `"AAS"` `, ` ` ` `if` `hl: ` `print` `"HL"` `, ` `else` `: ` `print` `"Triangles are not congruent"` |

*chevron_right*

*filter_none*

**Output:**

Triangles are congruent by SSS SAS ASA AAS HL

Attention reader! Don’t stop learning now. Get hold of all the important DSA concepts with the **DSA Self Paced Course** at a student-friendly price and become industry ready.

## Recommended Posts:

- Program to check similarity of given two triangles
- Program to print the pattern with two hollow Triangles
- Number of triangles in a plane if no more than two points are collinear
- Number of triangles formed by joining vertices of n-sided polygon with two common sides and no common sides
- Count right angled triangles in a matrix having two of its sides parallel to sides of the matrix
- Program to find all possible triangles having same Area and Perimeter
- Count the number of possible triangles
- Number of Triangles in an Undirected Graph
- Number of Triangles in Directed and Undirected Graphs
- Counting Triangles in a Rectangular space using BIT
- Finding the number of triangles amongst horizontal and vertical line segments
- Number of possible Triangles in a Cartesian coordinate system
- Equilateral Triangles using Matchsticks
- Number of triangles after N moves
- Forming triangles using points on a square
- Count of triangles with total n points with m collinear
- Find all possible triangles with XOR of sides zero
- Area of the circumcircle of any triangles with sides given
- Count number of right triangles possible with a given perimeter
- Number of Isosceles triangles in a binary tree

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.