/*
* @lc app=leetcode.cn id=1037 lang=typescript
*
* [1037] 有效的回旋镖
*/
// @lc code=start
function isBoomerang(points: number[][]): boolean {}
// @lc code=end
function isBoomerang(points: number[][]): boolean {
const [x1, y1] = [0, 1].map(i => points[0][i] - points[1][i]),
[x2, y2] = [0, 1].map(i => points[1][i] - points[2][i])
return x1 * y2 !== y1 * x2
}
test.each([
{
input: {
points: [
[1, 1],
[2, 3],
[3, 2],
],
},
output: true,
},
{
input: {
points: [
[1, 1],
[2, 2],
[3, 3],
],
},
output: false,
},
])('input: points = $input.points', ({ input: { points }, output }) => {
expect(isBoomerang(points)).toEqual(output)
})