Created
January 16, 2020 17:00
-
-
Save codenoid/7f0fa4e7fee4224e8b910de6e8db7160 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package space | |
import "math" | |
type Planet string | |
var orbitalPeriod = map[string]float64{ | |
"Mercury": 0.2408467, | |
"Venus": 0.61519726, | |
"Earth": 1.0, | |
"Mars": 1.8808158, | |
"Jupiter": 11.862615, | |
"Saturn": 29.447498, | |
"Uranus": 84.016846, | |
"Neptune": 164.79132, | |
} | |
func Age(age float64, planet Planet) float64 { | |
second := make(map[string]float64) | |
for key, value := range orbitalPeriod { | |
// value * (365*24*60*60) | |
second[key] = value * 3.154e+7 | |
} | |
age = age / second[string(planet)] | |
return math.Round(age*100) / 100 | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment