Tag Archives: Google

[SOLUTION] Google Treasure Hunt – Primes

Here comes the II. quest from Google Treasure Hunt. Maybe it sounds very simple, and algorithm what we’ve (Szakál Károly (ftnkaresz /at gmail /dot com) and I) used isn’t so difficult, but after 3 hours of hard-coding, what we got? A full stack error with 2GB RAM. 😉

Find the smallest number that can be expressed as
the sum of 3 consecutive prime numbers,
the sum of 9 consecutive prime numbers,
the sum of 253 consecutive prime numbers,
the sum of 781 consecutive prime numbers,
and is itself a prime number.

For example, 41 is the smallest prime number that can be expressed as
the sum of 3 consecutive primes (11 + 13 + 17 = 41) and
the sum of 6 consecutive primes (2 + 3 + 5 + 7 + 11 + 13 = 41).

Recursion is very bad thing in programming. It isn’t requires deeper analysis of problems, there is enough to make good type definitions, a good algorithm with some recursive calls and return statement and finally there recursion will solve the problem for you. Okay! 🙂
The main goal of Data Structure and Algorithms is how to solve problems without recursive calls, and how to avoid the whole recursion.
The first solution made without recursion in programming language C. The main part of this program is an infinite while loop, what terminates itself if the right prime sum found:

while(1) {
     switch (r) {
      case 0: result=PrimSum(previousPrime,1063,&previousPrime);
      case 1: ix++;
              if (!(ix<5)) { return 0; }
      case 2: r=sum(nextPrime=NextPrim(nextPrime),array[ix],result);

Finally, our number is: 6304483.


Hacking Google Image Search

I’ve just found and interesting thread on http://forums.opensuse.org/ about Google’s image search. 🙂
So, to get started go to Google’s site, and click to image search. Search for something popular (flowers, cars). When the pictures are displayed paste this code into your browsers address bar:

javascript:R= 0; x1=.1; y1=.05; x2=.25; y2=.24; x3=1.6; y3=.24; x4=300; y4=200; x5=300; y5=200; DI= document.images ; DIL=DI.length; function A(){for(i=0; i < DIL; i++){DIS=DI[ i ].style; DIS.position='absolute'; DIS.left=Math. sin(R*x1+ i*x2+x3)* x4+x5; DIS.top=Math. cos(R*y1+ i*y2+y3)* y4+y5}R++ }setInterval('A()',5); void(0)

Enjoy! 🙂

[SOLUTION] Google Treasure Hunt – Robot

Okay! Let’s solve this programming problem without writing a single line of code. 🙂
A robot is located at the top-left corner of a 60 x 31 grid:

The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid.

Our robot can 30 times to step down and 59 times to step right, because it is staying on the first block (1, 1).
We can write down his way from location (1, 1) to location (60, 31) like this:
R – right, D – down.
The only question is: how many different (unique) arrays we have from 59 R and 30 D?
Fill out a row with 59 R:
RRRRRRRRR……..RRRRRRRRRRRR……RRRRRRRRRR and take 30 D to random places without repeating an already existing array. On more mathematical language, number of unique arrays (unique permutations) with length 59+30 from 30 D is exactly:

Comments are welcome! 😉

Google Treasure Hunt

Hi again here! First, sorry I have a couple of TODOs in the past few weeks around the university, tests, exams, etc. I have a lot of new things in my mind what I want to share with you. 🙂 Are you heard about Google Treasure Hunt? An interesting programming challenge. The problems are not so easy, you need to find out a lot of things, not just the algorithms. We have two problems solved, I’ll post here the solutions in the next few days. Maybe you can use it to something, or start your own Treasure Hunt account with two already solved problems. 🙂

Okay, let’s get started. Here is the first question (maybe the shortest).

“A robot is located at the top-left corner of a 60 x 31 grid. The robot can only move either down or right at any point in time. The robot is trying to reach the bottom-right corner of the grid.
How many possible unique paths are there?
(Note: Answer must be an exact, decimal representation of the number.)”

ps.: If you have some mathematical background and one calculator then without writing a single line of code you can solve this problem in 5 minutes.
Good luck. Good Hunting. 🙂


Blehh… I was offline for more than 7 days. True nightmare.
There was some important changes in the open-source world, example Google’s web-browser.

Chrome is another web-browser in the browsers war. It has tabs, like Mozilla, quick dial like Opera, and the other similar properties… As you can read on KDE related blogs, some things are missing from the announcement, example: they mention Apple’s WebKit, Mozilla’s Firefox but nothing about KDE/KHTML. Google is known about their great web-services, Gmail, Blogger, Google search, Picassa, iGoogle, my guess is that they have more complex plans than a new web-browser, maybe a platform or an operating system… And finally I’ve found some unfamiliar things in Terms of Service:

By submitting, posting or displaying the content you give Google a perpetual, irrevocable, worldwide, royalty-free, and non-exclusive license to reproduce, adapt, modify, translate, publish, publicly perform, publicly display and distribute any Content which you submit, post or display on or through, the Services. …

Read more about this.
So, at this time Chrome have – at my browsers list. I hope they’ll change the terms in future.