Chocolate Wrapper Problem
I have ₹100. One chocolate costs ₹5. Every time I buy a chocolate, I get one wrapper. I can exchange 3 wrappers for 1 additional chocolate.
What is the maximum number of chocolates I can get?
Total money = ₹100
One chocolate = ₹5
3 wrappers = 1 chocolate
Every new chocolate gives 1 wrapper.
m = 100
c = 5
chocolates = m // c
wrappers = chocolates
while wrappers >= 3:
new_chocolates = wrappers // 3
chocolates = chocolates + new_chocolates
remaining = wrappers % 3
wrappers = new_chocolates + remaining
print("Total Chocolates:", chocolates)
Total Chocolates: 29

Top comments (0)