Ctrl K

Refills for Empties

Easy
A coffee shop runs a promotion: hand in rate empty branded cups and you get one full cup. You start with full full cups. Once you drink a cup it becomes empty and can be handed in along with the others. Return the total number of cups you can drink if you keep trading empties for as long as you can.
Example 1
full=7, rate=3 → 10

Drink 7 cups, trade 6 empties for 2 full ones (1 empty is left over). Drink those and you hold 3 empties again, worth 1 more cup. Total: 7 + 2 + 1 = 10.

Example 2
full=4, rate=5 → 4

You never collect 5 empties, so no trade is possible and the answer is 4.

Example 3
full=12, rate=2 → 23
Constraints
  • 1 ≤ full ≤ 100
  • 2 ≤ rate ≤ 100
Have you seen this problem in a real interview?
Solved by0
Tried by0
Submissions0
Acceptance—
Topics
Similar problemsSum of Binary Strings EasyFold the Digits Down to One EasyCounting Off by Threes and Fives EasyAdding Long Numbers in Strings EasyGrowing Handouts Around the Circle Easy
loading Python…
Input
full=7, rate=3
Expected
10

Run checks the first 3 tests in your browser. Submit checks all 76 tests on the server, hidden ones included.