## Friday, April 27, 2007

### There is something .... no, many things about THREE

Ever wondered what are the properties of a multiple of 3??
You must be wondering and the most prompting answer would be that the sum of the digits of any multiple of three is also divisible by three. There are more and a wonderful property that can be thought of is related with the number 153. Now what about it. Lets move on, read on the statement below:
"The sum of the cubes of the digits of any natural number which is the multiple of 3 will lead you to a black hole ... that is 153". Try it the process follows :

1. Choose a multiple of three
2. Take the cube of its digits and add them
3. Do the same with the new number.
4. You will be lead to 153 which is a 3-narcissistic number i.e. an n-digit number , the nth power of whose digits sums up to the number again.
And that is what the black hole is.

Now 153 is the only 3-Narcissistic number that makes a black hole.. leading from any multiple of three.
Try it with any length of the number..... write a computer program. But make sure the length of the number doesnt leaks your memory.

There must be something that keeps people thinking about grouping in three. Sometimes in bad omen , sometimes in good.

## Wednesday, April 25, 2007

### The difference 6174, a black hole

Mathematics is full of magic. Now stands the constant 6174 boasting about itself saying see the difference i can make.

1. Consider any natural number less than 10000 other than 1111*n where n = [1,9] i.e shouldn't be an integral multiple of 1111.
2. Extract the largest four digit natural number that can be made by rearranging its digits with zeros included i.e 9 is considered as 0009
3. Similarly, find the smallest four digit natural number again by rearranging digits
4. Find the difference between largest and the smallest number , name it as result.
5. Consider result as the new number and repeat 2,3,4,5.

Woaaaaa and thats the amazing black hole here. You will reach the number 6174 in a maximum of seven steps and you cannot go any further from here.
Try it. I will do it for 9
Start from Number 9 = 0009
Iteration 1: 9000 - 0009 = 8991 = new number
Iteration 2: 9981 - 1899 = 8082 = new number
Iteration 3: 8820 - 0288 = 8532 = new number
Iteration 4: 8532 - 2358 = 6174 = new number
Iteration 5: 7641 - 1467 = 6174 = new number
Iteration 6: 7641 - 1467 = 6174 = new number
.
.

6174 reached at iteration 4.
Hey stop now, dont get in to the loop, you cannt go any further it ll give 6174 again
The number 6174 is known as Kaprekar's Number

Run the following java code to ensure this:
Click to Show/Hide

START

import javax.swing.JOptionPane;
public class Kaprekar {
public static void main(String[] args) {
int number, digit[] = { 0, 0, 0, 0 };
String msgString = "\n";
number = getInt4DigitInput("Enter a natural number between 1 and 9998"
+ "\n (excluding integral multiples of 1111)");

if (number != 0) {
int[] sortedDigits;
int largest, smallest, count = 0;
do {
digit[0] = number / 1000;
digit[1] = number / 100 - digit[0] * 10;
digit[2] = number / 10 - digit[1] * 10 - digit[0] * 100;
digit[3] = number - digit[2] * 10 - digit[1] * 100 - digit[0]* 1000;
sortedDigits = sortInt(digit);
largest = generateLargest(sortedDigits);
smallest = generateSmallest(sortedDigits);
number = largest - smallest;
msgString += largest + " - " + smallest + " = " + number + "\n";
count++;
} while (number != 6174);
msgString += "Number 6174 reached in " + count + " iterations "
+ "\nNumber reached = " + number;
JOptionPane.showMessageDialog(null, msgString);
}
System.exit(0);
}

private static int generateSmallest(int[] sortedDigits) {
int smallest = 0;
for (int j = sortedDigits.length - 1; j >= 0; j--) {
smallest += sortedDigits[j] * Math.pow(10, j);
}
return smallest;
}

private static int generateLargest(int[] sortedDigits) {
int largest = 0;
for (int i = 0, j = sortedDigits.length - 1; i <>length; i++, j--) {
largest += sortedDigits[i] * Math.pow(10, j);
}
return largest;
}

private static int[] sortInt(int[] intArray) {
int temp;
for (int i = 0; i <>length; i++) {
for (int j = i + 1; j <>length; j++) {
if (intArray[i] <>
temp = intArray[i];
intArray[i] = intArray[j];
intArray[j] = temp;
}
}
}
return intArray;
}

public static int getInt4DigitInput(String inputMsg) {
int input = 0;
String returnValue = JOptionPane.showInputDialog(inputMsg);
if (null != returnValue) {
try {
input = Integer.parseInt(returnValue);
} catch (NumberFormatException nfe) {
input = getInt4DigitInput("Please enter a valid four digit number,dont play around testing the code");
}
if (input <> 9998) {
input = getInt4DigitInput("Please enter a valid four digit number,didnt i tell you a number between 1-9998");
} else if (input % 1111 == 0) {
input = getInt4DigitInput("Please enter a valid four digit number,oops its a multiple of 1111, take care buddy");
}
}
return input;
}
}

