re: Daily Challenge #84 - Third Angle of a Triangle VIEW POST

FULL DISCUSSION
 

In Go!

func thirdAngle(a, b int) (int, error) {
    if (a + b) >= 180 {
        return 0, errors.New("Input angles sum is greater than or equal to 180 degress, this cannot be a triangle")
    }
    if a == 0 || b == 0 {
        return 0, errors.New("Input angle cannot be zero, cannot be a triangle")
    }
    angle := 360 - a - b // sum of angles must be 360 degress
    return angle, nil
}

Go Playground

code of conduct - report abuse