Posts Tagged ‘contest’

Google treasure hunt solution to robot problem

The google treasure hunt is on at http://treasurehunt.appspot.com/

Here is the solution to the robots problem

The problem is to fins the total no. of paths from one corner to another in a grid

The logic behind my solution lies as:

Total no of paths from the top corner to any given corner is the sum of the two boxes one on left and the other on top of that box.

like

So I have made two programs to do the same.Run them by changing the limits as per given in your question.

the first one in java:

class Google
{
public static void main(String srgs[])
{
long a[][]=new long[5][8];
for(int i=0;i<5;i++)
a[i][0]=1;

for(int i=0;i<8;i++)
a[0][i]=1;

for(int i=1;i<5;i++)
{
for(int j=1;j<8;j++)
{
a[i][j]=0;
a[i][j]=a[i-1][j]+a[i][j-1];
}
}
for(int i=0;i<5;i++)
{
for(int j=0;j<8;j++)
{
System.out.print(a[i][j]+ ” “);
}
System.out.println();
}
}
}


The other is in C

#include
#include
void main()
{
int m=3;
int n=7;
int A[3][7];
for(int i=1;i<=m;i++)
A[i][1]=1;
for(int j=1;j<=n;j++)
A[1][j]=1;
for(i=2;i<=m;i++)
for(j=2;j<=n;j++)
A[i][j]=A[i-1][j]+A[i][j-1] ;
for(i=1;i<=m;i++)
{
cout<< “\n \n”;
for(j=1;j<=n;j++)
cout<<a[i][j]<<” “;
}
}

World Search Championship



The World Search Championship is on.Yahoo!powered this championship is more like a yahoo’s attempt to popularise and show off the new features of their search engine while it states that you may use any search engine after all an answer is an answer!well its a good way to find out how good are you at searching on the web.The questions range from Bolly wood to Hollywood and from US politics to formula one.My score was around nine minutes but I saw people with as less as 19 sec(dont know how thats possibe!!!).After all its not a bad thing to test your skills and win a playstation!