Prime Cut
To win a game of Super Mario Party Jamboree™, Mario and Luigi must separate a steak into 2 pieces of equal area using one straight cut. But alas, the dastardly Bowser has interfered with the game! The wicked turtle has mangled the steak so that it is triangular. In addition, this mangled steak can only be cut in vertical lines perpendicular to the y-axis. Can you find where the plumber brothers must make their cut to bisect the steak?
Specifically, you are given the coordinates of the steak in cartesian form. You must find the value of xi such that the line x=xi bisects the triangle into 2 pieces of equal area.
Input
3 lines of input are given, each representing one point of the triangle.
Each contains 2 integers, xi and yi, representing the coordinates of one point of the triangle.
Output
Output one number, xi, representing the x-value such that the line x=xi bisect the triangle.
Answers within 10−3 of the correct answer will be accepted.
Constraints
- −108≤xi,yi≤108
- Points are distinct.
- The points are guaranteed to be non-collinear (triangle has positive area).
Examples
0 0
1 1
0 1
0.2928924560546875
Cutting the triangle at x=0.293 will divide the triangle in sides of area 0.25.

-3 4
2 1
7 2
2.0
Cutting the triangle at x=2 will divide the triangle into equal halves.

Comments0
No comments yet
Be the first to comment.
New comment
Log in to join the discussion.