### optimizations

master Blaine Motsinger 1 year ago
parent
commit
f8b7acbeba
1 changed files with 7 additions and 9 deletions
1. 7
9
go/triangle/triangle.go

#### + 7 - 9 go/triangle/triangle.goView File

 @@ -1,9 +1,7 @@ // Package triangle - exercise for exercism.io go track package triangle import ( "math" ) import "math" type Kind string @@ -23,8 +21,8 @@ func KindFromSides(a, b, c float64) Kind { // all sides have to be of length > 0 if a > 0 && b > 0 && c > 0 { // test to ensure each side is not Inf, since that can pass as equal below. if math.IsInf(a, 0) == false && math.IsInf(b, 0) == false && math.IsInf(c, 0) == false { // test to ensure we're not working with Inf numbers, since they can pass as equal below. if math.IsInf(a+b+c, 0) == false { // and the sum of the lengths of any two sides must be greater than or equal to the length of the third side. if a+b >= c && a+c >= b && b+c >= a { @@ -46,13 +44,13 @@ func KindFromSides(a, b, c float64) Kind { if count == 3 { k = Equ // An _isosceles_ triangle has at least two sides the same length. (It is sometimes // specified as having exactly two sides the same length, but for the purposes of // this exercise we'll say at least two.) // An _isosceles_ triangle has at least two sides the same length. (It is sometimes // specified as having exactly two sides the same length, but for the purposes of // this exercise we'll say at least two.) } else if count >= 1 { k = Iso // A _scalene_ triangle has all sides of different lengths. // A _scalene_ triangle has all sides of different lengths. } else if count == 0 { k = Sca }