Saturday, February 20, 2010

The Ultimate Wedding-Attendance Algorithm

Most of us in our age group have been attending friends' or colleague's marriages since sometime now and will have lot of marriages to attend in the near future too. And we are always faced with the dilemma of whether its worth the effort to attend the wedding or not. Like we recently attended a friend's wedding at the far end of the town and by the end of it were left high and dry (I am clearly assuming that 'friend' is too busy enjoying the early fruits of marital bliss to read this post). So as my friend and guru revered Rashmi Mata put it, few factors come into play when deciding whether to attend a wedding. I went ahead and developed a full fledged algorithm for the same: The Ultimate Wedding-Attendance Algorithm.

The basic concept of the algorithm is simple. Its the mind-boggling permutations and combinatorial possibilities of all the factors that makes it difficult to understand and implement than,say the P vs NP Problem. Lets cut out the talk and dive straight in :

/****************Variables****************/
/* global Variables */

you_are_married = 0
// Looks pleasant as long as it is 0.You will know why this is required as we go along

/* Level 0 variables : The most powerful ones. Any of these, if set, override all the other factors and leave you with little choice but to attend the wedding. Carefully set them to zero at the start or face the dire consequences */

is_a_close_relative = 0   
is_a_close_friend = 0
is_your_manager = 0 

/* Level 1 variables : Little less powerful but have more weightage than level 2,3 */

you_are_alive = 1
/* Means you are a ghost and not visible to anyone. Its a good situation to be in when you think about it, coz then you don't have to hide all your way to the stage to escape from aunties who will cast their blood-draining hold on your cheek and tug at it till your "Holy #$%#$% mother of Jesus" agony-filled shriek fills the hall. They would still they not let you go unless you agree to their "Its you next, babbby". Again be careful with this parameter else your life can become a paradox and then self-destruct  */

you_are_zombie = 0
/*Tricky business this, being a zombie. Not that anyone will be idle enough to differentiate between a human and a zombie in an Indian wedding setting(except the  prying elderly aunties, of course and your socially challenged & utterly clueless geek friends ,which you will have if you are an IT Professional like me ). Still its advisable to exercise caution  when you finally get on the dais that you don't bite off the girl's hand or something when she tries to shake your hand. Remember : Subtlety is a virtue of great value */

/* I hope there is no confusion wrt to Level 0 & Level 1 till now. Just as an example, if its your manager's wedding , you WILL attend the wedding regardless of whether your a ghost or a zombie */

you_are_seriously_not_well_or_injured = 0
// My parameter names are self-explanatory   ;)
you_are_giving_an_excuse_of_not_being_well = 0 // Very useful but to be used with caution
wedding_out_of_town = 0

/* Level 2 variables Also called Rash's params named after my friend who originally came up with this idea. Obviously the names will be the same as she quoted. You will learn the resourcefulness of these variables once we reach the algo */

venue_is_far_far = 0
date_is_a_wiikday = 0 // weekday
have_attended_your_wedding = 0
/* the bride or the groom have attended your wedding. Applicable only if  the global variable you_are_married = 1 */


/*Level 3  variables */

pretty_girls_expected = 1
/*Always set to default value 1,being the eternal hopeful. This clearly has the  potential to be at Level 0, but by precisely  measuring the inherent ambiguity of the variable and the fatal effects it could have if given overriding powers, I had to place it at a safe Level 3 where it can do little harm to the individual's brain */

great_food_expected = 1 // Another ambiguous param , which can play with your mind and affect your body

relative_or_colleague_has_been_a_pain_in_the_ass = 0
/*Ethics force you to set it to zero by default. A powerful and volatile variable which can even override "is_a_close_relative" (a Level 0) depending on the situation */


/****************Algorithm****************/

/*Let me be clear when I say I will only be presenting a part of the algo here because the entire algorithm is so complex with its interplay of variables that it will eventually be a lost cause for the ordinary layman for whom its actually made. I will be very happy to share the entire algo with anyone who is interested. Also I have decided to make it open source so anyone can edit or improvise the same.*/

/* I am not going to use Level 0 variables here. Extreme caution is advised while using them. Dont  them unless compulsary */

