Friday, October 29, 2010

Magic Number - One puzzle a day - Puzzle Buddies

Puzzle: 
1. A number has n digits where n is greater than 1.
2. When multiplied by 1 through 6 the result contains the same digits arranged in different order.
3. When multiplied by 7 the result contains a single digit but n times.


What is the magic number?


Answer:
142857 is the correct answer!


142857 x 2 = 285714
142857 x 3 = 428571
142857 x 4 = 571428
142857 x 5 = 714285
142857 x 6 = 857142
142857 x 7 = 999999 


Winner:
Gaurave Sehgal

Thursday, October 28, 2010

Eight Eights puzzle - One puzzle a day - Puzzle Buddies

Puzzle:Using 8 exactly eight times make a 1000.

You can use any mathematical symbols

Note: Don't forget to visit us again. Answer to the puzzle will be posted tomorrow.
Solution:
888+88+8+8+8 = 1000
Winner: Vinay

Wednesday, October 27, 2010

Winner Winner Chicken Dinner - One puzzle a day - Puzzle Buddies

Puzzle: Your friend suggests a betting game. The rules are:

  1. Each person has to call a number after each another until someone calls 50. 
  2. Person who calls 50 wins.
  3. The player who starts has to call a number between 1 and 10 (inclusive).
  4. The new number must be at least 1 greater than the previous number. 
  5. It should not be more than 10 to the previous number.

You have bet 100 dollars on this game. You got the first turn. Which number would you call and why?

Note: Don't forget to visit us again. Answer to the puzzle will be posted tomorrow.
Solution:
This is a good example of backtracking algorithms
Winner says 50.
Looser has to say a number between: 40-49
Winner says 39
Looser has to say a number between: 29-38
Winner says 28
Looser has to say a number between 18-27
Winner says 17
Looser has to say a number between 7 and 16
Winner has to say 6 to start this.
So the answer is 6.
Winner: Kasturi is the Winner

Tuesday, October 26, 2010

The Burning Rope - One puzzle a day - Puzzle Buddies

Puzzle:There are two lengths of rope.Each one can burn in exactly one hour.They are not necessarily of the same length or width as each other.They also are not of uniform width (may be wider in middle than on the end), thus burning half of the rope is not necessarily 1/2 hour.
By burning the ropes, how do you measure exactly 45 minutes worth of time?

Note: Don't forget to visit us again. Answer to the puzzle will be posted tomorrow.
Solution:

If you light both ends of one rope, it will burn in exactly a 1/2 hour. Thus, burn one rope from both ends and the other rope from only one end. Once the one rope (which is burning from both ends) finally burns out (and you know a 1/2 hour has elapsed), you also know that the other rope (which is buring from only one end) has exactly 1/2 hour left to burn. Since you only want 45 minutes, light the second end of the rope. This remaining piece will burn in 15 minutes. Thus, totaling 45 minutes.
Winner: Gaurave Sehgal

Monday, October 25, 2010

Two Primes - One puzzle a day - Puzzle Buddies

Puzzle: Two prime numbers p1 and p2 differ by 11111. What are their sum and product?

Solution: Since p1 and p2 differ by an odd number, one of them must be even. Since 2 is the only even prime number,
p1 = 2 and p2 = 11113
Sum = 11115
Product = 22226




Thursday, October 21, 2010

Division - One puzzle a day - Puzzle Buddies

Puzzle:Find the number of factors of 264,600 that are not divisible by 6.
Note: Don't forget to visit us again. Answer to the puzzle will be posted tomorrow.
Solution:
264,600 = 2^3*3^3*5^2*7^2 (broken into prime numbers)
There are 4 powers of 2: 2^0,2^1,2^2 and 2^3
There are 4 powers of 3: 3^0,3^1,3^2 and 3^3
There are 3 powers of 5: 5^0,5^1, and 5^2
There are 3 powers of 7: 7^0,7^1, and 7^2
There are 4*4*3*3=144 different ways to combine the prime factors of 264,600.

