DEV Community

Sajin Joe J
Sajin Joe J

Posted on Edited on

Python : 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?

remaining = 8


dinner = remaining * 3//2   #2/3 -> Reciprocal-> 3/2 ->8x3/2 ->12
lunch = dinner * 3//2       #12x3/2 ->18
morning = lunch * 3//2      #18x3/2 ->27

print("Total Chappathi", morning)  #27
Enter fullscreen mode Exit fullscreen mode

What was the number of chapathis, She made - in total?

Total Chappathi 27
Enter fullscreen mode Exit fullscreen mode

Top comments (0)