DEV Community

Cover image for Solving Python Logical Problems
Narasimma Radhakrishnan
Narasimma Radhakrishnan

Posted on

Solving Python Logical Problems

Chapathi Story Problem

A person named Viyan eats chapathis three times a day.
Breakfast: He eats 1/3 of the chapathis.
Lunch: He eats 1/3 of the remaining chapathis.
Dinner: He eats 1/3 of the remaining chapathis.
The next morning, 8 chapathis are remaining.
How many chapathis did the maid prepare originally?


remain = 8

dinner = remain * 3 // 2
lunch = dinner * 3 // 2
breakfast = lunch * 3 // 2

print("Total Chapathis:", breakfast)
Enter fullscreen mode Exit fullscreen mode
Total Chapathis: 27
Enter fullscreen mode Exit fullscreen mode

Top comments (0)