Skip to content

Instantly share code, notes, and snippets.

@victoriadrake
Last active July 28, 2019 19:48
Show Gist options
  • Save victoriadrake/e158d143b5fbbc0b7139519c1cae4b4a to your computer and use it in GitHub Desktop.
Save victoriadrake/e158d143b5fbbc0b7139519c1cae4b4a to your computer and use it in GitHub Desktop.
Figure out if a pie is big enough.
package main
import (
"fmt"
"math"
)
// Slice a `x` inch diameter pie into `n` pieces.
// Return true if each slice is greater than `m` inches wide.
func slicePie(x, n, m int) bool {
var radius, circumference float32
radius = float32(x)/2
circumference = 2 * math.Pi * radius
sliceSize := circumference/float32(n)
fmt.Println(float32(sliceSize))
return sliceSize > float32(m)
}
func main() {
fmt.Println(slicePie(10,12,2))
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment