Tuesday, July 7, 2009

Witty Kid @ Office

Posting after really long time but this one is a must share.

During a Recent HR Event by my Company which was themed around "Bring your Child to Work Day".

A small kid probably around 4-5 years of age was interacting with all his Father's Directs..(his Dad is a People's Manager with a team of around 6-7 Members) then suddenly one of them questions the kid "what does Dad do at work?".

Kid Replies,"Dad... takes the Lunch Box and Laptop.. then reads mails,attends meetings then goes to lunch with other members and comes back.. "

PS
1)My Verdict : "Yeah I am Loving It!!!!!!! Fun to be a Manager it seems :D.".
2) Kid gave the 101 on Being a Good Manager..

Wednesday, June 17, 2009

Fun Questions

I found this Interesting Questionaire in some blog. I felt I should try answering them too.

1. When you looked at yourself in the mirror today, what was the first thing you thought?
Buck up lazy fella .. loads of work pending ;)

2. How much cash do you have in your wallet right now?
Around 394 odd Rupees.

3. What’s a word that rhymes with DOOR?
More,Bangalore,Floor...

4. Who is the 4th person on your missed call list on your cell phone?
Abhinav Krishnamoorthy.

5. What is your favorite ring tone on your phone?
Always on Silent 24X7.

6. What are you wearing right now?
Jeans and T-shirt.

7. Do you label yourself?
No.I have left that for others ;)

8. Name the brand of the shoes you’re currently own?
Sparx (hardly wear it),Sandals Unbranded.

9.Bright or Dark Room?
Bright.

