exercism/go/triangle/triangle.go

31 lines
496 B
Go
Raw Normal View History

2016-08-13 23:20:14 +00:00
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
)