Leetcode Note: Go - Valid Boomerang
Valid Boomerang - LeetCode
https://leetcode.com/problems/valid-boomerang/
- Go 言語で取り組んだメモ
回答
golang math - LeetCode Discuss
https://leetcode.com/problems/valid-boomerang/discuss/574034/golang-math
func isBoomerang(points [][]int) bool {
if len(points) != 3 {
return false
}
if !(Distinct(points[0], points[1]) && Distinct(points[1], points[2])) {
return false
}
if (points[1][1]-points[0][1])*(points[2][0]-points[1][0]) == (points[1][0]-points[0][0])*(points[2][1]-points[1][1]) {
return false
}
return true
}
func Distinct(p1, p2 []int) bool {
if p1[0] == p2[0] && p1[1] == p2[1] {
return false
}
return true
}