The problem
Discover the full sum of inner angles (in levels) in an n-sided easy polygon.
N will probably be larger than 2.
The answer in Golang
Choice 1:
bundle answer
func Angle(n int) int {
return (n - 2) * 180
}
Choice 2:
bundle answer
func Angle(n int) (r int) {
r = (n-2)*180
return
}
Choice 3:
bundle answer
func Angle(n int) int {
return (n/2-1) * 360 + npercent2 * 180
}
Check instances to validate our answer
bundle solution_test
import (
. "github.com/onsi/ginkgo"
. "github.com/onsi/gomega"
)
var _ = Describe("Primary assessments", func() {
It("Angle(3)", func() { Count on(Angle(3)).To(Equal(180)) })
It("Angle(4)", func() { Count on(Angle(4)).To(Equal(360)) })
})