Ctrl K

Three Stakes Off the Line

Easy
A gardener has driven three stakes into the ground; stakes[i] = [x, y] gives the position of stake i on the plane. He wants to run a rope between them and fence off a triangular flower bed. That only works if the three stakes are at distinct points and do not all lie on one straight line. Return True if so, and False otherwise.
Example 1
stakes=[[0, 0], [4, 0], [1, 3]] → True

The stakes do not lie on one line, so they form a real triangle.

Example 2
stakes=[[2, 1], [4, 2], [8, 4]] → False

All three points lie on the line y = x / 2.

Example 3
stakes=[[5, 5], [5, 5], [9, 0]] → False

Two stakes are in the same spot, so there is no triangle.

Constraints
  • len(stakes) == 3
  • len(stakes[i]) == 2
  • 0 ≤ x, y ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsThe Biggest Triangle on the Board EasyShadows of Block Towers EasySurface of Cube Towers EasyHow a Rumor Spreads EasyPosts in One Line Easy
loading Python…
Input
stakes=[[0, 0], [4, 0], [1, 3]]
Expected
True

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