Ad
Fundamentals
Strings
Data Types
Code
Diff
  • package kata
    
    import "fmt"
    
    // MinsToHours converts Minutes to Hours and Minutes
    func MinsToHours(mins int) string {
        return fmt.Sprintf("%d:%.2d", mins / 60, mins % 60)
    }
    • fn minutes(mins: u32) -> String {
    • format!("{}:{:02}", mins / 60, mins % 60)
    • package kata
    • import "fmt"
    • // MinsToHours converts Minutes to Hours and Minutes
    • func MinsToHours(mins int) string {
    • return fmt.Sprintf("%d:%.2d", mins / 60, mins % 60)
    • }
Code
Diff
  • package kata
    
    // CalcAgeOnMars calculates the age on Mars from on a age on Earth 
    func CalcAgeOnMars(age int) int {
      return age * 365 / 687
    }
    
    • package main
    • package kata
    • import "fmt"
    • func main() {
    • var age int
    • fmt.Printf("Enter your age on Earth: ")
    • _, err := fmt.Scanf("%d", &age)
    • if (err != nil) {
    • fmt.Println(err)
    • }
    • age = age * 365 / 687
    • fmt.Printf("Your age on the surface of Mars is %d years old.\n", age)
    • }
    • // CalcAgeOnMars calculates the age on Mars from on a age on Earth
    • func CalcAgeOnMars(age int) int {
    • return age * 365 / 687
    • }