10. What do you think about the person who took this survey before you?
SOB .. didnot tag me :(

11. What does your watch look like?
I don't wear one..

12. What were you doing at midnight last night?
Slept..

13. What did your last text message you received on your cell say?
Airtel AV-Promo Message cannot be displayed

14. What's a word that you say a lot?
I want to Head AS* (Internal Confidential)

15. Who told you he/she loved you last?(please exclude spouse , family, children)
No one since Everybody decides that I am selfish after a while.

16. Last furry thing you touched?
Some Furry Toy on Bring your Child to Work Day @ Office.

17. Favourite age you have been so far?
Present.

18. What was the last thing you said to someone before doing this?
I will send across the details to him and CC you as well.

19.The last song you listened to?
Ana Free : Its Time && Nickelback : Rockstar

20. Where did you live in 1987?
No Idea

21. Are you jealous of anyone?
No one in Particular.

22. Is anyone jealous of you?
I feel so since they so want me dead :P

23. Name three things that you have on you at all times?
Mobile Phone,Wallet and a Pen.(Most of the times).

24. What’s your favourite town/city?
Mumbai.

25. When was the last time you wrote a letter to someone on paper and mailed it?
For some Freakin' Contest 12 years back.

26. Can you change the oil on a car?
No.

27. Your first love/big crush: what is the last thing you heard about him/her?
"Dude.. Change your Desktop. She looks Pathetic each passing day "

28. Does anything hurt on your body right now?
My Hands... I have been typing for a long time since Morning.

29.What is your current desktop picture?
Windows v/s Walls !!! :D

30. Have you been burnt by love?
No.


PS: I tag Ankit Prabhat,Roshan Singh and all other bloggers from my College.

Sunday, May 17, 2009

Department Results

Well, The Results for the Sixth Semester were declared and it has always been a practice for me to sort the results.
So,Here I am again. This Time I am sharing the Code so that People don't think I manually sort them ;).Also, I would like to congratulate all the dept guys/gals who have excelled as always and awaiting a cool Final Year ahead.





#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
struct stud
{
double cgpa;
double sgpa;
int roll;
};
struct sorter
{
bool operator () (const struct stud a, const struct stud b)
{
return a.cgpa>b.cgpa;
}
};
int main()
{
vectorvec;
ofstream out("res.txt");
ifstream in("in.txt");
struct stud a;
while(in>> a.roll >> a.sgpa >> a.cgpa)
vec.push_back(a);
sort(vec.begin(),vec.end(),sorter());
out<< "Roll\tSGPA\tCGPA\n" ;
for(int i=0;i<vec.size();i++){
out << vec[i].roll << "\t" << vec[i].sgpa << "\t" << vec[i].cgpa << endl;
}
out.close();
in.close();
return 0;
}


This Requires an Input File of the form :: Roll\tSGPA\tCGPA
and Output has the same Format which can be changed as well.

I would be coming out with more of code snippets.Till then Enjoy Life.

PS:

The Actual Cpp File is available at this Link :: Here
The Output File::

Roll SGPA CGPA
48 9.12 9.27
61 9.36 9.26
60 9.12 9.09
39 9.36 9.08
26 9.16 8.95
62 9.36 8.89
16 9.28 8.89
2 9.04 8.85
28 9.04 8.81
30 9.36 8.81
46 8.6 8.77
7 8.76 8.67
53 8.52 8.58
37 8.36 8.55
42 9 8.48
3 8.2 8.43
25 8.52 8.42
50 8.6 8.33
10 8.64 8.3
52 8.44 8.23
27 7.84 8.22
14 8.68 8.22
59 8.6 8.21
5 8.84 8.19
43 8.76 8.19
34 8.04 8.18
33 8.2 8.15
11 8.2 8.05
31 7.84 8.05
6 8.36 8.01
23 8.2 7.99
38 7.56 7.99
55 7.84 7.87
9 8.04 7.85
17 7.52 7.8
49 7.52 7.77
35 7.84 7.66
21 7.8 7.61
41 7.52 7.59
63 7.08 7.58
36 7.24 7.52
8 7.24 7.39
40 7.8 7.39
45 7.88 7.37
19 7.4 7.31
51 7.68 7.28
56 6.76 7.28
1 7.32 7.26
24 6.84 7.16
20 7 7.06
18 6.92 7.04
44 7.24 7.01
15 7.36 6.82
54 6.32 6.81
32 6.44 6.75
64 6.96 6.73
13 6.04 6.63
57 6.52 6.59
22 6 6.45
29 6.36 6.37
58 5.44 6.13
12 4.96 6.12
4 0 0
47 0 0

Saturday, April 25, 2009

Anagram Solver

First Things First : I am worse at solving Anagrams but a little bit better at writing a Code for solving them :D .

This Post is about a Code that I wrote for solving Anagrams.It all started with this bot friend in my friend list : games@gtalkbots.com.It is a bot that allows users to play anagram with other users.

I was(rather am) really pathetic at solving anagrams instantaneously.Instead of sulking, I thought I must do something about it. I could win each round if I could get an answer within 0.1 secs. (My own Heuristic).

So,The Best way is to write a C++ Code for the same.Then,after little brain storming (random thoughts actually), I just needed a Dictionary and a Data Structure to store it. Since Hashing was out of question for a Quick-Code,STL Set was the second Best with Insertion /Look up of Asymptotic Upper Bound of O(log(n)).So, I just had to check all Permutations of the Random String and look up the Dictionary and if Match is found then Output the Result.

Within first 2 results for Dictionary in Google, I found a US Dictionary List in txt format.
So, The C++ Code for the same ::


#include<iostream>
#include<string>
#include<cstdlib>
#include<set>
#include<fstream>
using namespace std;

// This is a Set that Stores the Dictionary Values.

set<string>s;

/*
* This Method is used to check whether the String matches the given Mask.
* Example : srinivas --i-i--s
*/

bool check(string a, string b) {
for (int i = 0; i < a.size(); i++)
if (isalpha(a[i]) && isalpha(b[i]) && a[i] != b[i])
return false;
return true;
}

/*
* This Method is used to find all Permutations of the String
*/

void perm(string pre, string suff) {

if (!suff.size())
cout << (s.find(pre) != s.end() ? pre + '\n' : "");
else
for (int i = 0; i < suff.size(); i++) {
perm(pre + suff[i], suff.substr(0, i) + suff.substr(i + 1, suff.size()));
}
}

int main() {

s.clear();
string a;
ifstream in;
in.open("US.dic");
while (in >> a)
s.insert(a);
in.close();
cout << s.size() << endl;
while (cin >> a) {
perm("", a);
cout << "----------------------\n";
}
return 0;
}



But then as Luck would have it, The Bot went offline after I wrote the Code. I guess both of them are somehow related. But then Next Time I find the bot online,you wouldn't wonder if you find my name as one of the Top-Scorer's.

Cheers!!!
Do Comment/Post about it.

Friday, April 24, 2009

EasyProb

This is one of the Problems that I did long time ago but then I came back to it today. I had a text file containing the Result that had been generated using the Code though the Code was missing.
So, I had to start everything from scratch and I have become a bit Rusty though got it working in some time.

The Code for the Same ::



#include <iostream>
#include <fstream>
using namespace std;
/*
* String Uses a Recursive Function to Achieve the Effect.
*/
string ret(int a) {

/*
* Base Cases
*/
if (a <= 0)
return "";
else if (a == 1)
return "2(0)";
else if (a == 2)
return "2";
/*
* Recursive Step Begins here.
*/

else {
string s = "";
int count = 1;
while (a > 0) {
if (a % 2 == 1)
//Magic Statement
s = (count <= 2 ? ret(count) : "2(" + ret(count - 1) + ")")+(s == "" ? "" : "+") + s;
count++;
a /= 2;
}
return s;
}
}

int main() {
int a;
while (cin >> a)
cout << a << "=" << ret(a) << endl;
return 0;
}



It feels good to get such Codes working in real quick time ;) .
PS :
1) The Output for all The Inputs in the Problem::