END

### A Black Hole number 15

There is no reason to it , nothing but it still exists. Mathematics has wonders to do with it
For any natural number take down its divisors including 1 and the number itself. Add the digits of all the divisors. You will get a new number. Do the same over it.
No matter what number u take u fill finally converge to 15 and after that you wont be able to move any further, the number of iterations may vary, and this black hole number 15 when you do the same with it. Lets see what happens.
Divisors of 15 = 1, 3, 5, 15
Add digits = 1+3+5+1+5

Lets take another example you want to take 4 , go for it.
divisors = 1 , 2, 4 Addition = 7 = new number
divisors = 1 , 7 Addition = 8 = new number
divisors = 1 , 2, 4 ,8 Addition = 15 = new number
Back on 15

Great!!

### Superman Returns - A lifetime coincidence (Lex screams)

Its was once when self moving car , zoom in through satelite linked computer etc in the James Bond movies were supposed to be fiction. At this point of time most of them are real. But coming to superheroes with super power, any single thing that comes real is unbelievable. And that is now the case with Superman this time.

Lex Luthor screams," Oh that Kryptonite was contaminated. I have to work upon it now "

The Kryptonite is in the limelight. No it didnt come from outer space. It is found in the mines of Serbia. The only difference is it doesnt glows(Not radioactive) and that it is white in colour opposite to green color in the fiction. The chemistry matches exactly the same except that it doesnt contain flourine. The scientific naming convention described the compound as sodium lithium boron silicate hydroxide, which on a mere web search matched the Kryptonite in the Superman fictions.

Now that is really really a life time coincidence. That doesnt mean the existence of the Superman story as real. It is very unusual to find any new mineral in such a quantity, they are generally found these years only in a few grains under a microscope. The new mineral cannot be named Kryptonite as per naming conventions as it has no relation with the existing elment Krypton. It may be named on the place where it is found as Jadarite.
At Canada's National Research Council (NRC) and the expertise of its researchers, Dr Pamela Whitfield and Dr Yvon Le Page has worked on its novelty as calling it as new calls for rigorous testing. Canadian agencies are working on it for international recognition.
Now that is a news for Superman fans and so is for the Lex Luthor fans as the fiction says its fatal for Superman and boon for Luthor to kill him.

No wonder Superman's new movie may correct the color of the compound :) and says that is the reason why the son of superman didnt have any impact on him with the Green Kryptonite found by Lex [refer Superman Returns , Movie].
Lex's screams," Oh that Kryptonite was contaminated "

## Tuesday, April 24, 2007

### Google - Race for the quantity

Dont know since when has google started lacking common sense. I had been a great fan of Google from the start. It looks like in the race, google is getting into quantity rather than quality.

For instance the Revision History comparison in the Google Docs have started saying "too_many_revisions" in a very disturbing manner. It just means it cannot provide revision comparison for say over above some 25-30 revisions. The purpose of providing revisions is now defeated. It seems to be pun when one says he wants to compare between a 25 version back document. But with saving of the document every few seconds the 25th version is actually a few minutes ago edited document.

Another great thing... google has added a new button to the Google reader that marks all the feeds as read. That provides a great relief but now there are only two options - either to mark all as read or go through every one to mark selective articles as read. That means you just wont be able to mark the feeds as read selectively which are visibly crappy from the subject even if contextual(differs from person to person) .

Sincerely, i am still in love with google in spite of these things. But they must go for improving the current quality before going for quantity (the new presentation services) because they are only known for quality/performance (the era of google search)

## Thursday, April 19, 2007

### Greedy Pirates

Five greedy pirates looted 100 gold coins and now to be divided amongst them. Having different seniorities, the most senior pirate proposes a way out. They will cast a vote and now if at least 50% accepts the proposal, the loot is divided as proposed. Or else the most senior pirate's head is chopped off, and they start again with the next senior pirate. What should be the idea in the mind of seniormost pirate to get the max coins?
Important : Given that they are intelligent enough to think about it :)

Solution
Lets minimize the problem for 3 pirates. To make it easily understandible for 5 pirate situation i assume they are C, D, E in order of decreasing seniority.
Pirate C needs to convince any of the other. So he contacts juniormost pirate E and tells him that if he dont vote him, then i (C) will die. And then in the next round D will vote himself and he will get all the money. In that case you dont get anything. Pirate C offers pirate E 1 gold coin to vote for him. He has no choice but to accept so as to have at least something.