/*Combination of Level 1 & Level 2*/
if (you_are_zombie == 1 && venue_is_far_far == 1)
/* A special case. If you are a zombie and you have to travel far,
 you would reach months after the wedding considering how fast
zombies walk or the probability of a zombie hitch-hiking */
   {                                                                         
        chill_at_home_and_munch_on_man-wiches()  // like sand-wiches ;)
   }

/*All Level 2*/
if (venue_is_far_far && date_is_a_wiikday)
// Remember its a conditional AND. so all the conditions need to be satisfied
{
     set you_are_giving_an_excuse_of_not_being_well = 1
     go_home_from_office()
}

/*all Level 3*/
if (pretty_girls_expected == 1 || relative_has_been_a_pain_in_the_ass == 0 )
/* Though both are Level 3, considering its a conditional OR
and assuming the if condition is evaluated from L to R,
the control enters the if loop as soon as pretty_girls_expected = 1 regardless of whether the relative has been a pain
in the ass or not */

     go_have_a_blast_ogling()
}

/* As you can see , lot of scenarios in the algo are special cases and hence code reusabilty cannot be a factor. I will not bore you with more code (i know its already a lot :P) Hope it helps you de-clutter your mind on the subject and consequently guarantee more attendance at your wedding too. Hasta la vista!*/

14 comments:

  1. hey cool post..though the zombie part was a lil over the top :P
    btw didnt understand this condition (...date_is_a_wiikday && date_is_a_wiikday)... was this by mistake? :P
    btw some grammer mistakes also which i didnt wanna point out :D :D

    guess some day we'll implement this program also. :D

    ReplyDelete
  2. very useful post... if u release the complete one...i think its gonna be the most rigorously used algo ever... thanks for ur kindness to the humanity by making it open source :p

    ReplyDelete
  3. Pretty post I must say. I agree with justsam, post it full if you can :D . Its already complex the way it is. That's a nice topic you touched upon - Wedding attendance. Gotta post my feelings on that sometime. I have had some very very bad experieneces mate.

    Btw, just wanted to ask, are you not getting any spam comments dude? I mean every day or the other there are at least 3 unmoderated comments coming from ridiculous sources, which of course I delete. How about you? Any problems as such?

    Just my advice, if you haven't implemented yet, opt for comments with moderation.. :)

    Cheers,
    Karthik

    ReplyDelete
  4. @Div,
    Zombies are such fun I can't help including them wherever I can in my posts :D.

    BTW these are code comments, so its fine I guess if there are grammar mistakes :D

    @Justsam,
    I guess it will be very useful to you. I remember you saying you dont miss weddings. Now you can use this algo and give a second thought. I shall give you the complete algo :D

    @yossarian,
    Thanks. I haven't got any spam as of now. Your blog itself is a spam of your life, so I guess expected :D :P. Thanks for the advice,though

    ReplyDelete
  5. Hey!! This algo is mine ,you haven't given me enough credit , except mentioning my name here and there :P I will SUE YOU!! :D

    ReplyDelete
  6. I have already made the algorithm open source, so you are not getting any remuneration or something. This much credit should be enough. There are 3 params named after you. What more do you want? :D

    ReplyDelete
  7. is another 3 idiots controversy abt to happen? I think the blog must be renamed to "3 Parameters"

    ReplyDelete
  8. @justsam,
    Any publicity is good publicity ;)

    @Radha,
    Hey thanks for reading. Will apply this for your wedding too :D

    ReplyDelete
  9. @pavan - good one..Credit of level 1 and level 2 should definitely go to rashmi.. - idea woman behind the algorithm

    and level 3 is definetly yours- now we know pavan y you came to marriage..unfortunate both conditions were 0.. :-)

    ReplyDelete
  10. @Prabha,
    I think you only read the pieces of code there and not the variable declaration part. Or u have been bribed to support Rash :D

    ReplyDelete
  11. hehe ya..owning those variables alone, rash would never reach this algo :D
    @pavan, i tot you were so specific abt grammer that you wudnt miss it even in comments ;)

    ReplyDelete
  12. True/false wudve been better than 0/1 What is the invocation of buy_gift() dependent on :P -- AC

    ReplyDelete
  13. @Div,
    No :P There r some specific situations where usage of wrong grammaar is irritating. Not here :D

    @AC,
    Yes da. Good point about buy_gift(). I had thought of it later. It deserves a whole new algorithm, may be a more complicated one, math n all ;)

    ReplyDelete