Now, eliminate the factors of 6. A factor of 6 must have at least one 2 and one 3.
So it must either have either 2^1,2^2, or 2^3 AND 3^1,3^2, or 3^3. So, there are 3*3=9 different ways the powers of 2 and 3 can combine to generate distinct numbers divisible by 6.

Also, there are 3*3 = 9 different numbers that can be created from the powers of 5 and 7. Any of these 9 numbers can combine with any of of the 9 multiples of 6 to form 9*9 = 81 distinct multiples of 6.

Hence, the number of factors of 264,600 that are no divisible by 6 is 144-81 = 63.
Winner:
Noone

Wednesday, October 20, 2010

100 Lockers - One puzzle a day - Puzzle Buddies

Puzzle: You are in a locker room with 100 lockers in  a row. You have keys to all the lockers. All the lockers are initially closed. You make 100 passes, you toggle ( if the door is closed you open it, if its open you close it) all the locker doors in the first pass, second time you only visit every second door and toggle it, third time you only visit every third door and toggle it and so on.

How many doors will be open after 100th pass.

Solution: There are three ways to solve this puzzle
1. Brute force
 Keep running it for all 100 passes and then count. The solution will be correct but not elegant.
2. If you try to run brute force for first few you can infer that

  • 1st locker will be toggled 1 time
  • 2nd locker will be toggled 2 times
  • 3rd locker will be toggled 2 times
  • and so on ........

This shows us that each locker will be toggled by its own factors only.
The locker can be in open state if the factors are odd.
Now we can count factors of each number from 1 to 100 and which ever are odd will result in open lockers
3. The easiest way is that only perfect squares can have odd factors. So all perfect squares can be counted and that is the answer.

So the answer is 10 and locker numbers are 1,4,9,16,25,36,49,64,81,100.

Winner: Today's winner is Kasturi

Monday, October 18, 2010

Print 20 Dashes - One puzzle a day - Puzzle Buddies

Puzzle:

In the following C program, replace(not add or delete) only one character so that it would print 20 dashes.

int i, n = 20;
for (i = 0 ; i < n ; i--) {


printf("-");
}

Find three different solutions to this puzzle.

Solution:

1.

int i, n = 20;

for (i = 0 ; i < n ; n--) {
printf("-");
}

2.

int i, n = 20;
for (i = 0 ; i + n ; i--) {
printf("-");
}

3.

int i, n = 20;
for (i = 0 ; -i < n ; i--) {
printf("-");
}

Winner: None

Dice puzzle - One puzzle a day - Puzzle Buddies

Puzzle: Two students play a game based on the total roll of two standard dice. Student A says that a 12 will be rolled first. Student B says that two consecutive 7s will be rolled first. The students keep rolling until one of them wins. What is the probability that A will win?



Solution:

Let p be the probability that student A wins. We consider the possible outcomes of the first two rolls. (Recall that each roll consists of the throw of two dice.) Consider the following mutually exclusive cases, which encompass all possibilities.

  • If the first roll is a 12 (probability 1/36), A wins immediately.
  • If the first roll is a 7 and the second roll is a 12 (probability 1/6 · 1/36 = 1/216), A wins immediately.
  • If the first and second rolls are both 7 (probability 1/6 · 1/6 = 1/36), A cannot win. (That is, B wins immediately.)
  • If the first roll is a 7 and the second roll is neither a 7 nor a 12 (probability 1/6 · 29/36 = 29/216), A wins with probability p.
  • If the first roll is neither a 7 nor a 12 (probability 29/36), A wins with probability p.
Note that in the last two cases we are effectively back at square one; hence the probability that A subsequently wins is p.
Probability p is the weighted mean of all of the above possibilities.
Hence p = 1/36 + 1/216 + (29/216)p + (29/36)p.
Therefore p = 7/13.

Friday, October 15, 2010

Two boys in a row - One puzzle a day - Puzzle Buddies

Puzzle: A woman has two children. One of them is a boy. What is the probability that the other child is also a boy.

Solution: The natural answer to this is 1/2 as the second child can be either Boy or Girl so the probability of boy is 1/2. But this solution is wrong as there can be following cases when there are two children


1. Boy - Boy
2. Boy - Girl
3. Girl - Boy