Now 4 pirate situation. B, C, D, E in order of decreasing seniority.
Pirate B sees that if he dies the worst pirate will be pirate D (as it will be a 3 pirate situation with C,D,E). So he contact D and offer him 1 coin and explain him if he dies C and E will get the coins. So he comes to his side and votes for him.

Now our situation A, B, C, D, E in order of decreasing seniority.
Pirate A , sees that if he dies the worst off people will be pirate C and E(as with the situation in BCDE). So he contracts both of them with 1 gold coin offer for each. And takes away 98 gold coins

### Snailing on puzzles

1. What is the next number in this sequence?
1, 11, 21, 1211, 111221, ???

Solution:
Each number in the sequence describes the previous one.
i.e. first number= 1
second number = one one = 11
third number = two ones = 21
fourth number = one two and one one = 1211 and so on
so the sixth number will be 312211

2. You’ve got someone working for you for seven days and a gold bar to pay them. The gold bar is segmented into seven connected pieces. You must give them a piece of gold at the end of every day. If you are only allowed to make two breaks in the gold bar, how do you pay your worker?

Solution:
For this kind of questions , break the bar with the values 1, 2 , 2^2 , 2^3 , 2^4……. i.e in the series of 2^n where n = 0 to n. This combination always have all the natural number values possible upto the total value of bar.

Here it will be accordingly 1, 2 ,4 break
Now day 1, give 1
Day 2, give 2 take 1
Day 3 give 1
Day 4, give 4 take 1,2
Day 5 give 1
Day 6, give 2 take 1
Day 7 give 1

3. You have 5 jars of pills. Each pill weighs 10 gram, except for contaminated pills contained in one jar, where each pill weighs 9 gm. Given a scale, how could you tell which jar had the contaminated pills in just one measurement?

Solution:
Take 1 pill from jar 1 , 2 from 2nd , 3 from 3rd , 4 from 4th and 5 from 5th.
If they all had 10gm pills these pills weigh 150 gms. If jar number n has contaminated pills we have total sum = 150 – n gms. As per pill 1 gram is reduced and we took out n pills from nth jar, so loss in gms = n. And hence it is the nth jar. That means the decrease in value measured drom 150 is the jar number with contaminated pills

4. Bridge
There are 4 people on a side of a bridge. They all have to go to the other side of the bridge. They have a lantern that will last for 17 minutes which is necessary to cross the bridge. Bridge can support only 2 people at once. Having their own individual maximum speed, they can cross the bridge in 1, 2, 5 and 10 minutes respectively. What combination they should use to cross the bridge in time.

Solution:
Here we must ensure that the two slowest persons should not come back to give back the lantern as they will consume the maximum time. To make that possible have the one of the faster persons on the other side every time we need to bring back the lantern. Do this by:

1 and 2 cross the bridge ------- time taken = 2 min
1 comes back --------------------time taken = 3 min
5 and 10 cross -------------------time taken = 13 min
2 comes back --------------------time taken = 15 minutes
1 and 2 cross the bridge --------time taken = 17 minutes

5. You are standing outside the first floor entrance to a building. Next to you is a bank of 3 light switches. One of the switches controls a light bulb in a stock room on the second floor. The other two switches don't control anything. The only way you can check the light on the second floor stock room is to physically walk up the stairs, open the door to the stock room, and check the light. You can do anything to the switches that you want before you walk up the stairs; however you are allowed only one trip up the stairs to check the light. Assuming the light and switches are off to start with, how do you find out which light switch controls the light using only one trip to the room?

Solution:
Needs a little bit of knowledge that bulb get hot when turned on for a while
Turn on the first switch and wait for sometime. Then turn it off and turn on the second.
Move immediately to the room. There can be three cases :
Hot and off bulb -- 1st switch
Cold and glowing bulb -- 2nd switch
Cold and off bulb -- 3rd switch

6. You are on one side a river and need to cross with your dog, chicken and some grain. There is a boat but it is so small it will only be able to carry yourself and one of the items at a time. If you leave the dog and chicken together the dog will chase the chicken away. If you leave the chicken with the grain the chicken will eat the grain.
How do you get yourself and the three items across the river?

