Spam Psychology

Sometimes I think that the rate of growth of spam applications on facebook is steadily losing out to the rate of growth of numb-skulls falling for it.

Humans have been designed to adapt, to learn from experience. The first neanderthal man who introduced his fingers inside a burning flame, must not have needed a second chance to learn the essential lesson. And those were neanderthals. They usually just smacked each other on the head to kill time. And here we are – youth of the 21st century, at the brink of a major technology revolution – repetitively falling for the same spam applications on facebook.

But why do people keep falling for it? Ah! They play with our brains! Lets have a look at the specific type of people who fall for such applications.

1. “Who will be your valentine?” = Teenagers who are single or in complicated relationships, and people who have nothing better to do.

2. “Who viewed your profile?” = Absolute loners, and people who have nothing better to do.

3. “Facebook will be deactivated. Authenticate your profile” = Dumb people, Gullible people, and people who have nothing better to do.

4. “Paste this code to see something Amazing!” = Dumb people again, Bored people, and people who have nothing better to do.

5. “Free 1000 iPhone giveaway!” = Dumb people who think they’re clever, and people who have nothing better to do.

Gotta go grab some sleep now. Will continue in the next post.

Codechef Practice Easy – ATM

Problem Code: HS08TEST

The initial solution in C to this problem seemed okay to me, and so it did to the codechef engine.

#include<stdio.h>
int main()
{
int wd; //withdraw amount
float bal; //initial account balance
scanf("%d%f",&wd,&bal);
if(bal-wd>=0.5 && wd%5==0) //enough balance for bank charge, and withdrawal amount multiple of 5.
printf("%0.2f",bal-wd-0.5); //print new balance.
else
printf("%0.2f",bal); //if not enough money, print current account balance.
return 0;
}

1st Attempt – Accepted – 0.0 Time – 1.6M Memory

Codechef Practice Easy: Life, the Universe, and Everything

Problem code = TEST

Initial solution – Accepted – 0.01 Time – 2.2M Memory

#include<stdio.h>
 int main()
 {
 int num;
 scanf("%d",&num);
 while(num!=42){
 printf("n%d",num);
 scanf("%d",&num);
 }
 return 0;
 }

Lets optimize the code a bit further.
2nd Attempt – Accepted – 0.0 Time – 2.2M Memory

#include<stdio.h>
 int main() {
 int x;
 while(1){
 scanf("%d",&x);
 if(x==42)
 break;
 else
 printf("%dn",x);
 }
 return 0;
 }

Now that was an easy warm-up to the codechef engine. I’ll move on to the next problem and try to solve all the problems in the practice-easy section whenever I get some free time.

Hello World

Hello world?

I’ve always wondered why this was the first thing people write when trying out something new.

Much like every other question possibly related to code, someone had already asked this question on Stack Overflow.

Apparently the very first ‘Hello World’ program was written by Brian Kernighan as part of the documentation for I/O section of the BCPL programming language manual. This code was also used for testing of the C compiler and hence made its way into Kernighan and Dennis Ritchie’s book on C which was published in 1972. And again, later, it was also one of the first programs used to test Bjarne Stoustroup’s C++ compiler.

Ha! Brian Kernighan, Dennis Ritchie, and Bjarne Stoustroup! No wonder people have been using it ever since.

Anyway!

Hello World!