A Programmer’s Explanation to Inception


Spoiler Alert

void main(){
   static int totem = 12345;
   int level = 0;
   int task = 45678;
   int returnTotem = dreamSequence(task);

   if (totem == returnTotem)
        printf("you are real");
   else{
       printf("Stuck in limbo");
       while(true);
   }
}

int dreamSequence(unsigned int number) {
     int totem = 12345;
     level++;
     int taskCompleted = 0;

    // Task Processing
   // Time Spent in function = f(t,level)

    if( taskCompleted)
         return totem;
     return dreamSequence(task);
}
Share and Enjoy:
  • Print
  • Digg
  • del.icio.us
  • Facebook
  • Google Bookmarks
  • email
  • Netvibes
  • Twitter

,

  • Kinnari Savani

    Veetrag, this one is superb!! Very much expected from an software engineer's mind. Yesterday, Nirav was discussing with one friend about 'recursion'(dream inside dream) and 'break'(kick) in this film :)

  • http://thejeshgn.com Thejesh GN

    There should be a like button for posts :)
    +1

  • http://repeatgeek.com/technical/how-to-view-inception-through-code/ How To View Inception Through Code

    [...] A Programmer’s Explanation to Inception [...]

  • Ruturajmd

    The totem in the dream and real life are same here in your program. I think they should be different, else they would beat the purpose. Only thing I can think of is a guard variable, like used in buffer over flow attacks, which might try to simulate the exact relevance of the totem. the probable implementation might in fact be tricky!

  • Ruturajmd

    The totem in the dream and real life are same here in your program. I think they should be different, else they would beat the purpose. Only thing I can think of is a guard variable, like used in buffer over flow attacks, which might try to simulate the exact relevance of the totem. the probable implementation might in fact be tricky!

  • http://www.knotheory.com TH

    My take of plot summary in psuedo code ;)

    enterDream(inception) { inception = embed(inception); if(!inception.success() && !inception.wifeDead && inception.teamSize() > 1) {enterDream(inception);}}