Starve , Stuff ?

13 04 2008

“Starve a fever, Stuff a cold” goes the saying. A more popular variant seems to be, “Starve a fever, Feed a cold”.

Fever

Ruddy issue is, I always seem to get both together. Whenever I get a fever, a cold accompanies.

Cold

Now, the issue is, do I starve or do I stuff myself ? I have always been bad at decision making, but this looks like a dead end to me. To illustrate the gravity of the issue, let me write a pseudocode, (you guys can later write a program out of it) :)

if(variable ==fever)

{

Starve;

}

else if(variable ==cold)

{

Stuff yourself;

//preferable at others’ expense ;)

}

Predict the output of the above pseudocode.

P.S: Answers to the effect of first starve yourself and then stuff yourself will be scorned upon.

Revised Psuedocode**:

flag=0;

variable1=fever;

variable2=cold;

While(flag=0)

{

if(variable1 == fever && variable2!=cold)

{

starve;

flag=1;

}

if(variable1!=fever && variable2==cold)

{

stuff yourself;

//At shiva’s expense ;)

flag=1;

}

}

**Rewritten on insistence from Shiva :)

Also, the whole point of the psuedocode was pointlessness. There was no point to it to start with.


Actions

Information

15 responses to “Starve , Stuff ?”

13 04 2008
shiva (10:03:13) :

Looks like you’ll only be starving yourself…you used an “else if” … it’ll never reach..

13 04 2008
Srividya (10:44:03) :

Yeah, good point.

13 04 2008
Karthik (14:57:53) :

@Shiva,

Oh, yes, this doesn’t apply in my case. This was when the two are mutually exclusive. :)

Writing a revised psuedocode ;)

13 04 2008
shiva (15:18:05) :

I see what your trying to do, so this is my way to not let you have your way:

With regard to your revised code:

Initially you only have fever as the cold is in the process, hence the condition:

(var1==fever)&&(var2!=cold) is true

Hence starve() executes… During this execution operation cold commences,

hence when you leave the first ‘if’, you have both cold and fever. The second if is now obviously not executed.

So as I said earlier you only starve; ;)

13 04 2008
Karthik (15:20:14) :

damn, the onset of the cold.

13 04 2008
Karthik (15:21:50) :

Also, I have assumed that the difference in time between the onset of fever and cold is less than the the time taken for the instruction to execute (function of number of instructions and the clock speed). Ha, so now I am right (I am right ? :( )

13 04 2008
shiva (15:25:55) :

Ok now I have work to do ;)

13 04 2008
Karthik (18:34:09) :

Ha, ha. But in essence, even my first psuedocode was right. The variable could not have had two values and unless it was fever, else if would have executed. :) Some people thought there was a point to it. :P

13 04 2008
Srividya (18:58:16) :

You would not have revised your first pseudocode if you felt it was up to the mark.So I was right in claiming he had a point.

13 04 2008
Karthik (19:09:07) :

@Srividya,

Shiva is always right. :D (And, I am not being even the slightest bit sarcastic here) If you claimed he had a point, you are equally right. (all the time. no need to even think)

I just said, people thought there was a point to the code itself. It meant other people who did not discuss it on this blog. That should clarify things ?

13 04 2008
Karthik (19:12:58) :

As for the code being right or wrong, there is no point to it. It was/is meant to be pointless.

I could come up with several arguments to prove its right and other people could come up with equally valid counter-arguments to prove me wrong.

For instance, in an event based program, the value of the variable could even change between execution of statements. So that would mean my previous claim is wrong. (right ? :) ) Let’s not get into technicalities and leave it at the cold and fever. I already feel unwell again. ;)

15 04 2008
Marc (10:07:29) :

Now you see why I skipped this post.

15 04 2008
Karthik (16:39:32) :

@Marc,

Yes, it involved a pseudocode :D

18 04 2008
George (17:28:04) :

Why not just go to sleep? That’s the procedure I usually employ.

20 04 2008
Karthik (17:56:06) :

@George,

Yes, but I do that even when I am feeling alright. My system is somehow used to that by now and does not respond. :)

Leave a comment

You can use these tags : <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>