31 lines
496 B
Go
31 lines
496 B
Go
|
package triangle
|
||
|
|
||
|
// KindFromSides returns what type of triangle has the sides
|
||
|
// of length a, b, and c
|
||
|
func KindFromSides(a, b, c float64) Kind {
|
||
|
if a+b > c && b+c > a && a+c > b {
|
||
|
if a == b && b == c {
|
||
|
return Equ
|
||
|
}
|
||
|
if a == b || b == c || a == c {
|
||
|
return Iso
|
||
|
}
|
||
|
return Sca
|
||
|
}
|
||
|
return NaT
|
||
|
}
|
||
|
|
||
|
// Kind describes the different types of triangles
|
||
|
type Kind int
|
||
|
|
||
|
const (
|
||
|
// Equ - equilateral
|
||
|
Equ = iota
|
||
|
// Iso - isosceles
|
||
|
Iso
|
||
|
// Sca - scalene
|
||
|
Sca
|
||
|
// NaT - not a triangle
|
||
|
NaT
|
||
|
)
|