diff --git a/go/water-bottles.go b/go/water-bottles.go new file mode 100644 index 0000000..503078e --- /dev/null +++ b/go/water-bottles.go @@ -0,0 +1,16 @@ +package main + +func numWaterBottles(numBottles int, numExchange int) int { + drank := 0 + + for numBottles >= numExchange { + canGet := numBottles / numExchange + + drank += canGet * numExchange + numBottles -= canGet * numExchange + + numBottles += canGet + } + + return drank + numBottles +}