Skip to main content
Home
plus.maths.org

Secondary menu

  • My list
  • About Plus
  • Sponsors
  • Subscribe
  • Contact Us
  • Log in
  • Main navigation

  • Home
  • Articles
  • Collections
  • Podcasts
  • Maths in a minute
  • Puzzles
  • Videos
  • Topics and tags
  • For

    • cat icon
      Curiosity
    • newspaper icon
      Media
    • graduation icon
      Education
    • briefcase icon
      Policy

    Popular topics and tags

    Shapes

    • Geometry
    • Vectors and matrices
    • Topology
    • Networks and graph theory
    • Fractals

    Numbers

    • Number theory
    • Arithmetic
    • Prime numbers
    • Fermat's last theorem
    • Cryptography

    Computing and information

    • Quantum computing
    • Complexity
    • Information theory
    • Artificial intelligence and machine learning
    • Algorithm

    Data and probability

    • Statistics
    • Probability and uncertainty
    • Randomness

    Abstract structures

    • Symmetry
    • Algebra and group theory
    • Vectors and matrices

    Physics

    • Fluid dynamics
    • Quantum physics
    • General relativity, gravity and black holes
    • Entropy and thermodynamics
    • String theory and quantum gravity

    Arts, humanities and sport

    • History and philosophy of mathematics
    • Art and Music
    • Language
    • Sport

    Logic, proof and strategy

    • Logic
    • Proof
    • Game theory

    Calculus and analysis

    • Differential equations
    • Calculus

    Towards applications

    • Mathematical modelling
    • Dynamical systems and Chaos

    Applications

    • Medicine and health
    • Epidemiology
    • Biology
    • Economics and finance
    • Engineering and architecture
    • Weather forecasting
    • Climate change

    Understanding of mathematics

    • Public understanding of mathematics
    • Education

    Get your maths quickly

    • Maths in a minute

    Main menu

  • Home
  • Articles
  • Collections
  • Podcasts
  • Maths in a minute
  • Puzzles
  • Videos
  • Topics and tags
  • Audiences

    • cat icon
      Curiosity
    • newspaper icon
      Media
    • graduation icon
      Education
    • briefcase icon
      Policy

    Secondary menu

  • My list
  • About Plus
  • Sponsors
  • Subscribe
  • Contact Us
  • Log in
  • Maths in a minute: Flipping pancakes

    5 March, 2019

    It's pancake day, so let's imagine a stack of pancakes. Unless you are very good at making them, the pancakes are likely to come in different sizes, which makes a stack of them look very untidy. One way of making it look better is to order them by size, so you have the biggest at the bottom and the smallest on the top.

    Want a neater stack?

    How can you order the pancakes in this way if the only tool you have is a spatula you can use to flip the pancakes over? One method goes as follows. First number the pancakes by size; 1 for the smallest, 2 for the second smallest, and so on. Then find the first pancake (counting from the top of the stack) that is in the wrong place (i.e. has smaller pancakes beneath it). For example, you might find that pancake number 3 is in position number 2. Now insert your spatula beneath the offending pancake and flip the whole stack on top of the spatula over. The offending pancake is now right on top. Next, insert your spatula beneath the position where the offending pancake is meant to be (position 3 in our example) and again flip the stack on top of the spatula. The offending pancake is now in the position it is meant to be in.

    If you keep going like this, for each offending pancake in turn, you will eventually end up with a stack that is sorted by size. And it turns out that if you have $n$ pancakes in total, this method takes at most $2(n-1)$ flips. This is good to know, but it still means that you might need a lot of flipping. For a stack of $n=10$ pancakes, it might take you all of $2\times 9 = 18$ flips, which is tedious. Is there a better method and, if yes, how many flips will it require?

    That's a very tricky question. The first significant improvement on the upper bound of $2(n-1)$ was proved by non other than Bill Gates, together with Christos Papadimitriou, when Gates was a student at Harvard in the mid 1970s. The two proved that every stack of pancakes can be sorted by at most $(5n+5)/3$ flips. This bound was not improved until 2009 by a team of seven researchers from the University of Texas at Dallas, who divided the problem into 2220 different cases to show that every stack can be sorted by at most $18n/11$ flips.

    In 2011 another team of researchers showed that the problem of finding the shortest sequence of flips for a given stack of pancakes is what's called NP-hard. Loosely speaking it means that, as far as anyone knows, the problem really is very, very hard. For more detail on what it means in the technical sense, see this article.

    The pancake flipping problem isn't just relevant to pancakes, but finds applications in all sorts of contexts where things need to be sorted. For an example involving chromosome flipping and evolution, see this article.

    • Log in or register to post comments

    Read more about...

    Maths in a minute
    pancake flipping problem
    permutation
    NP
    complexity

    Our Podcast: Maths on the Move

    Our Maths on the Move podcast brings you the latest news from the world of maths, plus interviews and discussions with leading mathematicians and scientists about the maths that is changing our lives.

    Apple Podcasts
    Spotify
    Podbean

    Plus delivered to you

    Keep up to date with Plus by subscribing to our newsletter or following Plus on X or Bluesky.

    University of Cambridge logo

    Plus is part of the family of activities in the Millennium Mathematics Project.
    Copyright © 1997 - 2025. University of Cambridge. All rights reserved.

    Terms