Question: Write a function total_equal_sides (ax, ay, bx, by, cx, cy, dx, dy): that consumes eight integers: ax and ay (the first vertex), bx and

Write a function total_equal_sides (ax, ay, bx, by, cx, cy, dx, dy): that consumes eight integers: ax and ay (the first vertex), bx and 

Write a function total_equal_sides (ax, ay, bx, by, cx, cy, dx, dy): that consumes eight integers: ax and ay (the first vertex), bx and by (the second vertex), cx and cy (the third vertex), and dx and dy (the fourth vertex); all corresponding to points on the Cartesian plane. The function total_equal_sides returns the number of sides of the quadrilateral formed by the previous vertices that have the same length. Please note that the coordinates will be listed so the first four coordinates correspond to a side of the quadrilateral, the four middle coordinates to a second side, the four end coordinates a third side, and the two coordinates at the beginning and end make up a fourth side, all of a non-degenerate quadrilateral (i.e., the input we will test your function on will correspond to genuine quadrilaterals). Example 1 total equal sides (30, 30, 10, -10, -30, 20, 20, 30) => 2 50 14.14 44.72 Activate Windows Go to Settings to activate Wi Example 2 total_equal sides (60, 10, 10, 10, 40, -15, 60, -15) => 0 Example 3 25 39.05 20 50 25 25 50 total_equal_sides (60, 10, 10, 10, 10, -15, 60, -15) => 2 Tips: Calculating the length of the side of a polygon from its vertices requires the and cannot reliably compare them for strict equality. However, since y = dab = (a - b) + (ay-by). use of a square root. Square roots produce real numbers. As you have seen, computers approximate real numbers as floating-point values, implies that , you may compare squared side lengths instead of side lengths and work with integers only: Activate Windows Go to Settings to activate Window

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!