Thursday, February 25, 2010

Solve this one....... Knockout series.

Once my friend asked me, do you know knockout series. I said yes. He said, "well then tell me how many matches will be played among 500 players"? If you are able to give this answer than tell me how much matches will be played among 1000 players? But in the later question if you have taken time more than 30 sec then you are gone.......

Disclaimers:: Do not see the comments unless:

1. You have solved it or
2. See first comment only if you have doubt.....

Thursday, October 8, 2009

"Break Statement" does not work with for( var X in ArrayVariable) in javascript

"Break Statement" does not work with for( var X in ArrayVariable) in javascript.

Wednesday, September 2, 2009

Boss please do not shot at me otherwise shot at me using option.......

Once my boss asked me for status of my module, I gave a pathetic reply.
He got angered and come with a gun (having six rack) and two bullets. He put the two bullet in consecutive rack and point at me.

I pleaded for my life. Showing little mercy, he rotate the rack and fire ......... ahh....


Being lucky, i did not meet with my final fate. Now, he got cooled and gave me two options:

a) either he will use the same loaded gun to check for my fate, OR

b) he will again rotate the barrel.


I said boss please do not shot at me otherwise shot at me using option x....



Please tell me which option i should go ahead (Remember movie 21, variable change concept J).

When my boss sent me to stone age.

I am writing this entry with assumption, my boss don't kill me after reading this post.

Once my super boss asked me to go to stone age to help a new shopkeeper who wanted to become guru in grains selling business. Being smart chap, he did some market analysis on selling of grains. He then found out the customers are purchasing grains weighing any integral value from 1 to 40. Now he went to kilomaker and requested him for few weights. But Kilomaker said, he can prepare only four weights for him.

Now, how should i help shopkeeper to choose the four weights, that can be used to measure any weight from 1 to 40 in one go?

Now i can come back only if i finish my task.



Solutions:

Possiblites using mathematical operation(summation and substraction):

1) a
2) b
3) c
4) d


5) a + b
6) a + c
7) a + d
8) b + c
9) b + d
10) c + d


11) a + b + c
12) a + b + d
13) a + c + d
14) b + c + d


15) a + b + c + d


16) a - b
17) a - c
18) a - d
19) b - c
20) b - d
21) c - d


22) a + b - c
23) a + b - d
24) a + c - b
25) a + c - d
26) a + d - b
27) a + d - c
28) b + c - a
29) b + c - d
30) b + d - a
31) b + d - c
32) c + d - a
33) c + d - b


34) a + b - c - d
35) a + c - b - d
36) a + d - b - c


37) a + b + c - d
38) a + b + d - c
39) a + c + d - b
40) b + c + d - a





Final Answer:

1, 3, 9, 27



Brief explaination:

1, 3 , 9 can uniquely represents 1 to 13.
So it can be used to get number from (14 to 26) if substracted through 27
and number(28 + 40) if added to 27.




Detailed explaination:

1 = 1
2 = 3 - 1
3 = 3
4 = 3 + 1
5 = 9 - 3 - 1
6 = 9 - 3
7 = 9 - 3 + 1
8 = 9 - 1
9 = 9
10 = 9 + 1
11 = 9 + 3 - 1
12 = 9 + 3
13 = 9 + 3 + 1
14 = 27 - 9 - 3 - 1
15 = 27 - 9 - 3
16 = 27 - 9 - 3 + 1
17 = 27 - 9 - 1
18 = 27 - 9
19 = 27 - 9 + 1
20 = 27 - 9 + 3 - 1
21 = 27 - 9 + 3
22 = 27 - 9 + 3 + 1
23 = 27 - 3 - 1
24 = 27 - 3
25 = 27 - 3 + 1
26 = 27 - 1
27 = 27
28 = 27 + 1
29 = 27 + 3 - 1
30 = 27 + 3
31 = 27 + 3 + 1
32 = 27 + 9 - 3 - 1
33 = 27 + 9 - 3
34 = 27 + 9 - 3 + 1
35 = 27 + 9 - 1
36 = 27 + 9
37 = 27 + 9 + 1
38 = 27 + 9 + 3 - 1
39 = 27 + 9 + 3
40 = 27 + 9 + 3 + 1





Moving towards rays in dark



How to come on these number ?


Step 1: We need to measure 1, conclusion
a. One of number should be 1. Or,
b. Two number should be consecutive.

Step 2: We need to measure 2,
a. Two number difference should be 2.
b. Second number should be 2.

Step 3: We need to measure 3:
a. The number should be itself 3.
b .Two number difference 3.
c. Addition of 1 and 2 as 3. This will voilate our uniqure constraints ( 2 - 1 = 1 i.e a - b = b) .

So we can have either 1 or 2.

So, one of the possible two number are 1 and 3. And these uniquely represent 1, 2, 3, 4 and it will
also helps us to represent 40, 39 , 38 , 37(to represents +4, -4 number from a given number.)


Going ahead on this line,

we are left with c + d = 36.

Now to represents 1 to uniquely
third number should be 9 or difference of other two number i.e c and d should be 9.

let assume second case,

c + (c + 9) = 36
=> 2c = 27

which will give us decimal value so ruled out. So third number is 9 and which makes 4rth as 27.




~ njoy
Anand

Sunday, August 16, 2009

Reading select component selected values in javascript

Reading select component selected values in javascript:

1. If you have the select object as SelectObject:

SelectObject.options[SelectObject.selectedIndex].value

2. If you are passing the value to javascript function through this component only

function(this.options[this.selectedIndex].value);

Tuesday, February 17, 2009

Basic java interview questions and topics.

While facing any interview we generally got panicked. This state come because we dont know what to study and what not study. Java in itself is vry vast topics. And it is difficult for anyone to cover each technology with Java.

So my advice is to solidify few things. By the Core java is must. For Studying core java. When pointer come to book, let me tell you i am big fan of Cathy.

If you are new learner then head first java is kewl. What you need to do is simply follow that. Beside i suggests you to give SCJP. It is not too easy but not too tough . Again if you follow Cathy scwcd book , you will score the descent marks. I too got 91% ( :-) thanks cathy).

Let me come to point. The topics , question imp for core java are:

1) What is enum? its use and syntax? Can we define enum as class? if yes how?
2) What is static variable ? what its concept ?
3) Abstarct class and inheritenc?
4) Differnece between an abstract class and interface ? Why interface if we have abstract class (interviewer gotcha here. They want to prove their smartness here.)
5) Can we have class with abstract and final modifier?
6) What is protected and default modifiers?
7) Generics concept?
8) File IO? You must write a code to practice it?
9) Serialization and its concept? transcient variables and static variable ? how it effects serialization?
10) Inheritence and encapsualtion?
11) Then the big pictures of exception handling, garbage collection?
12) Inner classes and their implications on others?
13) Collections(List, Map, set,) collections, array, comparable and comparator class.
14) Threads(worst topics)



Then they will ask you :
1) singleton class
2) factories and its need

JDBC
1) What is the flow? How class is register ? use of for etc? diference between statement and parameteised statement(prepared query)?

Hey i am getting late for home, problably i can edit this next time and try to add some good topics/ questions also?

Wednesday, February 4, 2009

Myself

Hi, i am anand jha a punekar.