so the probability is 1/3.


Winner: no winners this time. better luck next time.

Printing stars - One puzzle a day - Puzzle Buddies

Puzzle:
The following C program prints infinite *s. You have to change (not add or remove) only 1 character to make it print exactly 20 *s.

int i, n = 20;
for (i=0; i < n; i--)

{
printf("*");
}

Note: Don't forget to visit us again. Answer to the puzzle will be posted on Monday.


Thursday, October 14, 2010

Slim Lover - One puzzle a day - Puzzle Buddies

Puzzle


A slim young man asked a girl on a date:
"I say something. If it is truthful, will you give me your photo?"
"Yes," replied miss.
"And if it is a lie, do not give me your photograph. Would you promise that?"
The girl agreed. Then the chap said such a sentence, that after a little while of thinking she realized, that if she wanted to honor her promise, she wouldn't have to give him a photo but a kiss.


What would you say (if you were him [or her!]) to be kissed?





Solution:

"You will give me neither your photo nor a kiss."





Note: Don't forget to visit us again. Answer to the puzzle will be posted tomorrow.

Wednesday, October 13, 2010

Twins - One puzzle a day - Puzzle Buddies

Puzzle: Two girls are born to the same mother, on the same day, at the same time, in the same month and year and yet they're not twins. How can this be?


Solution:

They can be triplets or more

Winners: Subodh and Aashish

Tuesday, October 12, 2010

How many Zeroes - One puzzle a day - Puzzle Buddies

Puzzle: A certain street has 1000 buildings. A sign maker is contracted to number the houses from 1 to 1000. How many zeros will the sign maker need

Note: Don't forget to visit us again. Answer to the puzzle will be posted tomorrow.

Solution:

Divide 1000 building numbers into groups of 100 each as follow: (1..100), (101..200), (201..300),....... (901..1000) For the first group, sign-maker will need 11 zeroes.
For group numbers 2 to 9, he will require 20 zeroes each.
And for group number 10, he will require 21 zeroes.
The total numbers of zeroes required are
= 11 + 8*20 + 21
= 11 + 160 + 21
= 192

Winner: None

Monday, October 11, 2010

Iron cube - One puzzle a day - Puzzle Buddies

Puzzle: Eight Iron cubes are presented to you.seven of them are of equal weight and one is heavier than the others.You have a simple balance, you can use it only twice.How can you find out the heavier cube?
Note: It is not possible to identify the heavier cube by size









Solution:




Divide the cubes into 3 - 3 - 2.
Put 3 and 3 on the balance. If they are balanced then put the 2 on th balance to get the heavier.
If the 3 - 3 are not balanced, take the heavier set and split to 1 - 1 - 1. Weigh a set. If the set is balanced then the 1 left out is heaviest.

Winner is @Aus

Friday, October 8, 2010

Heads Up Quarters - One puzzle a day - Puzzle Buddies

Puzzle:
On a table, are 50 quarters. 40 of them are tails up and 10 are heads up.

You are blindfolded, so you cannot see the quarters. Also, you are wearing gloves, so you cannot distinguish between heads up and tails up quarters by touching them.

You have to divide the quarters into two groups such that the number of heads up quarters in both the groups is the same. There is no restriction on the total number of quarters in each group or on the number of heads up quarters in each group. You are allowed to flip the quarters.

How can you accomplish this?


Solution: Divide the quarters into two groups of 10 coins and 40 coins and flip all the 10 coins in the smaller group.

Suppose there are x heads in the 10-coin group. You have:

10-coin group -> x heads, 10-x tails
40-coin group -> 10-x heads(since total heads=10), 30+x tails

When you flip all the coins in the smaller group you have:

10-coin group -> 10-x heads, x tails
40-coin group -> 10-x heads, 30+x tails

The number of heads in the two groups is the same.

Winner: Subodh Singh

Thursday, October 7, 2010

Tight Corner - One puzzle a day - Puzzle Buddies

Puzzle: A King asked one of his prisoners,
"State a sentence. If it is false, you will be hanged. If it is true, you will be shot to death."
The prisoner wants to live. Can you help him with a sentence?

