How many bottles can you drink?

You have 120 bottles of Cola and 120 bottles of Sprite.

You can exchange 3 empty Cola bottles for a new bottle of Sprite.

You can exchange 4 empty Sprite bottles for a new bottle of Cola.

You can borrow empty bottles, but must return them in the end.

What is the maximal number of bottles of drink that you can drink? Prove the optimality of your result.

As this is a puzzle, please give short and clever answers rather than tedious bruteforce calculations.

• How does borrowing bottles help? Could you give an example, even in a case that does not belong (in number of bottles) to this problem? Jul 9 at 6:10
• @GeorgeMenoutis Example: you start with 2 bottles of Cola and 3 bottles of Sprite. After drinking all 5 bottles, you borrow 1 empty Cola bottle and use 3 Cola bottles to exchange 1 new Sprite. You then have 4 Sprite bottles and can exchange a new Cola. Finally, return the empty Cola bottle after drinking it. Jul 9 at 6:18
• can you borrow empty bottle of cola and return empty bottle of sprite instead? Jul 9 at 7:56
• Oh you must return the borrowed bottles. Ok got it now. Can you return an empty sprite bottle instead of an empty cola bottle that you borrowed? I assume not. Jul 9 at 8:13
• The maximal number of bottles I can drink is about two, three occasionally - any more and the excess carbonation makes me puke. Jul 9 at 11:48

I'm not sure if this is the kind of solution you are looking for:

Let $$c$$ be the number of coke drinks taken, and $$s$$ the number of sprite drinks. If all the empty bottles produced could be exchanged even partially you'd get $$s/4$$ new coke drinks from the empty sprite bottles, and $$c/3$$ new sprite drinks from the coke bottles. This gives the two equations: $$c = 120 + \frac{s}4 \\ s = 120 + \frac{c}3$$ Solving this gives: $$c = \frac{1800}{11} = 163.6 \\ s = \frac{1920}{11} = 174.5$$ Of course you can't really create partial bottles so we have a maximum of $$163$$ cokes and $$174$$ sprites.
This can be achieved: The $$163$$ cokes are the original $$120$$ plus $$43$$ that were acquired in exchange for $$4*43=172$$ sprite bottles. The $$174$$ sprites are the original $$120$$ plus $$54$$ that were acquired in exchange for $$3*54=162$$ coke bottles. You have $$163-162=1$$ empty coke bottle and $$174-172=2$$ empty sprite bottles at the end.

Strictly speaking we should be solving these equations: $$c = 120 + \lfloor \frac{s}4 \rfloor \\ s = 120 + \lfloor \frac{c}3 \rfloor$$
With starting amounts other than $$120$$ it is possible that there are two solutions to these equations. Note that for a variable to have a different value, the other variable must change enough for the floor function to give a different value. Therefore a second solution can only happen when $$s$$ and $$c$$ can both be increased by $$1$$ and where both those floor functions change value. This happens when at the end you have $$3$$ empty sprite bottles and $$2$$ empty coke bottles, and in this situation you can borrow one empty bottle of either drink, drink one of each type and return the empty bottle after which you have no bottles left.

• Nice answer (: The generalized form is an integral linear optimization problem. Jul 9 at 19:20

You can drink about 337 bottles.

Explanations:

First, an explicit construction of a 337-bottle solution (Cola and Sprite are abbreviated to C and S respectively for the sake of brevity):
1. Starting with 120C and 120S, drink all 240 bottles and exchange. You are left with 30C and 40S.
2. Drink all 70 bottles and exchange. You are left with 10C and 10S.
3. Drink all 20 bottles and exchange as much as possible. You are left with 2C and 3S (and 1 empty C and 2 empty S bottles).
4. As shown in the OP's comment, you can drink at least 7 more bottles from this state (even without borrowing, since you already have an empty Cola bottle).
Second, a proof for the upper bound. Let's assign a value of 1 to an empty bottle (any one), 3 to a new Sprite bottle and 4 to a new Cola bottle. So, when you exchange bottles, the total value of your bottles does not change. It never increases (note that we don't count the value of borrowed bottles, since you must return them in the end), and decreases if and only if you drink (it decreases by 3, if you drink a Cola bottle, and by 2, if you drink a Sprite one). Of course, the value remains nonnegative but can become zero in the end (since you can borrow bottles, so you can end up with no bottles at all).
You have started with value $$120\times3+120\times4=840$$. Note however, that at least 162 of the bottles drunk must be Cola bottles (120 initial ones + 30 which were exchanged from 120 initial Sprite bottles + 10 which were exchanged from 40 Sprite bottles remaining upon drinking the 120 initial Sprite bottles + 2 which were exchanged from 10 Sprite bottles remaining from 30 Cola bottles after the first exchange — since the empty bottles are useless for the purposes other than exchanging). So, the drunk Cola bottles will decrease the value by at least $$162\times3=486$$. Even if the remaining value of $$840-486=354$$ was fully @taken@ bu drunk Sprite bottles, number of them will be $$354/2=177$$ (since each drunk Sprite bottle decreases the value by 2), so the grand total will be $$160+177=337$$.

• Thanks for answering, but this looks more like a bruteforce method, as it doesn't easily generalize to, say, $10^9$ bottles of both drinks. There should be a simpler and logically clearer solution. Jul 9 at 10:26
• To its credit, this answer shows that 337 can be attained --- by detailing a sequence of events. Jaap's answer is fine on the arithmetic, but doesn't resolve the paradox of how you get new Coke bottles from exchanging new Sprite bottles you got by exchanging Coke bottles, and also vice versa. Jul 14 at 8:59

