Jignesh Malavia

Author
+ Follow
since May 18, 2001
Merit badge: grant badges
For More
Cows and Likes
Cows
Total received
0
In last 30 days
0
Total given
0
Likes
Total received
0
Received in last 30 days
0
Total given
0
Given in last 30 days
0
Forums and Threads
Scavenger Hunt
expand Ranch Hand Scavenger Hunt
expand Greenhorn Scavenger Hunt

Recent posts by Jignesh Malavia

Originally posted by Sameer Jamal:

other short approach can be
Suppose A takes T time to reach bottom (or 50 steps) when escalater is moving
For B to take 90 steps it will require T/5 time
total no of steps in escalater= (90T-50T/5)/T-T/5
=80T/4T/5=100 STEPS


Wow
20 years ago
#4 (Probably not the best approach. Too long..)
Let D = number of steps
Let S = constant speed of escalator (that is, it goes down at the rate of S steps/second)
Let sa = speed of A (sa steps/second) when escalator is stationary.
Let sb = speed of B (sb steps/second) when escalator is stationary.
If the escalator is moving at speed S, and A is walking at speed sa, then the effective speed of A is S+sa
If the escalator is moving at speed S, and B is running at speed sb, then the effective speed of B is S+sb
Let T = time required by escalator to cover D steps.
Let ta = time required by A to cover D steps when escalator is stationary.
Let ta50 = time required by A to cover 50 steps when escalator is stationary.
Let taeff = effective time required by A to cover 50 steps when escalator is moving.
Let tb = time required by B to cover D steps when escalator is stationary.
Let tb90 = time required by B to cover 90 steps when escalator is stationary.
Let tbeff = effective time required by B to cover 90 steps when escalator is moving.
Therefore,
D = S*T
D = sa*ta
D = sb*tb
50 = sa*ta50 (for A walking on stationary escalator) --- 1
90 = sb*tb90 (for B running on stationary escalator) --- 2
D = (S+sa)*taeff (for A walking on moving escalator) --- 3
D = (S+sb)*tbeff (for B running on moving escalator) --- 4
For A, the time required to reach the bottom while escalator is moving is same as the time required to walk 50 steps.
Thus, ta50 == taeff.
or 50/sa = D/(S+sa) --- [from 1 and 3]
or D = ((S+sa)*50)/sa --- 5

For B, the time required to reach the bottom while escalator is moving is same as the time required to run 90 steps.
Thus, tb90 == tbeff.
90/sa = D/(S+sb) --- [from 2 and 4]
or D = ((S+sb)*90)/sb --- 6
Also, B coveres all 90 steps when A has covered only 10 steps == 1/5th the total steps for A. Thus, effective speed of B is five times effective speed of A
(S+sb) = 5*(S+sa)
Replacing S+sb with 5*(S+sa) in 6 gives
D = 5*(S+sb)*90/sb --- 7
Combine 5 and 7
(S+sa)*50/sa == 450(S+sa)/sb
thus sb/sa = 9
B goes 9 times faster then A
Solving for eq 5 and 6 using sb=9*sa gives S = sa.
Using S = sa in 5 gives D = 100.
Answer: 100 steps are visible when the escalator is not operating.
A walks at the same speed as the escalator and thus reaches in half the normal time = A covers 50 steps + escalator covers 50 steps.
B runs at the 9 times the speed of escalator and thus reaches in 1/10th the normal time = B covers 90 stpes + escalator covers 10 steps.
20 years ago

Originally posted by leandro oliveira:
guys, I've requested this page many times, and what I could notice was that for each request, tomcat 5.0 created a new instance of this page. Last night I did 4600 requests to this resource and 4600 objects were created, my memory usage increased linearly... I'm afraid of using singleThreadModel in a highly visited aplication, since we may have OutOfMemoryError...


Originally posted by leandro oliveira:
guys, I've requested this page many times, and what I could notice was that for each request, tomcat 5.0 created a new instance of this page. Last night I did 4600 requests to this resource and 4600 objects were created, my memory usage increased linearly... I'm afraid of using singleThreadModel in a highly visited aplication, since we may have OutOfMemoryError...


Hi,
I think you wanted to use this construct
<%!{qtdInstances++;}%>
Note the ! in <%! to make it an instance initializer. Without !, it is just a scriplet (part of the _jspService method) that will be executed for each request, hence the high value printed by <%=qtdInstances%>
Also, as Michael suggested, you probably don't want to use isThreadSafe or SingleThreadModel at all. That interface is depricated in the new version of the specs.

Originally posted by Mapraputa Is:
If we express ourselves by behaving like everybody else, then we don't express too much.


asds2 sds2f fkpf- fdjfjd;g;lckgs' jkdsjf g dgdgs g2rg
[Translation:
If we don't express ourselves in a language understood by everybody else, then we don't express anything.]
Isn't proper use of body language as important as that of the written or spoken ones for effective and 'unambigious' communication? Random acts of twisting ones body are probably as meaningful as randomly uttered words.
20 years ago

Originally posted by Bert Bates:

3 - A 2 dimensional, geometric 'point' of light will be placed, whereever you want it, inside the shape.


Has it anything to do with wave interference? Like if there is a wall with very thin slits in it within the closed space, then the light rays originating from a single 'point' source produce bright and dark areas on the other side of the wall?
20 years ago
ok got it. Bert's right (if he thought about that, not clear from his post).
Flipping ANY ONE die will change from odd to even and vice versa.
20 years ago
Oh! no. oooooppss.. Flipping all of them won't work.. you are right Jim.
i mean flipping all does not necessarily change from odd to even or otherwise.
[ September 18, 2003: Message edited by: Jignesh Malavia ]
20 years ago