137=2(2(2)+2+2(0))+2(2+2(0))+2(0)
1315=2(2(2+2(0))+2)+2(2(2+2(0)))+2(2(2)+2(0))+2+2(0)
73=2(2(2)+2)+2(2+2(0))+2(0)
136=2(2(2)+2+2(0))+2(2+2(0))
255=2(2(2)+2+2(0))+2(2(2)+2)+2(2(2)+2(0))+2(2(2))+2(2+2(0))+2(2)+2+2(0)
1384=2(2(2+2(0))+2)+2(2(2+2(0)))+2(2(2)+2)+2(2(2)+2(0))+2(2+2(0))
16385=2(2(2+2(0))+2(2)+2)+2(0)

2) If you do have a code that is better than mine Please make it a point to post/Comment about it.

Friday, April 17, 2009

Addicted to Blogging

Well, This is a short Post Considering the fact that I have my Exams going on.
I took a short Online Test to check my addiction to Blogging.
The result is in form of a IMG.

62%How Addicted to Blogging Are You?



Cheers!!!!

Saturday, April 11, 2009

Google Ad-Sense Pdf's

This is about a series of Pdf's that I found on Google's UK Server which is about Case Studies of Ad-Sense Program.
I was reading about Configuring robots.txt File from this URL.

Then Began a Series of Re-Direction of URL's (http://google.co.in/robots.txt -->http://www.google.com/sitemaps_webmasters.xml-->http://www.google.co.uk/intl/en/adtoolkit/pdfs/pdf_sitemap.txt)until i reached out for a URL which contained a list of Pdf's.
I was too curious to find the Contents of all Pdf's in a single go.That is when i realized that I could download-them-all (No Pun Intended) real quick if I can use Shell scripts to semi-automate the download Process.

The Process I followed :
1) Copied the Contents of a txt file to a file on the system.

2)I just had to insert a Firefox before each URL.This was the Difficult Part since I was really awful at tweaking shell scripts to achieve that. Instead I wrote a Quick C++ Code to do the same with File Handling(It was guaranteed to work too ).
The C++ Code for the same ::




#include <iostream>
#include <fstream>
using namespace std;

int main() {
/*
* links.txt is the Original File that Contained the list of URL's.
*/
ifstream in("links.txt");
/*
* link.sh is the shell Script which was to automate the Process.
*/
ofstream out("link.sh");

string s = "";
while (getline(in, s)) {
// This line enabled the Insertion of firefox before each URL.
out << "firefox " << s << endl;
}
in.close();
out.close();
return 0;
}




3) I had disabled all Prompts for Download in the Preferences Tab. So, it would Download all of these pdfs without prompting me ;).After this, I just had to run the Script from the Terminal and Voila!! All Pdf's were downloaded within 1-2 minutes.

4) Later, I had to move the pdf's from default download directory to a different Directory.

5) Finally, using wc-l/Word Count for lines,I found out that I had downloaded around 167 pdf's (some of them being confidential :P ). Since it is accessible for public viewing .. it doesn't matter.

I did all these steps within a matter of around 4-5 minutes which is real-quick for me.
The Entire Process was real fun.. In case you had come across such quick-tweak then do post about it..

PS:
1) Advanced Shell Script Tweaking is a definite To Do Thing next Semester.

2) wget was a better option than Firefox :( .. I am on the learning Curve ... Trying to Grasp Few things..