Solving algorithm for a simple problem

Posted by maolo on Stack Overflow See other posts from Stack Overflow or by maolo
Published on 2010-04-03T23:11:16Z Indexed on 2010/04/03 23:13 UTC
Read the original article Hit count: 150

Filed under:
|

I'm searching for an algorithm (should be rather simple for you guys) that does nothing but solve the chicken or the egg problem.

I need to implement this in C++. What I've got so far is:

enum ChickenOrEgg
{
  Chicken, Egg
};

ChickenOrEgg WhatWasFirst( )
{
 ChickenOrEgg ret;
 // magic happens here
 return ret;
}

// testing
#include <iostream>
using namespace std;
if ( WhatWasFirst( ) == Chicken )
{
   cout << "The chicken was first.";
} else {
   cout << "The egg was first.";
}
cout << endl;

Question:

  • How could the pseudocode for the solving function look?

Notes:

  • This is not a joke, not even a bad one.
  • Before you close this, think of why this isn't a perfectly valid question according to the SO rules.
  • If someone here can actually implement an algorithm solving the problem he gets $500 in cookies from me (that's a hell lot of cookies!).
  • Please don't tell me that this is my homework, what teacher would ever give his students homework like that?

© Stack Overflow or respective owner

Related posts about c++

Related posts about chickenegg