Sunday, August 01, 2010

Inception via recursion.

If you had no clue what the movie was all about, below is a simplified complicated explanation in Java that you probably will have no clue about unless you are an engineer and a geek !


public static void main(String[] args) {
int initialDreamLength = 300; // 5 minutes
boolean success = Inception(teamSize, initialDreamLength);
}

public boolean Inception(int noOfPeopleLeft, int timeLeft){
timeLeft = timeLeft * 12 ;
while(timeLeft > 0){
if(ideaImplanted)
return true;

if(subjectRealizesHeIsInADream)
return false;

if(noOfPeopleLeft <= 1)
return false;

if(personDies)
noOfPeopleLeft--;

if(sharingADream)
return Inception(noOfPeopleLeft - 1, timeLeft);

timeLeft--;
}
// Time's up !
return false;
}

No comments: