DEV Community

Mathu varshtih
Mathu varshtih

Posted on Edited on

Python:Scenario based Problem

1) Chocolate Wrapper Problem

You have Rs. 100 /- One chocolate costs Rs. 5. Every time you buy a chocolate, you get one wrapper. You can exchange 3 wrappers for 1 additional chocolate. What is the maximum number of chocolates you can have with Rs. 100?

My Approch:



money = 100
cost = 5

Choc = money 
wrapper = Choc

total = Choc

while wrapper >= 3:
    newChoc = wrapper

    total = total + newChoc

    remainWrapper = wrapper % 3

    wrapper = remainWrapper + newChoc

print("Total:", total)

output = 29
Enter fullscreen mode Exit fullscreen mode

2) Chapathi Story

MyApproch:

Code

Need to be solved

Top comments (0)