1.Chapathi Story
There is one person called Viyan. He is a Software Engineer. He employs a maid for cooking. One day, the maid prepared n number of chapathis and kept in a hot box. Viyan ate those chapathis and the count is as follows:
* For Morning breakfast, he completed 1/3 number of chapathis in the hot box.
* For Lunch, He had 1/3 of what was there in the hot box.
* For Dinner, again he took and ate 1/3 number of chapathis present in the box.
The next day morning, When the maid checked the number of chapathis remaining, it was 8. What was the number of chapathis, She made - in total?

chapathi = 8
n = 0
while n < 3:
chapathi = chapathi * (3/2)
n += 1
print(chapathi)
#output =27
2.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?
total = 100
price = 5
chocolates = total // price
wrappers = chocolates #20wrap=20chocolate
while wrappers >= 3:
new_chocolates = wrappers // 3 #6,2,1
chocolates += new_chocolates #26,28,29
wrappers = (wrappers % 3) + new_chocolates #8,4,2
print(chocolates)
#output 29

Top comments (0)