FunctionRacerProblemsRace

Water Bottles

EasyMathPython, JavaScript, TypeScript, Java, C++

You start with full full bottles. You drink a bottle, which makes it empty. At any time you may trade exchange empty bottles for one new full bottle. Return the greatest number of bottles you can drink in total.

Example 1

full 9
exchange 3
returns 13

Drink 9, trade 9 empties for 3, drink 3, trade 3 for 1, drink 1: 13.

Constraints

Race itor take your time

Write it in your browser, against the clock. The model solution, stepped through line by line, comes after.

More Math problems