diff --git a/book_with_bridge/comon_shit/main.go b/book_with_bridge/comon_shit/main.go index 753e62b..3e8f556 100644 --- a/book_with_bridge/comon_shit/main.go +++ b/book_with_bridge/comon_shit/main.go @@ -2,19 +2,19 @@ package main import "fmt" -type Point struct { - x int -} - -func (p *Point) Inc() { - p.x++ +func Cakes(recipe, available map[string]int) int { + fin := 100000 + for k := range recipe { + fmt.Printf("recipe[k] is %d and available[k] is %d\n", recipe[k], available[k]) + temp := available[k] / recipe[k] + if temp < fin { + fin = temp + } + } + fmt.Println(fin) + return fin } func main() { - points := []Point{{1},{2},{3}} - - for i := range points { - points[i].Inc() - } - fmt.Println(points[0].x) -} \ No newline at end of file + Cakes(map[string]int{"flour": 500, "sugar": 200, "eggs": 1}, map[string]int{"flour": 1200, "sugar": 1200, "eggs": 5, "milk": 200}) +}