From 94c61a1f83614691c045f67b25c69838adcd90da Mon Sep 17 00:00:00 2001 From: bumpsoo Date: Sun, 7 Jul 2024 14:26:52 +0900 Subject: [PATCH] https://leetcode.com/problems/water-bottles --- easy/watter_bottles.py | 10 ++++++++++ 1 file changed, 10 insertions(+) create mode 100644 easy/watter_bottles.py diff --git a/easy/watter_bottles.py b/easy/watter_bottles.py new file mode 100644 index 0000000..def1e27 --- /dev/null +++ b/easy/watter_bottles.py @@ -0,0 +1,10 @@ +# https://leetcode.com/problems/water-bottles +class Solution: + def numWaterBottles(self, numBottles: int, numExchange: int) -> int: + ret = numBottles + while numBottles >= numExchange: + full = numBottles // numExchange + ret += full + numBottles = (numBottles % numExchange) + full + return ret +