Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find all perfect squares that are a permutation of some 300 digits

Tags:

This was a question that was asked to my friend in a Google interview a while back. He was unable to come up with a solution but ended up bagging the job anyway. Here's the question

You have been given 300 digits comprising of 100 ones, 100 twos, and 100 threes, now come up with an algorithm that will determine all such numbers which are a perfect square

I tried this for a while but am stumped. Any thoughts on how to go about this?

like image 733
sanz Avatar asked Sep 18 '11 05:09

sanz


People also ask

Is there a perfect square in 300?

300 is a number that is not a perfect square. This indicates that it does not have a natural number as its square root. Also, its square root cannot be expressed as a fraction of the form p/q which tells us that the square root of 300 is an irrational number.

What are all of the perfect squares up to 400?

They are 4, 9, 16, 25, 36, 49, 64, 81, 100, 121, 144, 169, 196, 225, 256, 289, 324, 361, 400, 441, 484, 529, 576, 625, 676, 729, 784, 841, 900 and 961.

What are the perfect squares from 100 to 200?

121 , 144, 169, 196 - There are four perfect squares between 100 and 200.

How many factors of 1000 are perfect squares?

Is 1000 a perfect square? We know, 1000 = 2 × 2 × 2 × 5 × 5 × 5.


1 Answers

   printf ("{}\n");  

The set in question is empty (the sum of the digits is divisible by 3 but not by 9).

like image 197
n. 1.8e9-where's-my-share m. Avatar answered Nov 18 '22 13:11

n. 1.8e9-where's-my-share m.