Solution: A problem like this can only be solved with a paradox, a statement neither true nor false. By stating "I will be hanged" he has rendered both the conditions false and saved himself.


Winner: Kasturi (You are a lifesaver!)

Wednesday, October 6, 2010

Find the winners - One puzzle a day - Puzzle Buddies

Puzzle: John and Doe were excitedly describing the result of the Third Annual International Science Fair Extravaganza in Sweden. There were three contestants, Michael, David, and Peter. John reported that Michael won the fair, while David came in second. Doe, on the other hand, reported that Peter won the fair, while Michael came in second.

In fact, neither John nor Doe had given a correct report of the results of the science fair. Each of them had given one correct statement and one false statement. What was the actual placing of the three contestants?

Note: Don't forget to visit us again. Answer to the puzzle will be posted tomorrow.


Solution: Peter won, David came in second and Michael came in last.


Winner: Today's winners are Subodh Singh and DJ

Tuesday, October 5, 2010

Big Bear - One puzzle a day - Puzzle Buddies

Puzzle: A bear walks 5 miles south, turns left and walks 5 miles to east and then turns again and walks 5 miles north and arrives at the starting point.

What is the color of the bear?

Note: Don't forget to visit us again. Answer to the puzzle will be posted tomorrow.


Solution: The bear color is White as its only possible at north pole to go south, then go east and then north to arrive back at the starting point. The bear is polar bear and is thus white.


Winner: Today's winner is DJ.

Monday, October 4, 2010

How many ways to distribute cookies - One puzzle a day - Puzzle Buddies

Puzzle:A woman has seven cookies--four chocolate chip and three peanut butter. She gives one cookie to each of her six children: Nick, Ron, Kim, Deb, Max, and Terrall. If Deb will only eat the kind of cookie that Kim eats, in how many different ways can the cookies be distributed?

Note: Don't forget to visit us again. Answer to the puzzle will be posted tomorrow

Solution: There are two possibilities in this problem. Either Kim and Deb will both get chocolate chip cookies or Kim and Deb will both get oatmeal cookies.If Kim and Deb both get chocolate chip cookies, then there are 3 oatmeal cookies and 2 chocolate chip cookies left for the remaining four children.

There are 5!/3!2!=10ways for these remaining cookies to be distributed--four of the cookies will go to the children. (There are 5! ways to arrange 5 objects but the three oatmeal cookies are identical so we divide by 3!, and the two chocolate chip cookies are identical so we divide by 2!.)\
If Kim and Deb both get oatmeal cookies, there are 4 chocolate chip cookies and 1 oatmeal cookie left for the remaining four children.There are 5!/4! = 5 ways for these 5 remaining cookies to be distributed--four of the cookies will go to the children, one to the dog.(There are 5! ways to arrange 5 objects but the four chocolate chip cookies are identical so we divide by 4!.)
Accounting for both possibilities, there are 10 + 5 = 15 ways for the cookies to be distributed.

Winner: Austin

Friday, October 1, 2010

Spy Game - One puzzle a day - Puzzle Buddies

A spy wants to break in to a highly secured building.there is only one way to enter and two guards are always on duty. The only way to get access is to answer the guards correctly.
The spy watches three people coming and he overheard the questions asked and answers given.all three men are given access to the facility.
Th Question and answers are given below.

Guard 1 said 12 first person replied 6
Guard 1 said 6 second person replied 3
Guard 1 said 2 third person replied 3

Guard 2 said 1 first person replied 11
Guard 2 said 11 second person replied 21
Guard 2 said 12 third person replied 1112

After this spy moved in
guard 1 said 3 spy replied
guard 2 said 1112 spy replied .

Guards allowed the spy in. what were the answers given by the spy?

Solution:Answer to the first guard 5.answer to the second guard 3112

answer to first guard is the number of letters in each number he says.
12(TWELVE) --six letters so answer 6
6(SIX)-- three letters so answer 3
answer to second guard is the using the contains..
1 contains one one --11
11 contains two ones-21
12 contains one one and one two-1121

Subodh is the Winner.