Originally posted by Bert Bates:
Can any of the die be flipped to have another side up?


I guess flipping is required because :
a) The current sum is 35, an odd number, and there is no way to divide them into two equal-valued groups.
b) Varun said that two opposite sides add up to 7 is the main key to the solution.
Also, if the current sum is odd and if you flip over "all" the dice, then you get an even number and vice versa. So extending Joel's idea, I guess the first step would be to flip "all" the dice to make the sum even. After that we can think of all the possibilities probably.
20 years ago

Originally posted by Hans Dorst:
Hi,
I've been thinking about how to swap boolean values without using helper variables


How's this?
a = (a==b);
b = (a==b);
a = (a==b);
20 years ago
Yup!
You both get an A+ :-)
20 years ago
Write a program that converts Roman numerals to Arabic and reverse.
Values:
I = 1 (one)
V = 5 (five)
X = 10 (ten)
L = 50 (fifty)
C = 100 (one hundred)
D = 500 (five hundred)
M = 1000 (one thousand)
Examples:
30 is written as XXX but 15 is not written as VVV
40 is written as XL but 45 is not written as VL
9 is written as IX but 49 is not written as IL and 99 is not written as IC
243 is written as CCXLIII
1510 is written as MDX
1999 is written as MCMXCIX
4,9,40,90,400,900 == IV,IX,XL,XC,CC,CM respectively
Rules:
1) No googling for any more rules or hints.
PS:
If the above is just plain boring, then you can solve this quiz or read about the 1999 problem
20 years ago

Originally posted by Jason Menard:


2^5 won't work because there is no 2
Yes, but we can get one using (5+5)/5
Even if it were to be used, then you could get something like 5^5. but not 2^5.
(((5+5)/5)^5)+5 = 37
Bit shifting, while being a Java operator, is also not a math operator in the true sense of the word (human beings have no need to bit encode digits to manipulate them, that's a computer thing).
Well, okay. If it were allowed, my answer was ((5/5)<<5)|5|5
You're best bet would be to stick with the normal mathematical operators imho.
So is factorial (!) allowed? In that case Michael Dunn was pretty close.
(5 x 5) + 5! - (5!/5)
(5 * 5) + (5! / (5+5))
20 years ago
hints
a) 2^5=32 (if power is allowed)
b) 1<<5=32 and 5|5=5
20 years ago
Thanks Paul.

Originally posted by rahul dighe:
HI,
with regard to issues related to using include directive vs standard action there is a statement
"The include directive interprets its file attribute relative to the current jsp file whereas <jsp:include> actions are interpreted relative to the current JSP Page"??
i can't seem to understand the difference in the terms how is the "file" different from the "page" ?? can anyone please try to explain


Rahul,
The phrases "relative to the jsp file" and "relative to the jsp page", mean that when the container has to select an included component using a relative URL, it looks at the file's current physical location in case of the directive while it looks at the page's current URL in case of the action.
To make it clear, suppose we have the following four conditions
1) A directory structure like this
doc-root/dir1/
doc-root/dir1/a.jsp
doc-root/dir1/b.jsp
doc-root/dir2/
doc-root/dir2/b.jsp <--- note this
2) a.jsp includes b.jsp twice, once using the dirctive and once using the action as follows
<%@ include file='b.jsp'%>
<jsp:include page='b.jsp' />
Note that in both the cases, file and page, we are using non-root-relative URLs. That is, the URL of the included component is relative to the current JSP file and current JSP page respectively.
3) web.xml has a <servlet> entry with a <servlet-name> A and <jsp-file> /dir1/a.jsp
4) web.xml has two <servlet-mapping> entries
4a) <url-pattern> /dir1/a.jsp is mapped to <servlet-name> A
4b) <url-pattern> /dir2/a.jsp is mapped to <servlet-name> A
Note a.jsp does not exist in dir2. In 4b, /dir2/a.jsp is just a mapping.
We can access the same jsp page in two ways
First- using http://.../dir1/a.jsp
Second- using <a href="http://.../<b rel="nofollow">dir2</b>/a.jsp" target="_blank">http://.../dir2/a.jsp
Both the above will invoke the servlet named A, which is actually the same a.jsp page
In the first case,
a.jsp will include b.jsp from dir1 because of the include directive
a.jsp will include b.jsp from dir1 because of the include action
In the second case,
a.jsp will include b.jsp from dir1 because of the include directive
a.jsp will include b.jsp from dir2 because of include action
Reason - when we use http://.../dir2/a.jsp, the container searches for b.jsp using .../dir2/ as its base URL.
Hope that helps
Now to have more fun, try this
1. Create a file named c.jsp in dir2
2. Declare a servlet named C and point to file /dir2/c.jsp in web.xml
3. map servlet C to the url <a href="http://.../dir2/<b rel="nofollow">b</b>.jsp" target="_blank">http://.../dir2/b.jsp
4. Then access a.jsp using http://.../dir1/a.jsp
5. Then access a.jsp using http://.../dir2/a.jsp
And observe what you get in steps 4 and 5.

Originally posted by Anupam Sinha:


Can someone explain the theory of relativity in smple words
If we measure something, then the measurements are relative to from where we are measuring and what is used to measure. Simplest example: the speed of a moving train can be measured using a simple watch and observing two points on the tracks. But if the train was moving at speeds close to that of light, then the observer will not be able to measure those speeds acurately just by observing with his eyes because his 'view' is dependent on the light travelled from that train to his eyes. He will start and stop the timer when he 'sees' the train passing those points on the tracks.
Can this theory be used to go back in time.
There's an old limerick about it
There was a girl named Ms. Bright
Who could travel faster than light
She set out one day
The Einsteinian way
And returned the previous night!
20 years ago