Solution:
Dog, chicken, you, grains >>>>>>>>>>>
Dog, grains <<<<<<<<<<<<<<<<<<<< you, chicken
Dog, grains, you >>>>>>>>>>>>>>> chicken
Grains <<<<<<<<<<<<<<<<<<<<<< chicken, you, dog
Grains, you, chicken >>>>>>>>>>>>>>> dog
Chicken <<<<<<<<<<<<<<<<<<<<<< you, dog, grains
Chicken, you >>>>>>>>>>>>>>> dog, grains
------------------------------------------ Dog, chicken, you, grains

7. You are presented with three closed boxes, labeled "Apples", "Oranges", and "Apples and Oranges". Y are told that all the labels are wrong. By looking at a single fruit from one box you can correctly label the three boxes. How?

Solution:
There can be two ways of wrong labeling
1. Original oranges -- apples, Original apples -- Both, Original both -- oranges
2. Original oranges -- both, Original apples -- oranges. Original both -- apples
So pick one from the one labeled both. If it is an oranges then it’s the first case else it’s the second case

8. Given a rectangular cake with a rectangular piece removed (any size or orientation), how would you cut the remainder of the cake into two equal halves with one straight cut of a knife?

Solution:
Join the centers of the original and the removed rectangle. And cut along that line.

9. Cut a circular cake in 8 equal pieces with 3 straight cuts permitted.

Solution:
There is a catch!! Cut at ninety degrees using 2 cuts and then horizontally from the height (remember circular cake is a cylinder)

10. If you had an infinite supply of water and a 5 litre and 3 litre jars, how would you measure exactly 4 litre without extra jar?

Solution:
Fill 5 litre jar and pour 3 litre in the 3 litre jar. Now you have 2 litres remaining in the 5 litre jar. Now empty the 3 litre jar and pour that 2 litres in the 3 litre jar. Now fill 5 litre jar and pour it in the 3 litre jar containing 2 litres already. It can accommodate only 1 more litre. So remaining in the 5 litre jar is 4 litre

### Prisoner puzzle win win situation

The warden meets with 23 new prisoners when they arrive. He tells them, "You may meet today and plan a strategy. But after today, you will be in isolated cells and will have no communication with one another.

"In the prison is a switch room, which contains two light switches labeled A and B, each of which can be in either the 'on' or the 'off' position. I am not telling you their present positions. The switches are not connected to anything.

"After today, from time to time whenever I feel so inclined, I will select one prisoner at random and escort him to the switch room. This prisoner will select one of the two switches and reverse its position. He must move one, but only one of the switches. He can't move both but he can't move none either. Then he'll be led back to his cell.

"No one else will enter the switch room until I lead the next prisoner there, and he'll be instructed to do the same thing. I'm going to choose prisoners at random. I may choose the same guy three times in a row, or I may jump around and come back.

"But, given enough time, everyone will eventually visit the switch room as many times as everyone else. At any time anyone of you may declare to me, 'We have all visited the switch room.'

"If it is true, then you will all be set free. If it is false, and somebody has not yet visited the switch room, you will be fed to the alligators."

Now what you got to do is plan for them and find a win win situation

Show/Hide

We may use 1 switch for a tag and the other just for changing state as it is given the prisoner have to change the state of 1 switch.

Chose a leader who will count (count what?? is explained below).
So lets say we chose switch A in the on conditions as a tag that a new prisoner has visited the room.
Only the leader can turn off the switch A and adds 1 to his count every time he turns it off. But he himslef doesnot turns it on (so as not to confuse himself with the count). If leader finds it in the off state(he visited consecutively) already he should change the state of switch B

Everytime a new prisoner comes if he finds the switch A in off condition(that means the count has been taken in account) he can switch it on. If he finds it in on condition or he had earlier changed the state of switch A to on then change the state of B.

This way the leader will count the number of on states of switch A and then change it to off state. Taking in account ,if the starting state of switch A is on. He may count it as a visited prisoner. So counting this case and 22 changed on states(he himself is the 23rd person) = 23 is the count which the leader got to reach to ensure that all of them has visited.
And then he can tell the warden that everyone has visited the room

## Wednesday, April 18, 2007

### Lateral Thinking

Now this has been a lateral thinking puzzle boggling minds.

1 seven seas
2 split level
3 forgive and forget
4 missing you
5 Downtown
6 lucky break
7 he's by himself
8 see through blouse
9 first aid
10 west indies
11 6 feet underground
12 backward glance
13 tricycle
14 reading between the lines
16 three degrees below 0
17 neon lights
18 just between you and me
19 one in a million
20 broken promise
21 you are out of touch
22 life begins at 40
23 Jack in a box
24 Growing economy
25 up before 8
26 just around the corner
27 Apple pie
28 making up for lost time
29 standing ovation
30 I understand you undertake to undermine my undertaking