New Speakers! :D

I recently got new speakers.

Sony SRS D5 Speakers. They are really awesome , although the volume is not that loud, but this has really some bass.

BTW! I have recently solved “Name that Number” USACO Problem. Here is the solution:


/*
ID: gautam11
PROG: namenum
LANG: C++
*/
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define P(s) printf("%s\n",s)
#define Pint(n) printf("%d",n)
#define Sint(n) scanf("%d",&n)
#define TEST printf("Test Called!")
#define NL printf("\n")
typedef struct node{
	int value;
	struct node *next;
}node;

typedef struct BinaryTree{
	int value;
	struct BinaryTree *left;
	struct BinaryTree *right;
}BinaryTree;

using namespace std;

string getChars(char num)
{
	switch(num)
	{
		case '2': return "ABC";
		case '3': return "DEF";
		case '4': return "GHI";
		case '5': return "JKL";
		case '6': return "MNO";
		case '7': return "PRS";
		case '8': return "TUV";
		case '9': return "WXY";
	}
}

/*bool LinearSearch(string S)
{
	ifstream fin ("dict.txt");
	string temp;
	for(int i=0;!fin.eof();i++)
	{
		fin>>temp;
		if(!S.compare(temp))
			return 1;
	}
	return 0;
}*/

bool match(string N,string test)
{
	string chars;
	for(int i=0;i>N;
	string test;
	bool flag=0;
	for(int i=0;!fdict.eof();i++)
	{
		fdict>>test;
		if(test.length()==N.length() && match(N,test))
		{
			flag=1;
			fout<<test<<endl;
		}
	}
	if(!flag)
		fout<<"NONE"<<endl;
	return 0;
}


Now, I am working on Code Chef November 2012 Challenge! I’ll post the solution to the problem I am able to solve(although the chances are really low ) here.

Well, I just got Coin Flip done. Here is my code:


#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#include
#define P(s) printf("%s\n",s)
#define Pint(n) printf("%d",n)
#define Sint(n) scanf("%d",&n)
#define TEST printf("Test Called!")
#define NL printf("\n")
typedef struct node{
	int value;
	struct node *next;
}node;

typedef struct BinaryTree{
	int value;
	struct BinaryTree *left;
	struct BinaryTree *right;
}BinaryTree;

using namespace std;

int main()
{
	int T;
	Sint(T);
	while(T--)
	{
		int G;
		Sint(G);
		while(G--)
		{
			int I,Q;
			long long int N;
			scanf("%d %lld %d",&I,&N,&Q);
			if(I==Q)
				printf("%lld\n",N/2);
			else
			{
				if(N%2)
					printf("%lld\n",N/2+1);
				else
					printf("%lld\n",N/2);
			}
		}
	}
	return 0;
}
Advertisements

Assholes ! how come I never misses to meet one.

I can’t write anything technical this time. I’m on my way back to Hyderabad in train. Unluckily, no hot chics near by.. but a lot of assholes. one never misses to meet atleast a asshole when travelling in Indian railways. Sitting here with no work , I just can’t stop thinking why is it that almost all companies select their employees on the basis on their data structure and algorithms knowledge.I mean what about a candidate who is very good at understanding large code bases?! what about those students who are really good at scripting ? Although , I am trying to improve my algorithmic skills for this very purpose. I am thinking of applying to Android Open Source Project(AOSP). I think this will boost my resume and I’ll learn few new very interesting things.

Installing mysql server.

I am trying to clone Open Monitor – Aggregator. The Open Source Project from Umit Project.

Its been about 1.5 years since I started contributing to Umit Project.
But soon after I cloned the aggregator from git, I realized I am I don’t have mysql setup. when I used the command to enter into mysql shell:

mysql -u root -p

After entering all the passwords I could remember to have ever used, all I could get in return was :

ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/var/run/mysqld/mysqld.sock' (2)

I was really pissed then I realized ,I have never really installed mysql server since I upgraded my system to Ubuntu 12.04

so I went to su mode, typed:

 apt-get install mysql-server

Bingo ! it worked in the first ,I could get my mysql running in no time.

Then I created a database named “openmonitor” using :

 create database openmonitor;

The day CodeSprint Ended.

I participated in CodeSprint 3. Before you judge me, let me tell you, it was a complete failure. I was hardly able to solve 1 problem out of 7 and my batchmates solved 4 problems even after starting way later when I had.

I need to keep my mind focused on Coding or I can say Bye Bye to the Placements this December.

From now on , I am focusing on solving a test placement paper or a coding competition every day . I’ll make sure I do it.I don’t think I have a option though.

BTW, Quora is damn addictive. Hats off to Adam D’Angelo.

For Now, I am solving this problem Transformation (http://ace.delos.com/usacoprob2?a=UwGQkWxSfYb&S=transform) .

WTF! I am confused now , how do we pass a 2D array of size N*N into a function ? I guess, I’ll just use dynamic allocation.

YAY! I got it working , in the 2nd Time, I did a stupid mistake in the first time. Here is my code(Include Necessary library,I’m new to blogging, don’t know how to post code 😛 ):

/*
ID: gautam11
PROG: transform
LANG: C++
*/
using namespace std;

bool Compare(char **Tiles,char **modTiles,int N)
{
	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			if(Tiles[i][j]!=modTiles[i][j])
				return 0;
	return 1;
}

char** RotateBy90(char **Tiles,int N)
{
	char **modTiles;
	modTiles=(char **)malloc(sizeof(char *)*N);
	for(int i=0;i<N;i++)
		modTiles[i]=(char *)malloc(sizeof(char)*N);

	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			modTiles[i][j]=Tiles[N-1-j][i];

	return modTiles;
}
char** Reflection(char **Tiles,int N)
{
	char **modTiles;
	modTiles=(char **)malloc(sizeof(char *)*N);
	for(int i=0;i<N;i++)
		modTiles[i]=(char *)malloc(sizeof(char)*N);

	for(int i=0;i<N;i++)
		for(int j=0;j<N;j++)
			modTiles[i][j]=Tiles[i][N-1-j];

	return modTiles;
}
int main()
{
	freopen ("transform.in", "r", stdin);
	freopen ("transform.out", "w", stdout);
	int N;
	Sint(N);
	char **Tiles;
	Tiles=(char **)malloc(sizeof(char *)*N);
	for(int i=0;i<N;i++)
		Tiles[i]=(char *)malloc(sizeof(char)*N);
	char **finalTiles;
	finalTiles=(char **)malloc(sizeof(char *)*N);
	for(int i=0;i<N;i++)
		finalTiles[i]=(char *)malloc(sizeof(char)*N);
	for(int i=0;i<N;i++)
		scanf("%s",Tiles[i]);
	for(int i=0;i<N;i++)
		scanf("%s",finalTiles[i]);
	char **modTiles;
	modTiles=RotateBy90(Tiles,N);
	if(Compare(modTiles,finalTiles,N))
	{
		printf("1\n");
		return 0;
	}
	modTiles=RotateBy90(modTiles,N);
	if(Compare(modTiles,finalTiles,N))
	{
		printf("2\n");
		return 0;
	}
	modTiles=RotateBy90(modTiles,N);
	if(Compare(modTiles,finalTiles,N))
	{
		printf("3\n");
		return 0;
	}
	modTiles=Reflection(Tiles,N);
	if(Compare(modTiles,finalTiles,N))
	{
		printf("4\n");
		return 0;
	}
	for(int i=0;i<3;i++)
	{
		modTiles=RotateBy90(modTiles,N);
		if(Compare(modTiles,finalTiles,N))
		{
			printf("5\n");
			return 0;
		}
	}
	if(Compare(Tiles,finalTiles,N))
	{
		printf("6\n");
		return 0;
	}
	printf("7\n");	
	return 0;
}