So I took a challenge from my Geometry teacher to create code that when the user gives the computer how many angles / sides a polygon has and the angle of each of the interior angles it could find each of the exterior angles whether it is regular or irregular. For example the user tells the computer they have a four-sided shape (quadrilateral), the interior angles are $70, 75, 110, 145$. The computer would then be able to output each corresponding angle in the proper order. My problem is that with coding you can't just type in the human logic so I need a formula to work from: what on earth would be a formula that could apply to any polygon with any number of sides (irregular or regular)?
The other answer is not complete, because you can have a non convex polygon (i.e one interior angle can be 240) and to say that $180-$
input_angle is not all correct.
Thr proper way to to this is:
- read angles and save them as a list
- initialize and empty array with size equal to
- loop over elements in
elementis greater than 180, then append to
element, else append $180-$
Also you can add validations to check if the input angles indeed correspond to a polygon (i.e, the sum of angles must be a multiple of 180)