Skip to main content

Whois[she|he]

One of my favorite ploy to those who newly joined my previous company was to give them a command line application and ask them to find out how it worked. This magic command line tool happens to guess your gender if you give your name.

char lastc = argv[1][strlen(argv[1])-1];

printf("%s is a %s\n", argv[1], (lastc == 'a' || lastc == 'i') ? "She" : "He");

Basically, it checks to see if your name ends with an 'a' or an 'i' and if it does, assumes that the person is a lady. Chances are, 95% of most Indian names fall into this category and this simple app seems to do magic.

Most were able to (after a few tries) guess the grand algorithm, but a few poor souls could not, which eventually leads to step number 2.

Step #2 is, as they were unable to decipher the algorithm, I said that I will provide with two separate command line apps called whoisshe and whoishe. I also mentioned that as I had not done the validation part properly, to please provide only men's name to whoishe and a ladies name to whoisshe. If they provide the wrong name, the results could be wrong as well. The code for whoisshe is as follows:

printf("%s is a she\n", argv[1]);

And appropriately modified for whoishe.

The aim is to see how long our new joinee continues to test these tools... Wicked!

Comments

Popular posts from this blog

Helmet and seat-belt mandated at TN Today morning, I was pleasantly surprised to see most bikers (along with pillion riders) traveling with their helmets on as TN geared itself from the 1st of June to make it mandatory to wear helmets for bikers and seat belts (for the front seat passengers) for car commuters. The FM radio RJs had been conducting on-the-road commentaries, catching helmet-less riders seeking justification on why they had not yet acquired one (the helmet) yet. The shamed few who got caught eventually were presented with a helmet. One the way (near Tirumangalam), I couldn't help notice people flocking near put-up helmet shops on the sidewalks, trying to acquire the license to ride a bike! Let's hope the momentum carries on...
Battle of Wesnoth Been on the lookout for a free turn based strategy game and chanced upon the Battle of Wesnoth . Despite it being an open source game (meaning, you get the source), it was incredibly polished akin to any of the other turn based strategy game (Alpha Centauri), be it the background score or the graphics or the tutorials. The game itself is set in a period similar to the D&D or nethack era. For the film buffs, if you have read or seen the Lord of the Rings, you would probably be able to relate to the clans that populate the game world. The game play, as with any turn based strategy game requires background information on each of the units that you own, their strengths and weaknesses and a lot of planning (a kin to chess, but with a lot more parameters) where factors like day - night cycles are taken into account (e.g, humans fight well during the day, but the orcs are better during the night). It is encouraged to keep your older units as they gain experience and beco

WiFi atlast

After numerous hours of tweaking, I resolved the problem with my WG311v3 NetGear PCI card. The problem? The router was too far away! Now that I am online using my Linux box, here are a few screen-shots of my desktop! The next time your supported WiFi card acts up, you know what to do... For those inquisitive lot, I am currently using the XP drivers with ndiswrapper.