DEV Community

loading...

Discussion on: Daily Challenge #275 - Casino Chips

Collapse
a3 profile image
Ajay

Go #GoLang

package main

import (
    "fmt"
    "sort"
    "math"
)

func main() {
    fmt.Println("Hello, playground");
    conins := []int{12,2,1}
    res := play(conins)
    fmt.Println(res)
}

func play(c []int) int {
    if(c[0] == c[1] && c[1]==c[2] && c[0] == c[2]) {
        return int(math.Floor(float64(c[0])*1.5))
    }
    sort.Ints(c)
    return int(math.Min(float64(c[2]), float64(c[0]+c[1])));
}