Ctrl K

The Biggest Triangle on the Board

Easy
Pins are stuck into a coordinate board; their positions are given in pins, where pins[i] = [x, y]. Stretch a thread around three different pins to form a triangle of the largest possible area, and return that area. If the three pins lie on one line, the triangle has area 0. Answers within 10⁻⁵ of the exact value are accepted.
Example 1
pins=[[0, 0], [4, 0], [1, 1], [0, 3]] → 6.0

The best triangle is (0, 0), (4, 0), (0, 3): a right triangle with legs 4 and 3, area 6.

Example 2
pins=[[-2, 1], [2, 1], [0, -1]] → 4.0

There are only three pins. The base from (-2, 1) to (2, 1) has length 4 and the height is 2, so the area is 4.

Example 3
pins=[[1, 1], [2, 2], [3, 3]] → 0
Constraints
  • 3 ≤ len(pins) ≤ 50
  • -50 ≤ x, y ≤ 50
  • All pins are at different points
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsShadows of Block Towers EasySurface of Cube Towers EasyHow a Rumor Spreads EasyThree Stakes Off the Line EasyPosts in One Line Easy
loading Python…
Input
pins=[[0, 0], [4, 0], [1, 1], [0, 3]]
Expected
6.0

Run checks the first 3 tests in your browser. Submit checks all 111 tests on the server, hidden ones included.