Wednesday, August 7, 2013

CodeVita Process Pseudo-code

The CodeVita 2013 Process Pseudo-code


package energy.efficiency.effectiveness.tcscodevita

import lots.of.Enthusiasm
import honour.code
import team.work

public class TCSCodeVita {
 String CT_DT_ReferenceNum;
 String emailID;
 String secretCode;
 boolean isRegistrationSuccessful = false;
 protected String getReferenceNum(){
      CT_DT_ReferenceNum = registerTo("https://tcs.nextstep.com");
      return CT_DT_ReferenceNum;
 }

public boolean registerForCodeVita(){
  if(today.date > '22-July-2013' && today.date < '10-Aug-2013'){
   loginTo("https://tcs.nextstep.com");
   if(null != CT_DT_ReferenceNum){
        submitSelfDetails(emailID); // choose role - {team lead or team member}
        if(you.chose("team_lead")){
            invitePartner();
            makePartnerRegister(); // call to external system
       }else if(you.chose("team_member")){
           while(!inviteReceived){
               waitForInviteFromPartner();
               shakeUpWakeUpPartner(); // call to external system
           }
       }
       secretCode = waitForSecretCodeToBeDeliveredToCampusCommuneInbox();
       secretCode.doNotShareWithPartner = true;
       if(secretCode.received){
            return (isRegistrationSuccessful = true);
       }else{
           return (isRegistrationSuccessful = false);
       }    
   }else{
        this.CT_DT_ReferenceNum = getReferenceNum();
       registerForCodeVita();
    } // End of RefNum check
  } // End of timeline
}  // End of method


public void doPractice(){

  if(isRegistrationSuccessful){
   loginTo("https://tcscodevita.com", CT_DT_ReferenceNum, emailID, secretCode);
   readContestRules();
   acceptContestRules();
   setMyNotifications(); // highly recommended
   Timestamp contestStartTime = startContest();

  while((now()-contestStartTime) < "6:00 hrs"){
    solution = solveProblemsInAnySupportedLanguage(useFavouriteIDE);
    int Status = solution.submit();
    String statusMessage = "";
    switch (Status) {
  case TLE:  statusMessage = "Optimize run-time ofyour program.";
                     break;
  case MLE:  statusMessage = "Reduce memory footprint of your program"
                     break;
  case WA:  statusMessage = "Some Test Cases are failing. Take a closer look at your program";
                    break;
  case RTE:  statusMessage = "Catch-All error message. Program did something, it shouldnt have.";
                    break;
  case CTE:  statusMessage = "Compile-time error. Using the same compiler as CodeVita systems?";
                    break;
case PE:       statusMessage = "Presentation Error. Dont worry. Will get full credits for this solution." +               
                      "Go solve another problem."; 
                     break;
case ACC:   statusMessage = "Good Job, Champ! Go solve another problem.";
                    break;
default:        statusMessage = "No defaults";
                    break;
    }
    System.out.println(statusMessage);
    }
   }

   validateBrowserSettings();
   validateNetworkSettings();
   validateCompilerSettings();
  
  if(tomm < "11th Aug 2013"){
    if(interested){
     comeBackTommorrow();
     practiceForAnotherSixHrs();
    }
   }
  }
 }


 public void firstRound(String dateOfContest){
  String startTime = "9 AM on " + dateOfContest;
  String endTime  = "9 AM on " + (dateOfContest+1); // next day
  String loginTime = loginAnyTimeBetween(startTime,endTime);
  if(endTime - loginTime > "6 hrs")
  {
   System.out.println("You get your allotted quota of 6 hrs");
  }else{
   System.out.println("You get " + (endTime - loginTime) + " time for your tests.");
  }
 }

 public boolean waitForResults(String resultsDate){
  boolean yourTeamMadeItToNextRound = false;
  int rank = resultTable.lookup(CT_DT_ReferenceNum);
  if(resultDate.equals(17th Aug 2013")){
   if(rank < 301){
    yourTeamMadeItToNextRound = true;
   }
  }else if(resultDate.equals(24th Aug 2013")){
   if(rank < 11){
    yourTeamMadeItToNextRound = true;
   }
  }  
  return yourTeamMadeItToNextRound;
 }


 public boolean GrandFinale(String grandFinaleDate){
  boolean hadFun = false;
  travelToTCSOfficeForFinale();
  compete();
  if(win || lose){
   hadFun = true;
  }if(absent || couldNotMakeIt){
   hadFun = false;
  }
  return  hadFun; 
 }


 public static void main(String args[]){
  TCSCodeVita codevita = new TCSCodeVita();
  codevita.registerForCodeVita();
  codevita.doPractice();
  if(needMotivation||likeReading==true)
  {
   visit("codevita.blogspot.com");
   visit("campus commune");
  }
  codevita.firstRound("13th  Aug  2013");  //  starts  9 AM  13th  Aug,  finishes  9  AM  14th  Aug  2013.  Individual
session duration is 6 hrs.
  codevita.waitForResults("17th Aug 2013");
  codevita.secondRound("20th Aug 2013");
  codevita.waitForResults("24th Aug 2013");
  codevita.GrandFinale("3rd Sep 2013");

 if(rank<4)
  {
   for(int i=1;i<4;i++)
   {
    winExcitingPrize(i);
   }
  }
 }
}

Disclaimer: -  This is meant to be a fun way of disclosing CodeVita process of participating in 2013 event. The pseudo-code in no way overrides or overrules formal communications received from official sources. The above is purely for entertainment purposes.

9 comments:

  1. How to comprehend the messages the system gives after submission? Some are obvious, like "Reduce memory footprint" but what about "Almost there, think more"? Does it mean the solution is failing for some test cases?

    ReplyDelete
  2. if remark says presentation error....what does this mean program is accepted or not?

    ReplyDelete
  3. @Aman:"Almost there.think more?" is given when your solution miss some testcases.

    ReplyDelete
  4. @Viswa : Presentation error is shown when submitted solution is passing all test cases but not adhering output format.

    ReplyDelete
  5. so will mam we get full marks for that in main contest ???

    ReplyDelete
  6. @prabhu :Presentation Error is because of mismatch of white spaces with accepted solution.This error will be treated equivalent to "accepted" remark. You can jump to next problem once you get this kind of error.

    ReplyDelete
  7. Hi ! I am getting "Reduce memory footprints of your program" in my java program....Now what can I do to remove this error???

    ReplyDelete
  8. will we get any kind of credits for almost there ?

    ReplyDelete
  9. The code is pretty nice, but gives compilation error!

    ReplyDelete