Slashdot Mirror


Pancake Flipping Is Hard — NP Hard

mikejuk writes "French computer scientists have finally proved that sorting pancakes is hard — NP hard. No really — this isn't a joke. Well, it is slightly amusing but that's just because it is being presented as pancake flipping. The algorithm in question is sorting a permutation using prefix reversal — which is much easier to understand in terms of pancakes. Basically you have to sort a pancake stack by simply inserting your spatula and flipping the top part of the stack. We now know that if you can do the this in polynomial time then you have proved that P=NP."

260 comments

  1. I'm more interested... by halivar · · Score: 4, Funny

    ...in finding the exact amount of maple syrup I need to pour on a pancake stack to ensure that my bacon is accidentally covered in it.

    Because I would never intentionally put maple syrup on my bacon; that's barbaric.

    1. Re:I'm more interested... by Anonymous Coward · · Score: 0

      It's good on sausage too!

    2. Re:I'm more interested... by kungfugleek · · Score: 1

      Just like how I would never intentionally dip my bacon, and sausage, in runny egg yolk and wrap it in a butter and syrup-soaked pancake. Not without adding peanut butter, that is.

    3. Re:I'm more interested... by Tarlus · · Score: 1

      My day can now start on a happy note. Thanks for that. :)

      --
      /* No Comment */
    4. Re:I'm more interested... by Dunbal · · Score: 3, Informative

      If you used real Canadian maple syrup from real Maple trees instead of that artificial corn syrup crap the rest of the world calls "maple syrup" that tastes like dead beetles, then it really wouldn't matter if you got some on your bacon because everything tastes better with Maple Syrup.

      --
      Seven puppies were harmed during the making of this post.
    5. Re:I'm more interested... by X0563511 · · Score: 1

      Those are some tasty beetles.

      --
      For large sets, this will be our guide even unto death, for the LORD will work for each type of data it is applied to...
    6. Re:I'm more interested... by operagost · · Score: 1

      Protip: we have both consumer protection laws and sugar maple trees in the USA. The fake stuff is called "pancake syrup"; calling it "maple syrup" would be fraudulent. And Vermont is very proud of its maple syrup.

      --

      Gamingmuseum.com: Give your 3D accelerator a rest.
    7. Re:I'm more interested... by MagicM · · Score: 4, Funny

      that artificial corn syrup crap the rest of the world calls "maple syrup" that tastes like dead beetles

      It's called "beetle juice". It's quite popular in some areas. I love me some beetle juice.

      Mmmm. Beetle juice.

    8. Re:I'm more interested... by Anonymous Coward · · Score: 0

      Don't say his name again, he'll come in thread.

    9. Re:I'm more interested... by fostware · · Score: 4, Funny

      Shhh!

      You'll summon the remake!

      --
      "We know what happens to people who stay in the middle of the road. They get run over." - Aneurin Bevan
    10. Re:I'm more interested... by Dunbal · · Score: 1

      we have both consumer protection laws

      Those must be fairly new - it used to be called maple syrup when I was a Canadian ex-pat kid growing up in Florida. I think many restaurants still call it "maple syrup" though on the menu.

      And Vermont is very proud of its maple syrup.

      Also a recent development. Of course American maple syrup is nowhere near as good as Quebec maple syrup, but that's just my biased Montreal snob-side coming out. Good for you, any cartel (and the Quebec maple syrup industry certainly is a cartel that has been gouging the price for years) deserves a little competition overseas.

      --
      Seven puppies were harmed during the making of this post.
    11. Re:I'm more interested... by kimvette · · Score: 1

      Even better is maple sugar - it is very hard to find in supermarkets so when I vacation in PA or NH I buy bulk amounts of it. Maple sugar is amazing in breads, coffee, cakes, cookies, and cream cheese frosting. YumYumYum!

      No one really eats that "pancace syrup" or "maple flavor syrup" do they? That stuff is nasty.

      --
      The Christian Right is Neither (Christian nor right). See: Matthew 23, Matthew 25, Ezekiel 16:48-50
    12. Re:I'm more interested... by Scaba · · Score: 1

      Hmmm. Everything also tastes better with bacon. So the question is: does putting real maple syrup on your bacon cause them to improve one another's flavors until your breakfast reaches a maximum recursion limit?

    13. Re:I'm more interested... by Crudely_Indecent · · Score: 1

      Just go to your nearest Whole Foods (or other real food distributor) and get Grade-B maple syrup. It's not as filtered as the standard Grade-A syrup that most are used to. The flavor is incredible compared to the processed crap that everyone is used to.

      --


      "Lame" - Galaxar
    14. Re:I'm more interested... by Golddess · · Score: 1

      Huh, and here I've been trying to use maple syrup in place of the standard, dull, white sugar in certain recipes. So there's actually a maple sugar you say? Wonder how it'd compare...

      --
      "I'm not sure I like the fugnutish tone you used in your post!" -RogL (608926)-
    15. Re:I'm more interested... by Synerg1y · · Score: 1

      Reminds me of the coffee apparatus from the lab in breaking bad tv series :)

    16. Re:I'm more interested... by s4ndm4n · · Score: 2
    17. Re:I'm more interested... by Rogue+Haggis+Landing · · Score: 5, Informative

      Just go to your nearest Whole Foods (or other real food distributor) and get Grade-B maple syrup. It's not as filtered as the standard Grade-A syrup that most are used to. The flavor is incredible compared to the processed crap that everyone is used to.

      FWIW, maple syrup grades are more dependent on when the trees were tapped than on filtering and processing. (Actually, they're most dependent on what state, provincial, or national body is defining the grades, but that's a different story.) Early in the season, trees produce sap that tends to be higher in sugar and water, and lighter in flavor and color. This sap becomes grade A syrup. As the season progresses, the sap tends to become thicker, less sugary, darker, and stronger flavored, eventually becoming grade B and beyond. This varies from season to season and even from tree to tree, but is generally true.

      If you're really hardcore about your maple, you can round up some Vermont Grade C syrup, "commercial grade", that's usually used in large-scale baking operations. It's extremely thick and strong -- my wife calls it maple sludge. If you like maple, that's as close to the taste of the tree as you can get without gnawing on some bark.

    18. Re:I'm more interested... by djeez · · Score: 2

      I understand not everybody has this luxury, but what I do every spring is shop around in the various friends and families that happen to know people who own or operate a sugar shack and get various grades of maple syrup. I use grade A instead of white sugar for day-to-day usages (coffee, cereals, etc.), grade B when I'm out of grade A or for maple recipes and grade C for maple sauces and dressings. I once had access to grade D and the strength of the taste was incredible, especially in salad dressing.

      So yeah, I consume about two gallons of maple syrup per year plus maple butter on toasts and maple sugar instead of brown sugar and I actually keep a bottle of syrup at work to sweeten my (and my coworker's) coffee.

      Everything is better with maple.

    19. Re:I'm more interested... by Anonymous Coward · · Score: 0

      Yes of course, which is why i do it.

    20. Re:I'm more interested... by djeez · · Score: 1

      Actually, it kinds of saturates the pleasure center until you achieve foodgasm and/or foodvana. Be careful not to overdose because that leads straight to pleasure coma.

    21. Re:I'm more interested... by Dunbal · · Score: 1

      mmmmm maple butter..... responsible for at least 1 of my blocked coronary arteries. Damn you, doting grand-parents!

      --
      Seven puppies were harmed during the making of this post.
    22. Re:I'm more interested... by Dunbal · · Score: 1

      If you do it too often you also end up running out of dopamine, just like meth users. So just do it once every couple of weeks.

      --
      Seven puppies were harmed during the making of this post.
    23. Re:I'm more interested... by Anonymous Coward · · Score: 1

      Too late. He already said it three times.

    24. Re:I'm more interested... by Dunbal · · Score: 1

      I understand not everybody has this luxury,

      There's no excuse nowadays. I live in Costa Rica and my local convenience store has "Roland" brand 100% genuine Canadian maple syrup. Of course it costs me like $35 for a tiny little jug, but hey you want good stuff you pay good money. Much better than the "dark ages" (30 years ago) where you could ONLY get maple syrup from Quebec, in Quebec province, and probably had to be able to cuss in French Canadian to get it. Maudit tabarnac.

      --
      Seven puppies were harmed during the making of this post.
    25. Re:I'm more interested... by Crudely_Indecent · · Score: 1

      I always thought the grading was based on filtering. I learn something new every day!

      --


      "Lame" - Galaxar
    26. Re:I'm more interested... by Oligonicella · · Score: 1

      Sounds good, but holy crap! -- At $16 a pound, I'll pass. I'd have to find it waaay lower to try.

    27. Re:I'm more interested... by INT_QRK · · Score: 1

      ...or Vermont Maple syrup, but honestly, I don't think the Maple Trees much care, disloyal bastards.

    28. Re:I'm more interested... by jamiesan · · Score: 2

      Beetle Juice Beetle Juice Beetle Juice

    29. Re:I'm more interested... by desdinova+216 · · Score: 1

      Oh I wish I had mod points for you and the Parent Post. You both deserve a +1 Funny

    30. Re:I'm more interested... by CheshireDragon · · Score: 1

      Indeed, I don't get that artificial crap. I just wish it was cheaper than 18$ for a 10oz bottle. I guess that's the power of reduction. Takes 15gal of the delicious tree sap to make 1gal of servable deliciousness. When I move to MN I am going to plant a maple tree so I can have my own delicious tree sap. I will just go out every morning and take a bite of the tree hahahah high in fiber :P

      --
      "That's right...I said it."
    31. Re:I'm more interested... by Atomus · · Score: 1

      You sir/ma'am are the reason I just signed up for /. Thank you for putting me in tears.... X-D

    32. Re:I'm more interested... by crakbone · · Score: 2

      I think you had "Maple flavored syrup". That was pretty common and most of the time "flavored" was off to the side or made to not stand out. As for me, pure maple syrup all the way.

    33. Re:I'm more interested... by mwvdlee · · Score: 2

      I don't know about Maple syrup specifically, but a country's border may very well influence the taste of food simply due to laws banning or prescribing certain production methods of prohibiting the use of certain ingredients.

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    34. Re:I'm more interested... by halivar · · Score: 1

      You can get 32oz. of grade B syrup from Vermont on Amazon for $20. It's what I use for baking.

    35. Re:I'm more interested... by Anonymous Coward · · Score: 0

      Rule # 1 about grade b syrup, don't tell people about grade b syrup, let them think they want grade a!

    36. Re:I'm more interested... by Dayze!Confused · · Score: 1

      And Vermont is very proud of its maple syrup.

      Also a recent development. Of course American maple syrup is nowhere near as good as Quebec maple syrup, but that's just my biased Montreal snob-side coming out. Good for you, any cartel (and the Quebec maple syrup industry certainly is a cartel that has been gouging the price for years) deserves a little competition overseas.

      I'm not sure where you think Vermont is, but the last I checked from Quebec to Vermont there are no seas, maybe a lake or two, but certainly no bodies of water large enough to constitute calling it a sea.

      --
      "All tyranny needs to gain a foothold is for people of good conscience to remain silent." [Thomas Jefferson]
    37. Re:I'm more interested... by bmo · · Score: 1

      It still doesn't make the Canadian's surprise that there is a maple sugar industry south of the Canadian border any less offensive.

      And btw, just like in Canada, you /pay/ for the real stuff from NY, VT, NH, and ME.

      We had sugar maples growing in our yard in RI. Never tapped them, though.

      Seriously, the Canadians here, including you, need to shut the fuck up.

      --
      BMO

    38. Re:I'm more interested... by Belial6 · · Score: 1

      That depends on which direction you go to get there.

    39. Re:I'm more interested... by garyebickford · · Score: 1

      Funny thing, you're right. I never really knew what that other stuff tasted like. Dead beetles is about right on - or at least so I imagine, never having eaten a dead beetle (to my knowledge). Also, you can buy maple-flavored sausages but they are not the same, they're just bad-tasting sausage. Real Maple Syrup FTW. I'd be interested in comparing Canadian to Vermont though. I guess that's going on my list of things to do.

      --
      It's easier to be a result of the past, but more fun to be a cause of the future! http://www.spacefinancegroup.com/
    40. Re:I'm more interested... by Anonymous Coward · · Score: 0

      Being that it's Quebec, I'm pretty sure all routes in and out require a visit to France somehow. ;)

    41. Re:I'm more interested... by Anonymous Coward · · Score: 0

      Maple syrup? Eww! With bacon?? *gag*
      Why not just wrap it around a stick, put it in Baconnaise Lite (2:07), and call it a day? :P
      Cause we can do anything!

    42. Re:I'm more interested... by residieu · · Score: 1

      I grew up with good old fashioned Log Cabin "Maple"(flavored) syrup, and while I'll admit the real stuff is good, I do prefer the thicker consistency you tend to get from corn syrup.

      I also prefer margarine over butter, so obviously I have no taste

    43. Re:I'm more interested... by Anonymous Coward · · Score: 0

      Seriously, you need to lighten the fuck up. it's about MAPLE SYRUP for crying out loud.

    44. Re:I'm more interested... by djeez · · Score: 1

      See, in my case I pay about 50 CAN$ for a gallon (8 cans) of maple syrup. That's why I'll never leave the province.

      I'm an addict, and I know it.

    45. Re:I'm more interested... by GameboyRMH · · Score: 1

      IT'S SHOWTIME!

      --
      "When information is power, privacy is freedom" - Jah-Wren Ryel
    46. Re:I'm more interested... by halivar · · Score: 1

      Try grade B. Seriously. Same thick consistency, but with real flavor and deliciousness that cannot be beat.

    47. Re:I'm more interested... by blair1q · · Score: 2

      That problem is Artery-hard.

    48. Re:I'm more interested... by Anonymous Coward · · Score: 0

      If you used real Canadian maple syrup from real Maple trees instead of that artificial corn syrup crap the rest of the world calls "maple syrup" that tastes like dead beetles

      Is it a good idea to take culinary advice from someone who knows what dead beetles taste like?

      then it really wouldn't matter if you got some on your bacon because everything tastes better with Maple Syrup.

      He wants it to get on the bacon. Perhaps dead beetles have deleterious some effect on reading comprehension.

    49. Re:I'm more interested... by Dunbal · · Score: 1

      That's why I'll never leave the province.

      Heh, you can keep it. I prefer to go around shivering and complaining about the "cold" when it's 17 degrees C outside. That's +17C... :P

      --
      Seven puppies were harmed during the making of this post.
    50. Re:I'm more interested... by nomadic · · Score: 1

      " Of course American maple syrup is nowhere near as good as Quebec maple syrup, but that's just my biased Montreal snob-side coming out. "

      Wow, do you actually believe that?

    51. Re:I'm more interested... by Dunbal · · Score: 1

      Is it a good idea to take culinary advice from someone who knows what dead beetles taste like?

      You sir, have obviously never ridden a motorcycle.

      Seriously though, I've never eaten beetles. But I have smelled them. And maple (flavored) syrup tastes like what beetles smell like.

      --
      Seven puppies were harmed during the making of this post.
    52. Re:I'm more interested... by longbot · · Score: 1

      Maple sugaring in Vermont is by no means a recent development. It's been going on since at least the 1700s, and possible a fair bit longer than that. I personally have been in a sugarhouse that's older than your country, and I assure you, they make better syrup than you guys do (I've had plenty of both).

      --
      I don't suffer from insanity, I enjoy every minute of it! --Longbottle
    53. Re:I'm more interested... by Anonymous Coward · · Score: 0

      Wait? You don't have maple glazed bacon? What kind of fifth rate bacon are you buying?

    54. Re:I'm more interested... by Anonymous Coward · · Score: 0

      It still doesn't make the Canadian's surprise that there is a maple sugar industry south of the Canadian border any less offensive.

      So how is that any different than USians being surprised that
      â mounties donâ(TM)t wear red serge and stetsons on regular duty
      â Canadians donâ(TM)t all speak French
      â we donâ(TM)t live in igloos
      â we donâ(TM)t say âoehooseâ and âoeabootâ
      â itâ(TM)s not winter eleven months of the year
      â etc ad nauseum

      Get a grip.

    55. Re:I'm more interested... by swalve · · Score: 1

      And they don't all know how to use unicode.

    56. Re:I'm more interested... by mwvdlee · · Score: 1

      Seriously, the Canadians here, including you, need to shut the fuck up.

      I'm not Canadian. Shows how bigoted you are.

      --
      Slashdot social media options: AIM, ICQ, Yahoo, Jabber and Mobile Text. Why no MySpace?
    57. Re:I'm more interested... by Alamais · · Score: 1

      Fuck yeah. Vermont grade-B maple syrup is like liquid sex. Just as sticky, too.

    58. Re:I'm more interested... by Alamais · · Score: 1

      The real winner? Cheddar and bacon waffles. Just the right amount of corn meal to make them extra crispy. Butter. A bit of syrup. And then you die.

    59. Re:I'm more interested... by mcswell · · Score: 1

      Oh, to be a beaver!

    60. Re:I'm more interested... by Anonymous Coward · · Score: 0

      I love maple syrup and hate beetle juice! Around 1971 or 1973 there was a cold snap that did major damage to the US and probably Canadian maple syrup industry. This is going by memory, btw. A fair percent of the US maple syrup trees were killed. (US reporting at the time tended to ignore the rest of the world, even Canada. Hmm, they still do.) The price and availability of real maple syrup went up. But, corn syrup arrived in time to....for corn syrup producers to take over.

      Of course, since corn syrup and fake maple syrup are part of the Forces of Evil, the only left to figure out is how they engineered the cold snap.

      Anonymous, not coward, too lazy to register....

    61. Re:I'm more interested... by Yaztromo · · Score: 1

      Hmmm. Everything also tastes better with bacon. So the question is: does putting real maple syrup on your bacon cause them to improve one another's flavors until your breakfast reaches a maximum recursion limit?

      Careful: you risk overflowing your pancake stack if you do.

      Yaz

    62. Re:I'm more interested... by buddilla · · Score: 0

      You can just use a form like a large cookie cutter and make them all the same size. DUH zero flips.

      --
      Pitch Forks: check Torches: check Angry People: check - A. LaChasse V for Victory
    63. Re:I'm more interested... by Anonymous Coward · · Score: 0

      this was the best comment ever!

    64. Re:I'm more interested... by Anonymous Coward · · Score: 0

      Please dont disparage beetles. im sure they are a much better snack than Old Missus Whippenpooper's Genuine Old Fashioned Pancaky Syrup Substance. In fact, dry roasted beetles covered with grade B or C maple syrup would be fantastic. What i love is that raw foodists think maple syrup is RAW. um, its cooked down from a watery texture for hours? how is that raw? (indians would let the water freeze and skim that off, maybe they think its done that way)

  2. Has anyone attempted to figure out... by Anonymous Coward · · Score: 2, Funny

    How we can do it in polynomial time but computers can't?

    1. Re:Has anyone attempted to figure out... by halivar · · Score: 1

      Can you? If P!=NP, then logic dictates you will not be able to do it in polynomial time.

      That's why they say that if you could do it in polynomial time, then P=NP.

    2. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      You can do it in polynomial time if you overclock your computer exponentially in n.

    3. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      If you can prove that you can do it in polynomial time, then there is a million bucks waiting for you in the bank. Also fame and glory: http://en.wikipedia.org/wiki/Millennium_Prize_Problems#P_versus_NP

    4. Re:Has anyone attempted to figure out... by durrr · · Score: 1

      Why use a computer? if a person can learn to do it you'd prove it too as the brain is governed by the same computational laws.

    5. Re:Has anyone attempted to figure out... by ledow · · Score: 1

      "Polynomial time" does not necessarily mean "quicker than a computer" or even "quickly" or EVEN "slowly". It just means an amount of time proportional to the size of the stack to some power (squared, cubed, etc.)

      Just because a human "can do it" doesn't mean that they did it in NP or even P. It just means they did it in a particular time for a particular example. The important thing is "What was that time compared to the size of the data"? I can handsort a stack of one cards just as fast as a computer. But when you get to 1,000,000 cards it's going to beat me. And when I get to 1,000,000,000 cards, I'll die before it even gets bored doing it. But that's not an answer.

      The point is to find a way that tasks that currently take "size of problem to some power" time to complete can be done in significantly less than that (i.e. no powers, or even log time!) no matter how big the problem is scaled up to.

      Humans lose at an awful lot of computational problems but only when they are scaled up. It's the scaling that concerns P=NP and the question itself is basically "can we STOP things that do that scaling faster than we could ever hope to catch up?" It's a way to do things that require n^26 operations to only need n, or log n, or some other non-polynomial time. The n itself doesn't matter one jot because that's only a SINGLE example of a particular type of that problem. If we crack how to remove those powers from the time taken, then any number of n won't really matter at all. But if we leave the powers try and try an n greater than a few dozen, we rapidly run into extreme amounts of trouble.

      How do you stop a problem needing FOUR times the computing power just because you DOUBLED the size of the input? That's basically what P=NP solution finders are trying to answer.

    6. Re:Has anyone attempted to figure out... by Joce640k · · Score: 1

      Am I missing something? I can do it in linear time...

      * Start with the bottom pancake and work towards the top
      * Locate next pancake, insert the spatula beneath it and flip it to the top
      * Insert the spatula at the position where it goes when sorted and flip again.

      Number of flips = 2 x Number of pancakes.

      --
      No sig today...
    7. Re:Has anyone attempted to figure out... by beelsebob · · Score: 1

      I'm struggling to understand the problem, can someone tell me what I've missunderstood.

      As I understand it the idea is to sort the pancakes from large to small by flipping a substack. Surely you could apply selection sort, where each time you select a pancake you flip from below it up (resulting in it being on top), and then flip from the place you want to insert it up, resulting in it now being on top of the currently sorted pile.

      Clearly as I've just given an easy O(n^2) solution, I've missed something, what is it?

    8. Re:Has anyone attempted to figure out... by Dunbal · · Score: 1

      Because we use abstraction instead of algorithms. The same type that lets us do 2nd order differential equations in our heads to put our hands in the path of a ball we intend to catch, without actually doing the math. Kinda hard to bind abstraction to a mathematical formula though.

      --
      Seven puppies were harmed during the making of this post.
    9. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      To prove that an algorithm runs in polynomial time, it's not enough to time it for n=1..10 -- you have to publish the algorithm and a run-time analysis. If you solve the problem with your brain, the published algorithm would be a map of your brain's neurons and a biochemical simulator. The referees would rather read C++.

    10. Re:Has anyone attempted to figure out... by Joce640k · · Score: 1

      PS: If the pancake is burnt on one side then you just flip it over when it's on the top:

      Maximum number of flips to sort burnt pancakes = 3 x Number of pancakes.

      --
      No sig today...
    11. Re:Has anyone attempted to figure out... by IkeTo · · Score: 1

      I think the question being asked is, given a certain stack, what is the minimum number of flips required. 2(n-1) is of course an upper bound, but that is not the minimum.

    12. Re:Has anyone attempted to figure out... by Elros · · Score: 1

      You've got 2n flips, but you haven't accounted for determining the location of the next pancake. Granted, I still think that can be done in n^2 time.

    13. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      Number of compares, not number of flips, Locate the next pancake is where your algorithm needs to be efficient, and a 2n claim would mean only 2n compares would only give you 10 compares to sort 5 pancakes.

    14. Re:Has anyone attempted to figure out... by Opportunist · · Score: 1

      Is that, like, you know how to stroke it but it's kinda hard to tell your girlfriend how to do it right?

      --
      We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
    15. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      More like O(n) actually (2 * number of pancakes)

      As pointed by Joce640k a few posts above.

      I would also be interested to know what we're all missing.

    16. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      Yes, the problem is not to sort a stack of pancakes, but to determine f(n), the minimum number of flips for all possible pancake stacks of size n. Determining f(n) is NP-hard in n.

    17. Re:Has anyone attempted to figure out... by jank1887 · · Score: 1, Funny

      computers have a specific disadvantage with this problem. they have trouble holding the spatula.

    18. Re:Has anyone attempted to figure out... by ComputerizedYoga · · Score: 2

      "size of the problem to some power" is the definition of polynomial time. Polynomial time problems are generally considered "easy" -- for example, your typical sorting algorithm is between n*log(n) and n^2. These grow slowly enough that general polynomial algorithms, even with relatively high exponents (like n^3 and n^4) are doable for reasonably large input sets.

      The time it takes to solve an NP-hard problem is more in line with "a constant raised to the power the size of the problem". So doubling the size of the input squares the computation involved. So like ... no known general solution to SAT is better than 2^n.

      So what that means is going from input size = 10 to input size = 20 would require a million times more power, and input size = 20 to input size = 21 would require twice the power that it would take to do input size = 20. This is WAY worse than n^x (where x is a constant).

    19. Re:Has anyone attempted to figure out... by Hatta · · Score: 1

      You can't.

      --
      Give me Classic Slashdot or give me death!
    20. Re:Has anyone attempted to figure out... by Dunbal · · Score: 1

      Surprisingly I didn't find it hard to explain it to her at all. I guess I got lucky - my ex wife never seemed to get it at all.

      --
      Seven puppies were harmed during the making of this post.
    21. Re:Has anyone attempted to figure out... by nschubach · · Score: 1

      I can handsort a stack of one cards just as fast as a computer.

      I don't know why, but I read this as if it said computers had hands...

      --
      Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
    22. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      RTFA. The 3rd paragraph of the linked article explains what you're missing (and why you're wrong):

      The only restriction, and this is what makes it difficult, is that you can't touch them with anything but your spatula. All you can do is insert your spatula at a division point and flip the entire set of pancakes you have picked up upside down in one operation.

    23. Re:Has anyone attempted to figure out... by AlecC · · Score: 1

      And O(n^2) is polynomial - it has a ^2 in it. And, apparently, they have proved there is no shortcut which is not polynomial unless P=NP. They have shown that this is one of a class of problems for which time to solve increases fast enough that for some value of n it must become uncomputable.

      --
      Consciousness is an illusion caused by an excess of self consciousness.
    24. Re:Has anyone attempted to figure out... by beelsebob · · Score: 2

      it still takes O(n) time to select the pancake to flip.

    25. Re:Has anyone attempted to figure out... by ComputerizedYoga · · Score: 1

      So the paper talks about SBPR (sorting by prefix reversals) and MIN-SBPR. The question is not "here, sort this stack of pancakes", it's "determine what the minimal number of flips is to sort an arbitrary stack of pancakes of size n".

      If I'm following this, then sorting the stack itself is relatively easy (as you said, n^2). Figuring out the optimal sorting is apparently what's hard.

    26. Re:Has anyone attempted to figure out... by beelsebob · · Score: 1

      Uhhh, no, the proof is that there is no *polynomial time* solution (i.e. all current solutions are higher than polynomial time, like exponential time or factorial time) unless P == NP.

      Remember P is the set of problems that can be solved in polynomial time on a deterministic machine, NP is the set of problems that can be solved in polynomial time on a non-deterministic machine.

      All problems (even hello world) have a polynomial or higher time complexity (hello world having O(k * n^0) complexity), linear problems have O(k * n^1) complexity, etc. Polynomial solutions is exactly what we want.

    27. Re:Has anyone attempted to figure out... by ebh · · Score: 1

      Right. 2n flips, 2^n compares. Unless we keep using the word "touch", but they do not think it means what we think it means.

      I'm presuming that whatever process we use to determine the next pancake to flip to the top doesn't count as "touching" it, only the flip does. Is that wrong?

    28. Re:Has anyone attempted to figure out... by ebh · · Score: 1

      s/2^n/n^2/

    29. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      n^26 is still polynomial time. Non-polynomial time is things like n^n, where the rate of increase increases as the problem scales.

    30. Re:Has anyone attempted to figure out... by Joce640k · · Score: 1

      you haven't accounted for determining the location of the next pancake.

      In real life you'd have to do that but the article was about the number of flips.

      --
      No sig today...
    31. Re:Has anyone attempted to figure out... by Joce640k · · Score: 1

      FTA: "if you can find a polynomial time solution to the pancake problem then you have proved that P=NP."

      "f(n) = 2(n-1)" is a polynomial solution of order 1 .... where's my million dollar (and Nobel) prize?

      --
      No sig today...
    32. Re:Has anyone attempted to figure out... by Joce640k · · Score: 1

      Number of compares, not number of flips

      Where does it say that...?

      --
      No sig today...
    33. Re:Has anyone attempted to figure out... by Joce640k · · Score: 1

      Isn't that what I'm doing?

      --
      No sig today...
    34. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      Cause computers are stupid, duh.

    35. Re:Has anyone attempted to figure out... by SQLGuru · · Score: 1

      I think (haven't actually done the research) the problem isn't in finding the upper bound (2n) but in finding the lower bound for a given stack.

      Stack A: 1, 7, 4, 2, 5, 3, 6
      Stack B: 7, 1, 2, 3, 4, 5, 6

      For Stack A, what's the fewest flips needed to sort them?
      For Stack B, what's the fewest flips needed to sort them?

      This isn't much different than the Travelling Salesman (most classic of NP problems) in that you are trying to organize a set of weightings in an optimal manner. Which is why the problem of pancake flipping would be deemed to be part of the NP family.

      Again, this is just conjecture on my part but it seems to make sense.

    36. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      Flip/insertion count is not the concern, what matters is comparisons. When we look at a short stack of pancakes (2-5 in my case), we may be able to easily compare them all at a glance. However, once you get to millions, you are going to have to do far more comparisons in order to determine insertions position. It doesn't matter if an algorithm can sort a stack in O(n) moves if it takes O(n2) comparisons to do so.

    37. Re:Has anyone attempted to figure out... by lgw · · Score: 1

      Remember P is the set of problems that can be solved in polynomial time on a deterministic machine, NP is the set of problems that can be solved in polynomial time on a non-deterministic machine.

      Not quite. NP-complete solutions have polynomial runtime on a non-deterministic machine, a subset of NP. NP problems are those where the solution can be verified in polynomial time on a deterministic machine. The terminology is confusing because it came before the realization that there were NP problems outside of NP complete (iff P != NP).

      NP-hard is all the problems in NP-complete, plus all the "harder" ones.

      --
      Socialism: a lie told by totalitarians and believed by fools.
    38. Re:Has anyone attempted to figure out... by blair1q · · Score: 1

      We don't do differential equations in our heads.

      We guess and correct as we chase the goal.

      Some people have more experience guessing, so they have to correct less.

    39. Re:Has anyone attempted to figure out... by FirstNoel · · Score: 1

      Yep, I think you got it.

      Like the travel salesman problem. A sales man can visit every site, but what is the most optimal travel path.

      the more places you add, the bigger the problem becomes....

      --
      "Hmm. I am to metaphor cheese as metaphor cheese is to transitive verb crackers!"
    40. Re:Has anyone attempted to figure out... by EuclideanSilence · · Score: 2

      The above is a solution to the question "how can I flip sort a stack of pancakes in polynomial time?"

      The question to be answered is: "let R(stack) be the minimum number of flips to sort a given stack. Let F(N) be the maximum value of R(stack) for all stacks of size N. Compute F(N)."

      Or, more precisely since it is a decision problem, probably something like "can all stacks of size N be flip-sorted in less than F(N) flips?", but it's trivially polytime equivalent.

      These french mathematicians showed that if you can compute F(N) then you can compute any NP problem in polytime. It does not however show that a solution to P=NP solves the pancake flipping problem.

      The article an summary were not very exact in their wording.

    41. Re:Has anyone attempted to figure out... by EuclideanSilence · · Score: 1

      How we can do it in polynomial time but computers can't?

      The term "computers" originally referred to humans who did computations.

    42. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      The Nobel prize is paid in Swedesh kronor, not dollars. Ten million of them. (About 1.51 million dollars at current exchange rates.)

    43. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      The minimum is 0. It is already sorted.

    44. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      But hey, wouldn't that generally solve making all NP-complete algorithms P? If it's a problem doing them in formulas, then we invent a new way of thinking about math. But I'm surprised to hear abstractions aren't really part of math, as they are kinda the whole point of the pattern matching in our brains. (And the point of abstractions is grouping of observations, whose point is predicting the outcome of similar events... which, as can be proven by the success of life with brains, is a good thing for solving problems. ;)

    45. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      It looks deceptively like n^2 because you are thinking that you can remove a single pan cake from anywhere and insert the same elsewhere (like bubble sort of integers).

      The problem here states that you are not allowed to yank pan cakes from one position and place in another position one cake at a time. In this sense it is not even like Towers of Hanoi. If you want to move one pan cake from its current location to somewhere else you have to move all pan cakes on top of it also at the same time.

    46. Re:Has anyone attempted to figure out... by nharmon · · Score: 1

      Correct. And in the case of catching a ball, we know that if the direction of a moving object remains the same relative to us, we are on a collision course. No need to do calculus in our heads.

    47. Re:Has anyone attempted to figure out... by Joce640k · · Score: 1

      The article an summary were not very exact in their wording.

      No Nobel prize for me then...? :-(

      --
      No sig today...
    48. Re:Has anyone attempted to figure out... by beelsebob · · Score: 1

      Reread my post -I gave an O(1) method of selecting a pancake and inserting it at a specified point, as long as you don't care about the resulting order of the pancakes above that point. This allows you to implement selection sort which is O(n^2). ComputerizedYoga however has hit the nail on the head. My misunderstanding was that the problem is finding the shortest series of flips to sort the pile, not simply sorting the pile. This makes it a much harder problem.

    49. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      So you can bring a specific pancake to its final destination. Can you do it without messing up the positions of pancakes that are already at the final destination? This is the issue as far as my 1-minute intuition goes, so don't put too much stock in it.

    50. Re:Has anyone attempted to figure out... by blair1q · · Score: 1

      This is not entirely true. It would be true if a moving object maintained a constant velocity. But a ball flying through the air? not so much. Though there is the a degenerate case of an object moving in a parabolic arc. That's something balls do in physics class, or on the moon, but can't do on a ballfield, owing to bernoulli, magnus, and plain ol' drag, acting through a layered, flowing, swirling, airspace on a spinning, deformed object; not to mention that a properly built field is crowned, not planar (may not be true with modern drainage systems).

      Ballplayers have sense memory, and have been learning the game their whole lives. They can tell from the sound, the condition of the air, and the visual effect of the initial flight of the ball, where it will likely end up. And even after doing this nearly their whole lives, they still guess wrong (where "right" is within an outstretched arm's length in a flying dive, with no intervening walls or railings or players) a good chunk of the time.

    51. Re:Has anyone attempted to figure out... by RightwingNutjob · · Score: 1

      Wait...so what does this have to do with flipping? Isn't this essentially asking 'Compute the number of ways the stack can be out of order?' because you can perform a bubble sort* by flipping in polynomial time on an arbitrary stack.

      If so, then isn't this the answer O(n log(n)) like any sort problem?

      *If you want to compare and/or invert the position of the kth and k+1th pancake, flip at the kth pancake, compare the top two and/or flip at N-1, then flip at k again = 4 operations per transposition/comparison.

    52. Re:Has anyone attempted to figure out... by beelsebob · · Score: 1

      Uhh, yes... The method described above does exactly that. Pancakes below some position k in the stack are already sorted, to select a new pancake at position k+n, you insert the spatula at position k+n, flip, then insert again at position k+1 and flip. No pancake below position k is moved, the pancake at position k+1 is now sorted.

    53. Re:Has anyone attempted to figure out... by Anonymous Coward · · Score: 0

      You forgot to include the complexity of the search and the flip, both would be the number of pancakes in the worst case.

      Still, that would only be cubic which is still polynomial. Either they are wrong or the summary is inadequate like maybe the pancake has to be rightside up in the final solution.

  3. Towers of Hanoi? by Tynin · · Score: 2

    Sounds like they just reworded the Towers of Hanoi puzzle, which has been around for a long time.

    1. Re:Towers of Hanoi? by AxeMurder · · Score: 2

      Not exactly, in the towers game you have 3 stacks and you rearrange the pieces by removing the top of a stack and placing it on the top of another stack. The challenge comes from the following rule: a bigger piece can never be placed above a smaller piece.

    2. Re:Towers of Hanoi? by Zaphod+The+42nd · · Score: 1

      Yeah, pretty similar. Even the pancake flipping has been around since the 80s, lots of people have taken cracks at it. The interesting thing here is the P vs NP problem, which the paper barely even mentions and does not explain whatsoever.

      --
      GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
    3. Re:Towers of Hanoi? by AnujMore · · Score: 1

      You either haven't understood the Towers of Hanoi, or this puzzle.
      Here's a link for you to read what Towers of Hanoi exactly are. https://secure.wikimedia.org/wikipedia/en/wiki/Tower_of_Hanoi

      Towers of Hanoi aims at moving a set of discs in the same order from one peg to another, and this one's just talking about sorting.

    4. Re:Towers of Hanoi? by yakatz · · Score: 3, Informative

      The difference is in where you flip. In the Towers of Hanoi, you do not flip the whole stack, you can only move the pieces one at a time between poles.
      For the pancake problem, you only have one pole and you flip as many as you want at once.
      Good explanation: http://en.wikipedia.org/wiki/Pancake_sorting

    5. Re:Towers of Hanoi? by Carewolf · · Score: 1

      I thought the same thing, but it is not that close really. The setup is very different in that the plates starts mixed, you only have one pin, but you can move a whole stack of plates in one move.

      So not the towers of Hanoi, but the comparison does make it easier for me to see why it could take an exponential number of moves.

    6. Re:Towers of Hanoi? by Anonymous Coward · · Score: 0

      Sounds like they just reworded the Towers of Hanoi puzzle, which has been around for a long time.

      Hanoi is 3 towers, move 1 disc at a time, not allowed to put a large disc on a small one. Optimal solution is well-known.

      Pancakes is 1 stack, flip as many as you want at a time, no restrictions on intermediate steps. Not so sure about optimal solution.

    7. Re:Towers of Hanoi? by Carewolf · · Score: 1

      Hmm. This actually means that if you prove this is a reworded version of the Towers of Hanoi, you would have proven N != NP.

    8. Re:Towers of Hanoi? by Opportunist · · Score: 1

      Erh... like in the Towers of Hanoi problem?

      --
      We used to have a Bill of Rights. Now, with the rights gone, all we have left is the bill.
    9. Re:Towers of Hanoi? by Anonymous Coward · · Score: 0

      Reversing a prefix of more than one element in ToH would violate the rules of ToH. Pieces can only be placed on larger pieces, so flipping a stack would place larger pieces on smaller pieces.

    10. Re:Towers of Hanoi? by nschubach · · Score: 1

      I think the difference is that there's only one tower, and I assume you can maintain the order of the pancakes in the flipping stack as long as the top pancake doesn't land on a smaller one.

      --
      Every time I start to have faith in humanity, I ruin it by driving to work between 7 and 8 am.
    11. Re:Towers of Hanoi? by ShogunTux · · Score: 1

      The most optimal one for years has been the one that Bill Gates devised, which would result in 5/3 N number of flips, but now the best solution is only 1% more optimal than his solution.

      And funnily, that's really the only known contribution that Bill Gates has done to the field of computer science, well, and a tad bit of programming in Windows 1.0 and the editions of DOS that came before that. After that, he didn't do anything anymore, or at least acknowledge that he did, since he became more occupied with managing Microsoft than coding.

    12. Re:Towers of Hanoi? by canajin56 · · Score: 1

      There's no rule about bigger on smaller. If there was it would be impossible to make even a single move, ever.

      --
      ASCII stupid question, get a stupid ANSI
    13. Re:Towers of Hanoi? by Anonymous Coward · · Score: 0

      No, you wouldn't.
      Hanoi isn't in P.

    14. Re:Towers of Hanoi? by jellomizer · · Score: 1

      The big difference successful completion doesn't cause the world to end. A big plus!

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    15. Re:Towers of Hanoi? by makubesu · · Score: 1

      I dare you to prove that the Towers of Hanoi is just a rewording of this problem. Here, I'll raise the stakes even, I'll give you a Turing Award if you do so.

    16. Re:Towers of Hanoi? by blair1q · · Score: 1

      this is nothing more than a 1-dimensional rubik's cube...

    17. Re:Towers of Hanoi? by Zaphod+The+42nd · · Score: 1

      He's not saying they're the exact same. He's saying algorithmic-ally they're similar problems, and they are. In both you are modifying a set and then recursively modifying sub-sets of that set. The logic to working both out is very similar, even if in Hanoi you have 3 posts, and in pancakes just the 1 stack. In both, you are performing an operation (a move, or a flip) on a stack of elements, but then that operation will disturb the inner state of that set, so then you have to perform additional recursive operations to restore the state of the inner subset to the set.

      Its like saying that mergesort and quicksort are similar. They are. They are also different.

      --
      GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
    18. Re:Towers of Hanoi? by Anonymous Coward · · Score: 0

      and that whole altair basic thing...

    19. Re:Towers of Hanoi? by Anonymous Coward · · Score: 0

      You're absolutely right. It's in Vietnam.

    20. Re:Towers of Hanoi? by Carewolf · · Score: 1

      We know the solution to the Towers of Hanoi is exponential and thus not polynomial, so if we can prove an NP problem to be equivalent to the Towers of Hanoi problem we know that the NP problem can not be polynomial which means NP !=P

    21. Re:Towers of Hanoi? by AnujMore · · Score: 1

      Any one who has mod points should definitely mod you up.

  4. I now understand by EmperorOfCanada · · Score: 1

    I love this problem. I have been reading about P=NP blah blah blah but never had a solid mental picture. This is great. I get it. Thanks. I wonder how many other mathematical misunderstandings could be cleared up with something as simple as pancakes?

    1. Re:I now understand by frisket · · Score: 5, Funny

      I love this problem. I have been reading about P=NP blah blah blah but never had a solid mental picture. This is great. I get it. Thanks. I wonder how many other mathematical misunderstandings could be cleared up with something as simple as pancakes?

      It's easy: P=pancakes and NP=no pancakes. When P=NP it means you ate them all. The problem is that P-NP != 0 because there's always some maple syrup left on the plate...

    2. Re:I now understand by Zaphod+The+42nd · · Score: 1

      Uh, did we read the same article? Because what I just read barely explained the pancake flipping algorithm, and that's it. If you like the pancake algorithm, that's fine, but that has almost nothing to do with P vs NP other than the fact that it is AN example of A problem. The article didn't explain how they proved it was NP-Hard, they didn't explain what P vs NP is at all, they didn't explain why P vs NP is significant...

      What exactly do you understand now that you didn't before?

      Mathematics is complicated, unfortunately that's just the nature of it, there's no shortcuts. Sometimes ideas can be better communicated through metaphor, but I think you're gotten hung up on the pancakes and as a result you're missing the forest for the trees.

      --
      GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
    3. Re:I now understand by Dunbal · · Score: 1

      Conservation of matter dictates that the pancakes are still there. Even if you ate them this just means that you moved them somewhere else (your stomach), but the pancakes do not cease to exist. Even after digestion if your stool is used as fertilizer to grow wheat for flour, corn for chickens to make eggs and grass and hay for cows to make milk, and the inorganic components are reprocessed into salt and baking soda, you can have pancakes again forever. Therefore "NP" (no pancakes) really has no meaning. Yeah, I have time to kill today.

      --
      Seven puppies were harmed during the making of this post.
    4. Re:I now understand by davidbrit2 · · Score: 1

      So if I don't use any syrup, I can eat pancakes in polynomial time? It's all starting to make sense now.

    5. Re:I now understand by dotancohen · · Score: 1

      Conservation of matter dictates that the pancakes are still there.

      You have never seen me eat pancakes. I gobble them down so fast that for every m of pancakes I eat, 1/c^2 of e is released.

      --
      It is dangerous to be right when the government is wrong.
    6. Re:I now understand by Anonymous Coward · · Score: 0

      Just because you have the ingredients to make pancakes doesn't mean you have pancakes.

    7. Re:I now understand by Anonymous Coward · · Score: 0

      That matter that made up the pancakes continues to exist, but the pancakes are gone.

      The obvious counterexample to your argument is that there's no way in hell that you'd eat a plate of "pancakes" after they've gone through someone's digestive track. Also, while we might have pancakes again in the future, there's no guarantee. Eventually people will grow tired of pancake's and long for a good waffle.

    8. Re:I now understand by rocket+rancher · · Score: 1

      Mathematics is complicated, unfortunately that's just the nature of it, there's no shortcuts. Sometimes ideas can be better communicated through metaphor, but I think you're gotten hung up on the pancakes and as a result you're missing the forest for the trees.

      Hmmm. That is an interesting take on metaphor. I was taught that metaphor is the refuge of writers whose thoughts are too fuzzy and undisciplined to be articulated in any other way. Metaphors are for communicating fuzzy ideas, not basic mathematical truths derivable from simple postulates. And no...I don't think mathematics is complicated. If it was complicated, humans couldn't do it. As my favorite author put it,

      "Anyone who cannot cope with mathematics is not fully human. At best he is a tolerable subhuman who has learned to wear shoes, bathe and not make messes in the house." Lazarus Long, Time Enough for Love (Robert A. Heinlein)

      I think anybody can do mathematics. It requires only the will to do it. That most people fail to summon the will necessary is the real issue, as Heinlein implies in his pithy aphorism. Sadly, many otherwise intelligent people I've known dismiss math as "too complicated to bother with" and end up hiring people like me to do the math for them. Sure I profit by their deficit, but I still believe that *anybody* can grasp any branch of mathematics. I was no stellar math student, but I didn't struggle to get a passing grade, either.

    9. Re:I now understand by Dunbal · · Score: 2

      long for a good waffle.

      Heresy! BURN THE UNBELIEVER!

      --
      Seven puppies were harmed during the making of this post.
    10. Re:I now understand by Anonymous Coward · · Score: 0

      I love this problem. I have been reading about P=NP blah blah blah but never had a solid mental picture. This is great. I get it. Thanks. I wonder how many other mathematical misunderstandings could be cleared up with something as simple as pancakes?

      It's easy: P=pancakes and NP=no pancakes. When P=NP it means you ate them all. The problem is that P-NP != 0 because there's always some maple syrup left on the plate...

      Whoa dude, you just proved P != NP. I am humbled by your genius.

    11. Re:I now understand by Anonymous Coward · · Score: 0

      Yeah, because clearly you didn't extract any energy out of those pancakes for your brain to use, and that whole working process to make more pancakes didn't transform any energy to non-recoverable heat. Are you a perpetual motion machine by any chance?

    12. Re:I now understand by Anonymous Coward · · Score: 0

      What exactly do you understand now that you didn't before?

      That mathematicians, like the rest of us, sometimes think about pancakes -- he now finds it much easier to relate to them.

  5. very friendly np-hard problem by Anonymous Coward · · Score: 2, Informative

    I really like this example because it is so intuitive. Its obvious at a glance that 2n is the worst things could ever get (they say 2n -6 for n >= 16) .. the real problem is, when it is easier than 2n (not from trivial already in-order sections), how do you find the optimum? :)

  6. Getting there slowly.. by RenHoek · · Score: 2

    Now if they can only explain to me what the hell 'polynomial time' is.. maybe with a bagel allegory..

    1. Re:Getting there slowly.. by Anonymous Coward · · Score: 1

      I believe that eating bagels happens in polynomial time.

      The first bagel goes down easily.
      The second bagel takes a little longer than the first.
      The third bagel takes even longer than the second.
      The fourth bagel takes a lot longer than the third.

      Each subsequent bagel will take a lot longer than the previous one.

    2. Re:Getting there slowly.. by fuzzfuzz · · Score: 1

      Very simplified stated, it means that the solution to a specific instance of the problem takes at least polynomial time to solve - i.e. there can never be an algorithm that can solve it faster. In NP the time it is Non-polynomial - i.e. it takes such a **** long time that it is not really considered feasible for n>15 or such. So if you have a specific stack of pancakes, err... I mean bagels... And want to turn all the sides without sugar downwards with the flip method from the article - it takes NP time to figure out how to do it best - also longer than polynomial time. The cool thing is that NP problems can be converted to other NP problems in polynomial time and thus if just one of them can be solved in P time that all of them cab be solved in P time (P=NP) - we just don't know how yet....

    3. Re:Getting there slowly.. by Dunbal · · Score: 1

      Fortunately you chose bagels because doughnut time seems to be pretty constant. The nth doughnut disappears just about as quickly as the first.

      --
      Seven puppies were harmed during the making of this post.
    4. Re:Getting there slowly.. by JonySuede · · Score: 1

      you might have explained exponential time with your imprecision

      polynomial time: for (n+1)/2 (also known as linear time)
      Eating one bagel takes 1 minutes;
      eating two bagels takes bagel take 1.5 minutes;
      eating three bagels takes 2.5 minutes;
      eating four bagels takes 3 minutes;
      eating ten bagels takes 5.5 minutes.

      polynomial time: for (n^3+n^2+n+1)/4
      Eating one bagel takes 1 minutes;
      eating two bagels takes bagel take 3.75 minutes;
      eating three bagels takes 10 minutes;
      eating four bagels takes 21.25 minutes;
      eating ten bagels takes 277.75 minutes.

      exponential time (in np if np!=p):for 2^(n-1)
      Eating one bagel takes 1 minutes;
      eating two bagels takes bagel take 2 minutes;
      eating three bagels takes 10 minutes;
      eating four bagels takes 21.25 minutes;
      eating ten bagels takes 512 minutes.
         

      --
      Jehovah be praised, Oracle was not selected
    5. Re:Getting there slowly.. by JonySuede · · Score: 1

      I was talking on the phone while responding
      here are the correct number:
      exponential time (in np if np!=p):for 2^(n-1)
      Eating one bagel takes 1 minutes;
      eating two bagels takes bagel take 2 minutes;
      eating three bagels takes 4 minutes;
      eating four bagels takes 8 minutes;
      eating ten bagels takes 512 minutes.

      --
      Jehovah be praised, Oracle was not selected
    6. Re:Getting there slowly.. by AlejoHausner · · Score: 1
      > The nth doughnut disappears just about as quickly as the first.

      Not if you are the only person in the room, and are eating all twelve donuts. Back when I was young and strong, I could eat a dozen donuts in one sitting, but I did slow down near the end of the box.

  7. Bill Gates did it. by Anonymous Coward · · Score: 2, Informative

    Bill Gates' only published paper gives a solution to the pancake-sorting problem. I discuss it at my blog.

    1. Re:Bill Gates did it. by rubycodez · · Score: 1

      I tried that algorithm, but my spatula blue-screened and worked work any more

    2. Re:Bill Gates did it. by melikamp · · Score: 1

      Intriguing.

    3. Re:Bill Gates did it. by orgelspieler · · Score: 2

      Great, now I have to reboot my skillet any time I want to change the temperature setting, and there are viruses in my batter.

    4. Re:Bill Gates did it. by itchythebear · · Score: 1

      The head writer for Futurama, David X Cohen, also published a paper on pancake sorting.

      --
      If what I just said sounded like a troll, it was probably just a failed attempt at humor.
    5. Re:Bill Gates did it. by NoNonAlphaCharsHere · · Score: 1

      That was WAY funnier than it got credit for.

    6. Re:Bill Gates did it. by Zaphod+The+42nd · · Score: 1

      Its pancake sorting. Everybody's done it. Its like mergesort and towers of hanoi, its one of those trivially easy to understand problems that you learn when you're getting into programming that still requires a decent bit of logic to solve. Easy to understand, not so easy to implement.

      Doesn't mean that Gates' version was optimal, and certainly doesn't say anything about P vs NP :P

      --
      GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
  8. Re:nerds by AnujMore · · Score: 1

    And what did you expect on a site that has the tagline "News for nerds, stuff that matters"?

  9. Since it comes from French scientists... by Anonymous Coward · · Score: 0

    Shouldn't it be crepe flipping?

    1. Re:Since it comes from French scientists... by Dunbal · · Score: 1

      No need to get the fucking Belgians involved in this ok? Europe is in enough trouble already.

      --
      Seven puppies were harmed during the making of this post.
    2. Re:Since it comes from French scientists... by godrik · · Score: 2

      We are French. We take Cooking seriously. Therefore, all our crepe are perfectly sized. There is no need to sort them. If they are French, they are properly sized!

      (Now, that's the theory, but it does not happen in my kitchen.)

    3. Re:Since it comes from French scientists... by jellomizer · · Score: 1

      A different type of food.

      --
      If something is so important that you feel the need to post it on the internet... It probably isn't that important.
    4. Re:Since it comes from French scientists... by Schmorgluck · · Score: 1

      Galettes flipping, even. And theres no such thing as maple syrup. Honey and apples all the way!

      --
      There's nothing like $HOME
    5. Re:Since it comes from French scientists... by Schmorgluck · · Score: 2

      And butter. How could I forget butter? I'm losing a lot of Breton creds on this one...

      --
      There's nothing like $HOME
  10. Let's get this out of the way, OK? by Anonymous Coward · · Score: 0

    We already know P = NP when N = 1 and P = 0.

    OK. Now we can discuss the article.

  11. The actual NP problem statement... by JMZero · · Score: 1

    Clarification from the article, the actual problem statement is:

    The question to be answered in both cases is, if the stack has n pancakes, what is the maximum number of flips needed as a function of n, i.e. f(n)?

    With regards to actual doing this for a specific stack, it's fairly trivial to order the pancakes in a polynomial number of flips (any n log n sort algorithm would be fine - with the actual flipping taking at most 2 flips per pancake).

    --
    Let's not stir that bag of worms...
    1. Re:The actual NP problem statement... by Millennium · · Score: 1

      The thing is, you're not swapping individual pancakes. You have to flip the entire stack above the insertion point. So if I have a stack [1,2,3,4,5,6,7,8,9] and I flip from where the 5 is, my stack is now [5,4,3,2,1,6,7,8,9], not [5,2,3,4,1,6,7,8,9].

      That's what makes it hard. If all you were doing was swapping individual pancackes around then this would be easy, but you have to move stacks of pancakes.

    2. Re:The actual NP problem statement... by JMZero · · Score: 1

      Well, there's two problems here: calculating an optimal number of flips (which I'm not sure about) and "sorting the stack with a polynomial number of flips" which is what I think is trivial (and which the summary seemed to suggest was difficult). I was just trying to clarify that this second problem is not hard (but my post itself wasn't clear).

      To further clarify, the naive algorithm for this second problem is simple and polynomial (in number of flips per pancake). Start at the bottom. If the largest pancake is not on the bottom, flip the stack starting at the largest pancake (so that the largest pancake is at the top). Now flip the whole stack. Now imagine the bottom pancake is part of the table and repeat the process. You'll flip at most twice for each pancake.

      --
      Let's not stir that bag of worms...
    3. Re:The actual NP problem statement... by Anonymous Coward · · Score: 0

      The thing is, you're not swapping individual pancakes. You have to flip the entire stack above the insertion point. So if I have a stack [1,2,3,4,5,6,7,8,9] and I flip from where the 5 is, my stack is now [5,4,3,2,1,6,7,8,9], not [5,2,3,4,1,6,7,8,9].

      That's what makes it hard. If all you were doing was swapping individual pancackes around then this would be easy, but you have to move stacks of pancakes.

      It isn't as hard as you think, watch:
      [5,4,3,2,1,6,7,8,9] - To speed this up, I'm going to ignore the ones that are already in the right place (6,7,8,9) [M=5]
      [>5<,4,3,2,1,6,7,8,9] - Search to find the biggest in the unsorted section (N=1)
      [>5<,4,3,2,1,6,7,8,9] - Flip 1->N so that pancake N is now on the top (This is an identity operation since N is 1 so is already the top)
      [1,2,3,4,>5<,6,7,8,9] - Flip 1->M so that the top pancake is now at the bottom of the unsorted section that makes up the top of the stack
      [1,2,3,>4<,5,6,7,8,9] - Find the biggest (N=4) [M=4]
      [>4<,3,2,1,5,6,7,8,9] - Flip 1->N
      [1,2,3,>4<,5,6,7,8,9] - Flip 1->M
      Rinse, repeat
      [1,2,3,4,5,6,7,8,9] - Done [N=0,M=1]

      You can improve the efficiency by skipping to the next iteration when N=M after the find biggest stage but the worst case efficiency of this approach isn't particularly good (O(n**2) I think) but is both polynomial and reasonably simple. (The paper in question is apparently discussing calculating the minimum number of flips that are absolutely necessary which IS a much harder problem)

    4. Re:The actual NP problem statement... by Unequivocal · · Score: 1

      Yay! Real content on slashdot. For all programmers here we don't see algorithms often enough. Thanks.

    5. Re:The actual NP problem statement... by Anonymous Coward · · Score: 1

      With regards to actual doing this for a specific stack, it's fairly trivial to order the pancakes in a polynomial number of flips (any n log n sort algorithm would be fine - with the actual flipping taking at most 2 flips per pancake).

      You say that; yet this article is here to prove its NOT fairly trivial to order them in polynomial operations. You only think its trivial because you've only dealt with small stacks of pancakes. There's no difference between polynomial and n log n if n=3. The difference is miniscule at n=4, and trivially easy for the human mind to comprehend at numbers up to about n=10. Just because you're very good at looking at a small stack of pancakes and solving it in a number of flips doesn't mean that process scales to large stacks pancakes - which is both the point of the article, and the definition of NP-hard problems.

    6. Re:The actual NP problem statement... by Anonymous Coward · · Score: 0

      The article also does a crap job of summarizing the paper. f(n) is by definition a function of only n, which means it is the worst-case behaviour of the best possible algorithm among all n! possible starting points (it is analogous to the "God's number" problem for a Rubik's cube which was recently shown to be 20).

      The NP-hardness result has nothing to do with calculating f(n). It would be astonishing to prove NP-hardness for a number sequence that we know so little about (I can't recall a single example of any function on integers that has been proved NP-hard aside from contrived encodings of other NP-hard problems).

      The problem that is NP-hard is, given a specific stack of pancakes, what is the precise minimum number of moves to sort it? This follows from a slightly more delicate version of the question, which roughly goes as follows. In polynomial time, it is easy to compute a certain specific lower bound for a given stack; now decide if it can actually be sorted in that number of moves.

    7. Re:The actual NP problem statement... by muridae · · Score: 1

      That gets you a polynomial number of flips, but that isn't the difficulty of the algorithm. Between each flip, you need to find the next biggest pancake, which involves comparing the size of pancakes left to each other. Those operations have to be counted when considering the O() notation for the algorithm.

    8. Re:The actual NP problem statement... by JMZero · · Score: 1

      Looking at every pancake every time would involve O(N^2) looks. That's polynomial in "looks" (N^2 is not exponential). And it's still linear in "flips".

      And this is a completely separate from problem than computing an optimal pattern for minimum number of flips (which, again, I don't know - the naive computation there would be exponential).

      --
      Let's not stir that bag of worms...
    9. Re:The actual NP problem statement... by tompaulco · · Score: 1

      The question to be answered in both cases is, if the stack has n pancakes, what is the maximum number of flips needed as a function of n, i.e. f(n)?
      Well, if you have a stack of pancakes than you need to do zero flips. If you HAD a stack of pancakes and you now have half a stack of pancakes and pancakes all over the floor, then you had to do more than zero flips, although being pancakes, it is likely that the ordering of the pancakes is only very loosely related to whether they need to be sorted.

      --
      If you are not allowed to question your government then the government has answered your question.
    10. Re:The actual NP problem statement... by JMZero · · Score: 1

      No, uh... I'm right. There's a simple algorithm to sort them in an polynomial number of flips.

      The hard part is computing an optimal set of flips (ie. not just a polynomial one, but a minimum count).

      This is exactly the distinction I was trying to make in my initial post. Solving the problem is easy. Solving the problem optimally is hard.

      --
      Let's not stir that bag of worms...
    11. Re:The actual NP problem statement... by Anonymous Coward · · Score: 0

      Agreed. It is clear that the stack of pancakes can be sorted with no more than 2n flips. Indeed, it is clear that one does not need more than one flip to sort a stack of 2 pancakes so we have a simple 2n-3 algorithm. The challenge is to find a sequence of flips of minimal length which sorts the stack. I believe this is what is being claimed as NP-hard.

    12. Re:The actual NP problem statement... by noodler · · Score: 1

      That's not a good description of the pancake flipping problem.
      The pancakes are not numbered, they can be in either of 2 states, 0 or 1.
      So you have a stack like this: [0,1,1,0,1,0,1,1,0,1,0,0]

      You can sort a stack of n pancakes in at most n times by fliping the stack (starting with the top on) so that its state matches the next one, then include the next one in the stack.

      So you get:
        [0,1,1,0,1,0,1,1,0,1,0,0]
        [1,1,1,0,1,0,1,1,0,1,0,0]
        [1,1,1,0,1,0,1,1,0,1,0,0]*
        [0,0,0,0,1,0,1,1,0,1,0,0]
        [1,1,1,1,1,0,1,1,0,1,0,0]
        [0,0,0,0,0,0,1,1,0,1,0,0]
        [1,1,1,1,1,1,1,1,0,1,0,0]
        [1,1,1,1,1,1,1,1,0,1,0,0]*
        [0,0,0,0,0,0,0,0,0,1,0,0]
        [1,1,1,1,1,1,1,1,1,1,0,0]
        [0,0,0,0,0,0,0,0,0,0,0,0]
        [0,0,0,0,0,0,0,0,0,0,0,0]*

      If you are alowed to peek at the states of the remaining pancakes without flipping you can leave out the flips with an asterisk.

  12. can we trust this story? by Anonymous Coward · · Score: 0

    any reason to think this isn't just another bogus complexity paper on the arxiv? has anyone credible verified this?

  13. Summary leaves out the fun part: by DogFacedJo · · Score: 1

    The fiddly part is that the question is what is the minimal number of flips required to sort the stack. Finding some number of flips that will sort the stack is fairly straightforward.

    1. Re:Summary leaves out the fun part: by Zaphod+The+42nd · · Score: 1

      The fiddly part is that the question is what is the minimal number of flips required to sort the stack. Finding some number of flips that will sort the stack is fairly straightforward.

      Yeah, exactly! People are completely misunderstanding and seem to think that a pancake sorting algorithm proves P = NP, which is just silly; ANY programmer worth his salt can write a pancake sorting algorithm right now trivially. Most of the comments on this page have absolutely nothing to do with computational complexity, and people are either arguing about the algorithm implementation or about syrup.

      It doesn't help that TFA barely explained anything other than the pancake sorting algorithm. I'd like to know how you can check that X is the minimum number of flips for a given N pancakes in NP time. It seems to me like in order to verify that X is indeed the minimum number, you'd have to calculate the minimum number, thus putting this in P.

      --
      GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
  14. Solution? by Erich · · Score: 3, Interesting
    I had something like this was an interview question once. My solution:

    Assume we are stacking pancakes with largest at the bottom.

    1. Find the largest unsorted pancake
    2. Flip that to the top
    3. Flip from the bottom-most unsorted pancake. (One additional pancake is now sorted)
    4. Repeat until sorted

    To me, assuming that you consider "Find the largest unsorted pancake" to be O(N), the algorithm is O(N^2). Number of flips is 2N. Where's my turing award?

    So I must be missing something... Is one not able to find the largest unsorted pancake easily? Perhaps you are only able to look at the size of the topmost pancake. The article was unclear.

    --

    -- Erich

    Slashdot reader since 1997

    1. Re:Solution? by Erich · · Score: 3, Insightful

      Oh, I see. The problem is not that pancake flipping itself is hard, that determining the optimal pancake flipping algorithm for a stack is hard. That's believable.

      --

      -- Erich

      Slashdot reader since 1997

    2. Re:Solution? by Anonymous Coward · · Score: 0

      The problem is your solution is not always optimal. The pancake flipping problem considers optimal solutions.

    3. Re:Solution? by adisakp · · Score: 1

      Oh, I see. The problem is not that pancake flipping itself is hard, that determining the optimal pancake flipping algorithm for a stack is hard. That's believable.

      Yeah... well since finding the optimal flipping solution is NP hard, you'll save time with the simple O(N^2) solution.

    4. Re:Solution? by Arlet · · Score: 1

      Not necessarily. Maybe it could take 1 billion calculations to figure out the optimal algorithm with an NP algorithm. But if a computer can do those calculations in 1 second total, while it takes you 2 seconds per flip, it's still worth it to spend all those CPU cycles.

    5. Re:Solution? by adisakp · · Score: 1

      Not necessarily. Maybe it could take 1 billion calculations to figure out the optimal algorithm with an NP algorithm. But if a computer can do those calculations in 1 second total, while it takes you 2 seconds per flip, it's still worth it to spend all those CPU cycles.

      Ummm... no... You are not only completely wrong here, you would also fail your basic comp sci exam when explaining how order of magnitude matters. In the long run as the number of pancakes in the stack gets greater, no matter how large the linear constant is, eventually NP becomes much greater than N^2.

      That's how math works and the reason why Computer Scientists drop the constants when comparing O(N) vs O(N lgN) vs O(N^2) vs O(NP). If the constant for the higher order algorithm is very small compared to the constant for the lower order algorithm, then the higher order algorithm may be faster for some small number of elements, but there is *ALWAYS* some finite tipping point in the count of elements for finite linear constants where the ORDER OF MAGNITUDE of the operation OUTWEIGHS THE LINEAR CONSTANTS and the lower order algorithm will *ALWAYS* win out as the element count approaches infinity.

    6. Re:Solution? by adisakp · · Score: 1

      In other words, you could take an hour per flip and the computer might take 1 microsecond per comparison but eventually NP grows enough faster than N^2 (for an very large stack of pancakes mind you), that those time constants for single operations don't matter.

      Now in the "real world" for hard optimizations vs comp sci, those time constants do matter. And most programmers who are concerned with performance for both small and extremely large sets simply write two versions of the functions and switch between them based on a threshold so you pick the optimal one either way (or at least close to the optimal one).

      In fact, you see this in many quicksort implementations when they get down to less than N elements (5-10) they will switch to another method that is higher order but lower linear constant. See this qsort.c source for an example.

    7. Re:Solution? by Arlet · · Score: 1

      eventually NP becomes much greater than N^2

      Sure, but you're comparing apples and oranges. The O(N^2) refers to the actual flipping time, while NP refers to the algorithm used for determining the minimum number of flips.

      Now, an interesting question is: given a certain time per computation, and a certain time per actual flip, what is the total time you'd need to sort the stack, and does this approach O(N^2) for large enough N ?

    8. Re:Solution? by blair1q · · Score: 1

      That's the longest way to do it.

      Is there a way to do it by flipping to intermediate states such that the next few flips get you to the solution faster than the longest way?

      Oh, and how did you solve the problem of finding the largest unsorted pancake on O(1) time? The fastest my computer can do it is O(n)...

    9. Re:Solution? by adisakp · · Score: 1

      Sure, but you're comparing apples and oranges. The O(N^2) refers to the actual flipping time, while NP refers to the algorithm used for determining the minimum number of flips.

      Wrong again. Sorry but that's the second basic comp sci "quiz" question you've flunked in a row. Have you actually taken an algorithms class where you determine order of magnitude and how that affects optimization?

      It can be TRIVIALLY shown by using a simple "selection sort" of flipping to largest unsorted pancake to the top and then flipping that pancake down to the next sort position that the maximum number of flips required is only 2N. The reason the algorthim is O(N^2) is for the comparison work (non flipping): presumably, you go through all the unsorted pancakes in the stack between each flip O(N) to find the next largest one. So your flip time is actually only O(N) but you need to multiply by the compare time O(N) to get a final magnitude of O(N^2).

      And still it doesn't matter if the NP refers to the amount of time to determine the flips. Eventually there is some number of elements (as the element count grows) at which it goes so much slower that it vastly outweighs the flipping time.

    10. Re:Solution? by Zaphod+The+42nd · · Score: 1

      Where's my turing award?

      You've got a long, long way to go.

      --
      GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
    11. Re:Solution? by Arlet · · Score: 1

      Eventually there is some number of elements (as the element count grows) at which it goes so much slower that it vastly outweighs the flipping time.

      First of all, you never mentioned that "for sufficiently big N" in your first post.

      Secondly, finding a solution that requires a maximum of 2N flips can be done with O(N*log N) comparisons, not O(N^2).

      Thirdly, for N sufficiently big that O(N*log N) comparisons on a computer takes more time than O(N) actual flips, you need have such a large stack of pancakes, that the flipping time can no longer be considered O(1).

      Maybe you should spend some more time on the problem, and a little less effort on patronizing.

    12. Re:Solution? by snowgirl · · Score: 1

      First of all, you never mentioned that "for sufficiently big N" in your first post.

      That's automatically implied when dealing with Big-O notation.

      Secondly, finding a solution that requires a maximum of 2N flips can be done with O(N*log N) comparisons, not O(N^2).

      O(N*log N) comparisons? I think you're getting confused here, because one can only find the largest element in an unsorted list in O(N) time. The algorithm originally described is essentially a copy of nearly every O(N^2) algorithm. "Find the largest, put it at the end, sort the rest using this algorithm."

      Thirdly, for N sufficiently big that O(N*log N) comparisons on a computer takes more time than O(N) actual flips, you need have such a large stack of pancakes, that the flipping time can no longer be considered O(1).

      Let's assume that the flipping time is not O(1), because it's not. Flipping a list is a relatively straight-forward operation of swapping the first and last element, then flipping the string inside, until the first and last element are either the same, or cross. This takes 1/2 * N operations. Thus, the operation is O(N). But wait, the "find the largest element" operation was O(N) as well, so we have O(N * (N + N)) which is.... O(N^2).

      Maybe you should spend some more time on the problem, and a little less effort on patronizing.

      I think he did. The algorithm as originally described is O(N^2), and everything he's talking about lines up properly. Meanwhile, you seem to be misusing terminology, and confusing matters. I have to ask, did you take an algorithms course, or did you just read about Big-O notation on Wikipedia?

      --
      WARNING! This girl exceeds the MAXIMUM SAFE standards established by the FDA for BRATTINESS
    13. Re:Solution? by snowgirl · · Score: 1

      Oh, and how did you solve the problem of finding the largest unsorted pancake on O(1) time? The fastest my computer can do it is O(n)...

      Um.... you're confusing me, because the OP posted:

      To me, assuming that you consider "Find the largest unsorted pancake" to be O(N)

      --
      WARNING! This girl exceeds the MAXIMUM SAFE standards established by the FDA for BRATTINESS
    14. Re:Solution? by blair1q · · Score: 1

      Oops. Skimmed right over that...

    15. Re:Solution? by Anonymous Coward · · Score: 0

      I went through exactly the same thought process; the original article title is misleading, and the slashdot summary makes it worse. It should be "*Optimal* Pancake Flipping is Hard".

    16. Re:Solution? by adisakp · · Score: 1

      Thanks SnowGirl for showing me there are actually other intelligent people who read Slashdot and who understand Mathematics as they apply to Computer Science. If this guy actually graduated Comp Sci, then sadly his school failed to teach him :-(

    17. Re:Solution? by adisakp · · Score: 1

      I have worked on optimizing computer algorithms for over 20 years. I'm going to assume that you are just a troll since you have made extremely obvious novice mistakes in your mathematics in every post so far that even a first or second year computer science student should be able to avoid.

  15. Important Distinction by Anonymous Coward · · Score: 1

    It's worth noting that sorting the pancakes in polynomial time is easy.

    From wikipedia: "The simplest pancake sorting algorithm requires at most 2n - 3 flips. In this algorithm, a variation of selection sort, we bring the largest pancake not yet sorted to the top with one flip, and then take it down to its final position with one more, then repeat this for the remaining pancakes."

    It's computing the optimal sequence of flips in polynomial time for any given stack of pancakes that's NP-Hard.

    1. Re:Important Distinction by Zaphod+The+42nd · · Score: 1

      It is simply blowing my mind how many people do not get this. I thought /. was full of programmers and computer scientists? Guess not. Jeepers.

      Doesn't help that TFA barely said ANYTHING about P vs NP at all, pretty much just said "hey guys, pancake algorithm is cool, read a description! Oh yeah, and some scientists somewhere proved something about this. Don't worry about that part."

      --
      GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
  16. This just in by Zaphod+The+42nd · · Score: 1

    There is a pancake flipping algorithm. Have you heard of it?

    Seriously, pancake flipping has been around forever. Seriously, its one of the few algorithms that even Bill Gates has implemented: http://en.wikipedia.org/wiki/Pancake_sorting#History And apparently the co-creator of Futurama has as well.

    TFA mentions that they proved pancake flipping was NP-Hard. Cool. THATS IT. It doesn't explain how they got to this conclusion, it doesn't explain the significance, it doesn't extrapolate anything useful...

    Cool story bro.

    --
    GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
    1. Re:This just in by Anonymous Coward · · Score: 0

      Not the mention the obnoxious amount of space reversed for ads

  17. Simple algorithm by Anonymous Coward · · Score: 0

    Am I missing something? Not only is this solvable in polynomial time, it's a trivial polynomial.

    Building your stack up from bottom to top, you use the following algorithm:

    1. Any time all the pancakes on the bottom are in the correct position, you never touch them again. Consider the "stack" to start just above the highest pancake that's in the correct position.

    2. Any time the pancake that would otherwise go in the next position on the stack is at the top, you flip the entire stack (excluding, of course, all the ones from #1 above).

    3. In all other cases, insert your spatula just below the pancake that should go next on the stack, flip that much of the stack, which puts it at the top, reducing this problem to #2 above.

    Bonus: If you want your pancakes burnt-side down, when you get to step 2, if it's already burnt-side down, flip only the top pancake before proceeding.

    So at maximum it takes 2 operations to move a pancake into position. One to put it at the top, one to flip the stack. In other words, the maximum number of operations is 2*N. For the burnt-side-down variation, 3*N.

    What am I doing wrong here?

    1. Re:Simple algorithm by Anonymous Coward · · Score: 0

      SNIP

      So at maximum it takes 2 operations to move a pancake into position. One to put it at the top, one to flip the stack. In other words, the maximum number of operations is 2*N. For the burnt-side-down variation, 3*N.

      What am I doing wrong here?

      You are correct when looking at one pancake in a stack. However all you have done with the simple multiplication is establish an upper bound on the number of flips required. You would never encounter a stack actually requiring this number of flips. What is the REAL maximum required number of flips?

  18. Re:nerds by Dunbal · · Score: 1

    That tag line has been gone for a few months. Just FYI.

    --
    Seven puppies were harmed during the making of this post.
  19. Incorrect postulation? by fey000 · · Score: 2

    There seems to be a miscommunication here. You can prove that P = NP only if you can solve an NP-complete problem in polynomial time (or some other type that can be reduced to every other problem in the set). The article refers to NP-hard, which is not necessarily in the NPC set. Thus, solving the pancakes problem in polynomial time only guarantees that P = NP for the pancake problem (again, unless you can reduce it to every other problem).

    1. Re:Incorrect postulation? by canajin56 · · Score: 2

      NP-Hard means it can be used to solve any NP-Complete problem. Not the opposite of that, like you seem to think...

      --
      ASCII stupid question, get a stupid ANSI
    2. Re:Incorrect postulation? by Anonymous Coward · · Score: 0

      *sigh* No, if any problem in NP-hard can be solved in polynomial time, P = NP.

      Why are computational complexity pedants always wrong?

    3. Re:Incorrect postulation? by Anonymous Coward · · Score: 0

      You don't have to reduce it to *every* other problem in NP, just one. Once it's reduced to that one, it can be reduced to all others.

    4. Re:Incorrect postulation? by Anonymous Coward · · Score: 1

      A little knowledge is a dangerous thing? You are clearly confused about factoids you have read about or maybe heard in class, and both your logic and terminology are very muddled and somewhat backwards. For starters, you write "P = NP [only] for the pancake problem". What exactly do you mean by "NP for the pancake problem" as distinct from NP itself?

      "Pancake problem is NP-hard" literally means "every problem in NP can be reduced to solving pancake problem". Therefore, despite some very poor choice of wording, the submission is correct on this point. NP-complete simply means both NP-hard and "NP-easy" (a whimsical way of saying "belonging to NP").

      Very often (in practice) this distinction is rather inconsequential: typically an NP-hardness result can be trivially reformulated as an NP-completeness result (but there are interesting exceptions such as the art gallery problem where it is not obvious that one can select suitable guards with only a polynomial level of precision). The pancake problem is easily equivalent (hint: binary search) to the following decision problem which is obviously in NP (hence NP-complete rather than just NP-hard):

      Given a stack of pancakes S and a fixed budget of k flips, is it possible to pancake-sort S in at most k flips?

    5. Re:Incorrect postulation? by blair1q · · Score: 1

      Since the easiest pancake-flipping solution is polynomial (not just polynomial, but the simplest "poly" nomial, O(n^2)), then I'm not sure the postulators knew what the fuck they were talking about...

    6. Re:Incorrect postulation? by Anonymous Coward · · Score: 0

      A polynomial-time solution to any NP-hard problem would show that P=NP. The idea of showing P=NP only for some problem is meaningless: P and NP are classes of problems. It would also (trivially) show that the NP-hard problem in question is in P, and in NP, and is NP-complete. It wouldn't show that any other NP-hard problem is in P, unless it were also known to be in NP.

      In this case, however, it's so easy to show that pancake flipping is in NP that it's barely worth mentioning: simply use the verifier-based definition of NP, in which case a sequence of flips with fewer than k moves (which is clearly polynomial length) is an obvious witness to the question "is there a solution to this instance in fewer than k moves", which is the correct formal statement of the problem.

    7. Re:Incorrect postulation? by Anonymous Coward · · Score: 0

      And I know, I screwed up the question. The researchers actually consider the decision problem "is there a solution in fewer than k moves for ALL stacks of size n". It's not immediately obvious how to show whether that one is in NP, although my first paragraph still holds: a polynomial-time answer would immediately show it's in NP.

    8. Re:Incorrect postulation? by Anonymous Coward · · Score: 0

      If P != NP then NP-hard problems have no poly-time solutions, therefore if any NP-hard problem has a poly-time solution P=NP.

    9. Re:Incorrect postulation? by Anonymous Coward · · Score: 0

      Quick tutorial:

      A problem A is in...
      1. NP-Easy, if proving P=NP implies that there is a polynomial-time algorithm for A.
      2. NP-Hard, if finding a polynomial-time algorithm for A implies that P=NP.
      3. NP-Complete, if it's both NP-Easy and NP-Hard.

  20. You burned it! by Anonymous Coward · · Score: 0

    The problem described in the summary is easy: In each step flip to bring the largest pancake that has smaller ones below it to the top and then flip once more to put it to its final position. The problem that TFA claims is NP-Hard is a variant of the above, where all the pancakes are burned on one side and you have to finish the sort with all the burned sides face down.

  21. Re:nerds by Anonymous Coward · · Score: 0

    You must be new here

  22. Flipping pancakes? PAH, away with you. by Anonymous Coward · · Score: 0

    Real men have 2 frying pans and just empty the pancake in to the other one by roofing the first pan with the second, then turning them around.

    We'll be having none o' that fancy flipping stuff in my house, they are as bad as birds being all flying and defying gravity, IT'S NOT NORMAL.

  23. Re:nerds by need4mospd · · Score: 1

    It's still there for me? go to slashdot.org, see browser tab heading

  24. Re:nerds by Dunbal · · Score: 1

    Oh yeah you're right. But it used to say "News for nerds, stuff that matters" under "Slashdot" in the top left corner. That's gone.

    --
    Seven puppies were harmed during the making of this post.
  25. more important question by tverbeek · · Score: 1

    The more important question is knowing when to flip the pancake.

    --
    http://alternatives.rzero.com/
    1. Re:more important question by Arlet · · Score: 1

      That's easy. You flip the pancake when the top is just dry enough to allow flipping without making a mess.

      The more important question is knowing what temperature the skillet should be.

  26. Link to the paper by Anonymous Coward · · Score: 1
  27. Re:nerds by AnujMore · · Score: 1

    You must be new here too.
    A slashdotter would know where to search for the UIDs and what would 7 digit UIDs would mean.

  28. This just in!!! by cayenne8 · · Score: 1
    This just in....

    From the Pancake Institute: "Fuck Waffles"

    --
    Light travels faster than sound. This is why some people appear bright until you hear them speak.........
    1. Re:This just in!!! by somersault · · Score: 1

      Even blue waffles?

      --
      which is totally what she said
  29. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  30. Re:This can't be right... by Arlet · · Score: 1

    The hard part is finding the optimal solution with the fewest number of flips.

  31. Comment removed by account_deleted · · Score: 2

    Comment removed based on user account deletion

  32. Mod parent up by gr8_phk · · Score: 1

    The simplest pancake sorting algorithm requires at most 2n - 3 flips

    That was my first thought. It took a bit to realize the problem is not sorting the pancakes, but finding the optimal sequence of flips to sort the pancakes.

    1. Re:Mod parent up by Zaphod+The+42nd · · Score: 1

      It took a bit to realize the problem is not sorting the pancakes, but finding the optimal sequence of flips to sort the pancakes.

      If a trivially easy algorithm would win you the Millennium Prize, odds are you're not understanding the problem. We're talking about millions of dollars and world record status. If any first year CS 101 student could solve this, THEY WOULD HAVE. This stuff is cutting-edge science for a reason; its REALLY COMPLICATED. I don't get why this is so shocking -__- wow.

      --
      GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
  33. Re: what you're missing by Anonymous Coward · · Score: 1

    You need to think in terms of "what's the fewest number of flips required for any possible permutation of size n."

    (Hint: The problem is hard because there are n! permutations.)

    p.s. I'm still half-asleep, so I haven't completely convinced myself that the correct decision problem at hand isn't Sigma-2 (aka NP^NP, or ExAy F(x,y)) or Pi-2 (aka Co-NP^NP, or AxEy F(x,y)) rather than Sigma-1 (aka NP, or Ex F(x)). Will someone please take a stab at writing the decision problem? Right now the best I can come up with is: "Is there a permutation of size n that cannot be sorted with at least k <= O(n) flips?", and that's clearly Sigma-2 (exists permutation such that for all re-orderings of size <= k, reordering is not sorted). I know I'm missing something obvious here...

  34. Who Does This? by Baby+Duck · · Score: 1

    Who sorts pancakes? Why is there any need to flip pancakes already in a stack? Who jams their spatula into the middle of the stack? WHAT?!

    --

    "Love heals scars love left." -- Henry Rollins

    1. Re:Who Does This? by Arlet · · Score: 1

      Nerds do. Feel free to turn in your membership card.

  35. Fine fine fine by SmallFurryCreature · · Score: 1

    I know I really shouldn't read slashdot when half drunk and blurry eyed but fine, I will take your advice and in future get my maple syrup from Canadians. Anyone got a large press for sale? Funny, I always thought it came from trees but then that was before I learned about the duck press.

    --

    MMO Quests are like orgasms:

    You may solo them, I prefer them in a group.

  36. It's HBO! by tepples · · Score: 1

    Beetlejuice was distributed by Warner Bros., which got bought by HBO's parent company shortly after the film was released. CBS owns Showtime. So wouldn't the product placement be HBO this time?

  37. Re:This can't be right... by Zaphod+The+42nd · · Score: 1

    The entire article should be thrown out, it doesn't say anything useful at all.

    Also, if you thought that ANY solution of pancake flipping would win you a million dollars, you need to have your head examined. The problem obviously has more to it than that.

    --
    GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
  38. Re:This can't be right... by Zaphod+The+42nd · · Score: 1

    Re-reading the summary, you're right, its extremely misleading. Lets toss out the summary AND the article! Bad /., bad!

    --
    GCS/MU/P d- s:- a-- C++++$ UL++ P+ L++ E+ W++ N o K- w--- O M+ V- PS+++ PE Y+ PGP t+ 5- X R++ tv+ b++ DI++ D++ G+ e++ h-
  39. Try Again by Baby+Duck · · Score: 1

    Explanation denied. I've sat at many a nerd table at IHOP. They were never armed with a spatula and they never sorted any damn pancakes.

    --

    "Love heals scars love left." -- Henry Rollins

    1. Re:Try Again by Arlet · · Score: 1

      Ah, your pancakes were probably all similarly sized, seeing that you ordered them at a professional facility.

      The sorting problem (and especially the variation with burned pancakes) is more typical for nerds who attempt to bake their own.

    2. Re:Try Again by Anonymous Coward · · Score: 0

      When nerds try to make pancakes, you end up with an upper limit of n at around 5 and a whole lot of "you call that a pancake!".

  40. Comment removed by account_deleted · · Score: 1

    Comment removed based on user account deletion

  41. Brush with fame by Anonymous Coward · · Score: 0

    Reference 6 in the paper refers to work by Futurama creator David X Cohen (David S Cohen at the time of the publication). As noted in the Wikipedia article about Dave, his most notable publication was on pancake flipping, although Dave's work related to the burnt pancake problem in which the pancakes are to be flipped so all the burnt sides face down. Dave is also a personal friend of mine and so my own brush with fame. I will suggest that Bender flip some pancakes in honor of this paper. I am sure Dave will quietly ignore the suggestion, since he is quite polite.

  42. Pancakes! by Anonymous Coward · · Score: 0

    Pancake flipping problems have been around for a while. The book "Programming Challenges" features one, and notes amusingly that pancake flipping was the subject of Bill Gates' one research paper while he was in school. (It's pretty easy to find on Google.)

  43. Nobody yet ? by Anonymous Coward · · Score: 0

    The most amazing fact about pancake flipping related problems is: Who was one of the pioneers in that domain with a 1978 paper ? Ok, don't tell me that you are reading slashdot and don't know the answer.