First note that the order of drinking does not matter

If I drink the cola, get sprite for it, drink it and then get cola for it:
* I drank 120 cola
* I drank 120/3 sprite
* I am left with 120/3/4 = 10 cola
So 110 cola nets me 120+40 drinks. Similarly 110 sprite nets me 120+30 drinks

If fractional bottles existed 1 cola would give 160/110 and one sprite 150/110 drinks
Then the answer would be 310 * 120/110 = 338 + 2/11

However with an integer number of bottles we can only end with 337, the 2/11 remainder is less than the 15/11/3 or 16/11/4 for which resp. an empty bottle of cola or sprite would count.
I end with 337 drinks finished, 1 empty cola bottle, 2 empty sprite bottles

PS: Similarly 10^9 bottles of each would give 10^9 * 310*110 - 13/11 drinks. Since the remainder of 10^9 / 11 is also 10, we have the same empty bottles remaining and (thus) the same 13/11 'loss'.
PPS: Note that the lending rule does matter, It allow (e.g.) the conversion of 11 full bottles of cola (C) to 16 drinks by lending 1 empty cola bottle (c): 11C+c -drink- 12c -exchange- 4S -drink- 4s -exchange- 1C -drink- 1c

An upper bound, at least.

First, forget terms of whole bottles for a minute. A "bottle" is actually a weirdly-named, infinitely-divisible item that can be consumed and then traded.

Each bottle of cola trades for $$1/3$$ of a bottle of sprite. But wait, if each bottle of sprite is actually worth $$1/4$$ of a bottle of cola, you have to figure that in, too! So really, given enough time, each full bottle of cola is worth $$1 + 1/3 + 1/12 + 1/36 + 1/144 + \cdots$$ empty bottles. Some re-arranging yields $$(1 + 1/3) * (1 + 1/12 + 1/144 + \cdots)$$. Similarly, each bottle of Sprite amounts to $$(1 + 1/4) * (1 + 1/12 + 1/144 + ...)$$.

If you have $$N$$ of each kind of bottle, the grand total is $$N * (2 + 7/12) * (1 + 1/12 + 1/144 + \cdots)$$ or $$31N * (1/12 + 1/144 + \cdots)$$ bottles. As it turns out, $$(1/12 + 1/144 + \cdots)$$ is actually $$0.11111\dots$$ in base 12, which (like with base 10 and $$1/9$$) works out nicely to $$1/11$$ in decimal.

So, ultimately. the upper bound given $$N$$ of each type of bottle is $$31N/11$$. That's quite a neat number, but it was computed with fractional bottles in mind. Fortunately, in the real world, we can borrow! Having some large number of one kind of bottle allows you to borrow up to $$1/12$$ of that quantity, trade back and forth, and then repay. I suspect (but am not totallty sure) that trading allows us to get up to that upper bound rounded down. In the case of $$N=120$$, that means we can drink $$\lfloor338.18181818\rfloor = 338$$ bottles.

you can drink 338 bottles

Explaination:

120s 120c = 240

30c 40s = 70

10s 10c = 20

3c 3s = 6

1s 3s = 1

1c(4s = 1c) = 1 this last bottle will return

TOTAL = 338

Without borrowing any bottles:

120 C + 120 S (all 240 bottles drunk)

30 C + 40 S (all 70 bottles drunk)

10 C + 10 S (all 20 bottles drunk)

After that:

10 C + (2 C + 2 S) = 12 C + 2 S (8 S to be traded for 2 C, then these 2 bottles are drunk)

6 S (12 C to be traded for 4 S, then these 4 bottles are drunk)

2 S + 1 C (C is drunk)

Total = 337 bottles.

Prove it's the best answer without borrowing:

120 C + 120 S

After taking $$x_1$$ C and $$y_1$$ S bottles: $$(120-x_1+y_1/4)$$ C + $$(120-y_1+x_1/3)$$ S

$$(x_1 + ... + x_n) - (y_1 + ... + y_n)/4 = 120$$

$$(y_1 + ... + y_n) - (x_1 + ... + x_n)/3 = 120$$

$$A - B/4 = 120 = B - A/3$$

$$4A - 480 = B$$

$$(4A - 480) - A/3 = 120$$

$$11A/3 = 600$$

$$1800/11 = A$$

$$(7200-5280)/11 = 1920/11 = B$$

$$floor(B/4) + floor(A/3)= floor(480/11) + floor(600/11) = 43 + 54 = 97 =$$ number of new bottles

The result is then 337.

By borrowing bottles:

Let's say we borrow $$c$$ Coca Cola bottles and $$s$$ Sprite bottles. Then:

$$A - B/4 = 120 + c$$

$$B - A/3 = 120 + s$$

$$4A - 480 - 4c = B$$

$$11A/3 - 600 - 4c = s$$

$$(4c + s + 600)3/11 = (12c + 3s + 1800)/11 = A$$

$$[(4c + s + 600)12 - 44c - 5280]/11 = (12s + 1920 + 4c)/11 = B$$

$$extra <= floor(12c+3s)/33 + floor(12s+4c)/44 + 2 = s+c$$ number of new bottles, which is wrong.

It doesn't increase, so it's still 337.