Puzzle | Minimum time required to make N Pancakes

Puzzle: You have to make N (≥ 1) pancakes using a skillet that can hold only two pancakes at a time. Each pancake has to be fried on both sides. Frying one side of a pancake takes one minute, regardless of whether one or two pancakes are fried at the same time. What is the minimum amount of time required to fry the pancakes?

Solution: Let’s try to solve this problem case-wise:

  1. If N = 1: This is a trivial case, where time to fry the pancakes is 2 minutes, as both sides need to be fried.
  2. If N is even: The time, in this case, is N minutes. Since two cakes can be fried at one time, N/2 minutes are needed to fry the cakes on one side. Hence, the total time taken to fry the cakes on both sides is N minutes.
  3. If N is odd: This case is a bit tricky. Let’s consider when the value of N = 3. We can fry 3 cakes in 3 minutes, as follows.

    • Firstly, fry pancakes 1 and 2 on one side.
    • Then fry pancake 1 on the second side together with pancake 3 on the first side.
    • Finally, fry the pancakes 2 and 3 on the second side together.
  4. If N is odd and greater than 3: We can first fry the 3 pancakes in 3 minutes and then the remaining (N – 3) pancakes, which is even, in (N – 3) minutes.

My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.

Article Tags :
Practice Tags :


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.