Hi All,
So I am here back again with a new interesting puzzle ( courtesy Vaibhav Gupta ). I am copying his mail verbatim below followed by the solution that I have in mind.
---------- Puzzle ------
NECKLACE PUZZLE #2
There are two circular necklaces with same number of three types of gemstones,
but the gemstones may be strung in different order along the necklace.
Now the two necklaces are placed on one top of the other so that the
gems are aligned
one above the other. Count the number of locations where the pair of
gems (one from
the lower necklace, one from the upper) is of the same type.
Since one necklace can be rotated relatively to the other, there are
many orientations
in which the count of matching gems can be taken.
Prove that there is at least one orientation where the number of
matches is at least
a certain number v.
For the special case of equal numbers of each kind of gem, v = N/3,
where N = total number of gems in one necklace (and 3 kinds of gems).
1. prove this for the special case.
2. find, with proof, value of v in the general case (with m kinds of
gems not necessarily equal in number).
some clarifications:
1. the necklace is circular i.e. its a simple closed loop. so given
two necklaces RGB and RBG,
the second can be rotated wrt first to give three orientations (but
this small example
is unusual because the number of matches is same in all 3 orientations):
RGB
RBG 1 matches
RGB
GRB 1 matches
RGB
BGR 1 matches
so v = 1
2. "there is at least one orientation where the number of matches is
at least v"
label the orientations from 1 to N. denote the number of matches for
orientation i as m[i].
then " there exists an i such that m[i] >= v" is the more formal way
of saying this.
-Vaibhav.
------------------
Well, indeed an interesting puzzle. Intially for a few minutes I thought whether it can be proved by contradiction or not. I tried to see whether I am able to hit a contradiction by imagining that "v is always less than N/3". Within a few minutes I realized that this is not going to work. As I remembered the lessons from Prof Sundar Vishvanathan , I thought of trying to prove it by induction. Prof Sundar always used to say that most of the proofs can be given by the principle of mathematical induction. This time I did not bank too much on this options as I learnt it from my earlier experience as I mentioned in my previous post. The solution of this proof also along the line which was taught to me by Prof Sundar.
The proof here makes use of the fact that if expected value of some random variable is a then there exist a possibility where the random variables has a values at least a.
Let us assume that first necklace is fixed and the second necklace is rotated with respect to the first one. Let us define a random variable X such that
X_i = 1 ( if ith gem of first necklace matches with the second one )
X_i = 0 Otherwise.
The ordering in the second necklace can be anything so assuming a uniform distribution there.
Calculating the expected value,
E(X_i) = Pr(X_i).X_i = (Number of gems having the same colour as ith gem/Total number of gems)
For 3 different kind of gems
E(X) = Sum(i=1 to N) ( E(X_i) ) = R^2/N + B^2 /N + G^2/N.
For the special case where R = B = G = N/3 we will have
E(X) = N/3. As the expected value is N/3 we can say that there is at least one configuration of second necklace which would make the number of matching gems at least N/3.
When there are m kinds of gems, not necessarily equal in number, let C[i] denote the number of gems of the same kind as i, where i varies from 1 to m.
Therefore, for general case the expected value is
E(X) = Sum (i = 1 to n ) ( C[i]^2/N )
Well, a nice puzzle indeed. As a closing remark, I have the solutions to the puzzle that I mentioned in my previous post. It will require some figures to be embedded to explain the solution in a lucid way. I will post it soon as I get the time.
Tuesday, May 29, 2007
Friday, May 11, 2007
Necklace Theorem
Hi all,
As mentioned in my last post, after lunch talks can be very fruitful at times. Describing a yet another fruitful chat with my friend Sambuddha Roy.
The other day he gave me an interesting problem to think about, which is formerly known as, as he told me, necklace theorem. Two thieves have stolen queen's very precious necklace. There are three kinds of gems in the necklace called R, G and B. All are even. The problem is to divide the necklace in such a way that both the thieves get equal amount of gems of each kind. The necklace can have any interleaving of the gems. ( e.g. RRGBGGRBBBG..... ) Prove that it is always sufficient to divide the necklace in equal share by at most 3 cuts.
The proof makes use of Ham Sandwich Theorem. For brevity, I will quote it as HST now on. HST for 2-dimension says that given any two point sets in a plane, there always exist a line which will cut both these point sets simultaneously into half. To say it more formally, call the point sets R and B. Then one side of line will contain at most |R|/2 points and at most |B|/2 points. The same constraints will be followed on the other side too.
If there is only 1 point set R. For a given direction we can always have a line which will divide R in two. The proof is based on intermediate value theorem. It says that for a continuous function if f(x1) = 0 and f(x2)=1 then there exist a z \in (x1,x2) such that f(z) = 1/2.
Now that we have two point sets. What we can do is we get a line for point set R. Now we evaluate how this line L behaves with respect to B. Let us define diff(L) = number of blue gems on the left of L - number of blue gems on the right of L. For initial line L, let the value of diff(L) be b. What we can do is rotate this line a bit. We know that for any given direction, we have a corresponding line L which will divide R equally. We will again evaluate wrt B. We keep on doing this until we have rotated the line for 180 degree. At this point value of diff(L) would be -b. From intermediate value theorem, we can state that there will be a line where diff(L) will be 0.
How about, Ham Sandwich theorem in 3-dimension?? Well, my friend has given me the proof as an exercise. The statement is that given 3 point sets R, G, B in R^3 ( or 3-dim space ) there always exist a plane which will divide all 3 point sets simultaneously into equal portion.
Now, we need to reduce Necklace Theorem to HST in 3D. Starting from left to right, assign every gem an index i. Plot a parametric curve ( t, t^2, t^3 ) using these indices. HST assures us that we will have a plane ax+by+cz+d=0 which will divide R, G, B equally. This plane will divide the parametric curve at , at most 3 points as at + bt^2 + ct^3 + d = 0 will have at most 3 roots. Now, it is easy to map these 3 intersection points on the curve to 3 cuts on the necklace.
Phew!!! It never occurred to me that this proof will use such weird things. Induction based method was too tempting for me to let me think in some different direction. But the story is not over yet. The proof given above is not constructive. So if we were to find an algorithm to find these 3 cuts we might have to explore all possibilities taking O(n^3) time. So another exercise would be to try to find more efficient algorithm to find these cuts.
The generalization of HST is that given k point sets in R^k there would be always be a hyperplane which would cut all these k point sets simultaneously into equal portion. Yet another generalization one can think of is that, what if there are more thieves??? Given q number of thieves and k kind of gems, what would be the upper bound on the number of cuts required?? The answer is due to dold's theorem ( Neither sambuddha nor I have read the proof ). It say that for such situation at most k(q-1) cuts would be necessary.
What if there are 3-point sets in two dimension?? Definitely a line would not suffice. An exercise would be to prove that two rays originating from an apex would be sufficient. Give an algorithm for finding them out.
Two more puzzles are :
1) Given a point set of size n in 2D, prove that there would exist a pair of orthogonal lines which would divide the point set in such a way that in each quadrant number of points are at most n/4.
2) Given a point set of size n in 2D, prove that there would exist 3 concurrent lines which would divide the point set in such a way that in each segment the number of points are at most n/6.
That's enough to tease our brain for a while :D.
As mentioned in my last post, after lunch talks can be very fruitful at times. Describing a yet another fruitful chat with my friend Sambuddha Roy.
The other day he gave me an interesting problem to think about, which is formerly known as, as he told me, necklace theorem. Two thieves have stolen queen's very precious necklace. There are three kinds of gems in the necklace called R, G and B. All are even. The problem is to divide the necklace in such a way that both the thieves get equal amount of gems of each kind. The necklace can have any interleaving of the gems. ( e.g. RRGBGGRBBBG..... ) Prove that it is always sufficient to divide the necklace in equal share by at most 3 cuts.
The proof makes use of Ham Sandwich Theorem. For brevity, I will quote it as HST now on. HST for 2-dimension says that given any two point sets in a plane, there always exist a line which will cut both these point sets simultaneously into half. To say it more formally, call the point sets R and B. Then one side of line will contain at most |R|/2 points and at most |B|/2 points. The same constraints will be followed on the other side too.
If there is only 1 point set R. For a given direction we can always have a line which will divide R in two. The proof is based on intermediate value theorem. It says that for a continuous function if f(x1) = 0 and f(x2)=1 then there exist a z \in (x1,x2) such that f(z) = 1/2.
Now that we have two point sets. What we can do is we get a line for point set R. Now we evaluate how this line L behaves with respect to B. Let us define diff(L) = number of blue gems on the left of L - number of blue gems on the right of L. For initial line L, let the value of diff(L) be b. What we can do is rotate this line a bit. We know that for any given direction, we have a corresponding line L which will divide R equally. We will again evaluate wrt B. We keep on doing this until we have rotated the line for 180 degree. At this point value of diff(L) would be -b. From intermediate value theorem, we can state that there will be a line where diff(L) will be 0.
How about, Ham Sandwich theorem in 3-dimension?? Well, my friend has given me the proof as an exercise. The statement is that given 3 point sets R, G, B in R^3 ( or 3-dim space ) there always exist a plane which will divide all 3 point sets simultaneously into equal portion.
Now, we need to reduce Necklace Theorem to HST in 3D. Starting from left to right, assign every gem an index i. Plot a parametric curve ( t, t^2, t^3 ) using these indices. HST assures us that we will have a plane ax+by+cz+d=0 which will divide R, G, B equally. This plane will divide the parametric curve at , at most 3 points as at + bt^2 + ct^3 + d = 0 will have at most 3 roots. Now, it is easy to map these 3 intersection points on the curve to 3 cuts on the necklace.
Phew!!! It never occurred to me that this proof will use such weird things. Induction based method was too tempting for me to let me think in some different direction. But the story is not over yet. The proof given above is not constructive. So if we were to find an algorithm to find these 3 cuts we might have to explore all possibilities taking O(n^3) time. So another exercise would be to try to find more efficient algorithm to find these cuts.
The generalization of HST is that given k point sets in R^k there would be always be a hyperplane which would cut all these k point sets simultaneously into equal portion. Yet another generalization one can think of is that, what if there are more thieves??? Given q number of thieves and k kind of gems, what would be the upper bound on the number of cuts required?? The answer is due to dold's theorem ( Neither sambuddha nor I have read the proof ). It say that for such situation at most k(q-1) cuts would be necessary.
What if there are 3-point sets in two dimension?? Definitely a line would not suffice. An exercise would be to prove that two rays originating from an apex would be sufficient. Give an algorithm for finding them out.
Two more puzzles are :
1) Given a point set of size n in 2D, prove that there would exist a pair of orthogonal lines which would divide the point set in such a way that in each quadrant number of points are at most n/4.
2) Given a point set of size n in 2D, prove that there would exist 3 concurrent lines which would divide the point set in such a way that in each segment the number of points are at most n/6.
That's enough to tease our brain for a while :D.
Posted by
Saurabh Joshi
at
2:10 PM
Labels:
algorithms,
mathematics,
theorems
Wednesday, May 02, 2007
After lunch talks
Hi,
It's been a long pause on my blog. I would say nothing significant to write. Even in this post not much significant but few small interesting pieces of interesting discussion.
Sometimes we go to IRL foyer after lunch and have some discussion. At times, those discussions are fruitful too. By fruitful, I mean it adds something in your knowledge. For example, today I was chatting with my friend Sambuddha . He is a very good narrator, I must admit. He was talking about his BTech advisor Manindra Agrawal who has been awarded with a Godel Prize.
He narrated an incident when Prof Manindra was out to present his work on a conference. There were a few Fields medalist , who were unable to grasp the idea of a young talent like Prof Manindra taking away the Godel prize on the same problem that they once tried to tackle. As Prof Manindra was presenting his talks, these fellows tried to interrupt him in order to embarrass him every now and then. At one point, a question was posed on such a trivial thing that Prof Manindra could not resist but say "I don't know about the undergraduates in US, but I can assure you that any undergraduate student in India would be able to understand this". Needless to say, no further interruptions occurred during his presentation :-).
There were also a few things that I came to know like a complexity class ( NP^NP ) as well as
game of Hex, Secretary Problem and things like that.
Sometimes, chatting can be more brain stimulating than the work :-)
It's been a long pause on my blog. I would say nothing significant to write. Even in this post not much significant but few small interesting pieces of interesting discussion.
Sometimes we go to IRL foyer after lunch and have some discussion. At times, those discussions are fruitful too. By fruitful, I mean it adds something in your knowledge. For example, today I was chatting with my friend Sambuddha . He is a very good narrator, I must admit. He was talking about his BTech advisor Manindra Agrawal who has been awarded with a Godel Prize.
He narrated an incident when Prof Manindra was out to present his work on a conference. There were a few Fields medalist , who were unable to grasp the idea of a young talent like Prof Manindra taking away the Godel prize on the same problem that they once tried to tackle. As Prof Manindra was presenting his talks, these fellows tried to interrupt him in order to embarrass him every now and then. At one point, a question was posed on such a trivial thing that Prof Manindra could not resist but say "I don't know about the undergraduates in US, but I can assure you that any undergraduate student in India would be able to understand this". Needless to say, no further interruptions occurred during his presentation :-).
There were also a few things that I came to know like a complexity class ( NP^NP ) as well as
game of Hex, Secretary Problem and things like that.
Sometimes, chatting can be more brain stimulating than the work :-)
Posted by
Saurabh Joshi
at
3:03 PM
Thursday, March 08, 2007
Sudoku Solver
It is very unlikely for me to post twice in a day, yet I am back again. I had a little idle time at my disposal so I thought to put it to some use.
A couple of months back I read in Times of India about world Sudoku championship which was to happen in March 2007. In addition to the day to day sudoku puzzles they included certain variation of the puzzle too, to encourage readers to take part as well as to stimulate their brain :D.
Sudoku took over my mind during those days and I was completely engrossed in reading about Sudoku as well as solving them at websudoku . It occurred to me why not write a program to solving the puzzle? So I took up the task and was ready with a small Sudoku Solver .
Of course, for certain inputs it does not give the solution. I pondered over the completeness and soundness issues of the initial sudoku board. I don't know whether it is appropriate to use these terms which are often used and associated with algorithms. Let me define it this way. Completeness means that the initial information given in the board should be sufficient to solve the puzzle by using only inferences ( No guessing game/No coin tossing/ No breaking tie). In other words, there must exist at most one solution that can be derived from the initial configuration of the board. Soundness means that the information should not be conflicting, or say, at least one solution exist that can be derived from the initial information. I discussed the matter with my mathematics teacher Mr Motilal Panigrahi at GCET .
We could not arrive at any definitive proofs or conditions to ensure the soundness and completeness, but it was nice to chat with him over these things years after I left the college.
A couple of months back I read in Times of India about world Sudoku championship which was to happen in March 2007. In addition to the day to day sudoku puzzles they included certain variation of the puzzle too, to encourage readers to take part as well as to stimulate their brain :D.
Sudoku took over my mind during those days and I was completely engrossed in reading about Sudoku as well as solving them at websudoku . It occurred to me why not write a program to solving the puzzle? So I took up the task and was ready with a small Sudoku Solver .
Of course, for certain inputs it does not give the solution. I pondered over the completeness and soundness issues of the initial sudoku board. I don't know whether it is appropriate to use these terms which are often used and associated with algorithms. Let me define it this way. Completeness means that the initial information given in the board should be sufficient to solve the puzzle by using only inferences ( No guessing game/No coin tossing/ No breaking tie). In other words, there must exist at most one solution that can be derived from the initial configuration of the board. Soundness means that the information should not be conflicting, or say, at least one solution exist that can be derived from the initial information. I discussed the matter with my mathematics teacher Mr Motilal Panigrahi at GCET .
We could not arrive at any definitive proofs or conditions to ensure the soundness and completeness, but it was nice to chat with him over these things years after I left the college.
Posted by
Saurabh Joshi
at
5:43 PM
Labels:
mathematics,
programming
Sherlock Holmes
Lately, I have been reading famous "Sherlock Holmes" stories. What a nice piece of literature it is! Sir Arthur Conan Doyle is truly a master of creating writings that hold the reader till the end. It really takes a true genius to create such a timeless character like Sherlock Holmes.
Though, some of the inferences employed by Sherlock Holmes in unleashing the truth seems to be unrealistic, I especially admire the literature for the flair with which the author wrote it. The description of a scene creates enough impact on your mind to force it to weave a virtual world around as if you are witnessing the entire series of events. Author has put to use his vocabulary so perfectly that it does not drive away a reader with average vocabulary and yet maintaining enough variations to make it far from banal. I wish I could attain at least 1/20th of author's writing skill.
Now I know, why Sir Arthur Conan Doyle was awarded knighthood. :-)
Though, some of the inferences employed by Sherlock Holmes in unleashing the truth seems to be unrealistic, I especially admire the literature for the flair with which the author wrote it. The description of a scene creates enough impact on your mind to force it to weave a virtual world around as if you are witnessing the entire series of events. Author has put to use his vocabulary so perfectly that it does not drive away a reader with average vocabulary and yet maintaining enough variations to make it far from banal. I wish I could attain at least 1/20th of author's writing skill.
Now I know, why Sir Arthur Conan Doyle was awarded knighthood. :-)
Monday, February 12, 2007
Bitwise fiasco
Yesterday was one of the worst day. It was the day of Bitwise 2007 . I participated in this contest with Pranjal as my team mate. I had really high hopes and a bit of arrogance as I could claim 26th rank in this prestigious contest last time amongst 2700 participating teams. Bitwise 2006 was my first official participation in a programming contest. Having done so well in my debut, I was dreaming to climb further up the ladder with Pranjal ( who secured 8th rank in Bitwise 2006 ) along the side.
The arrogance had fogged the part of the brain which does rational thinking, and I ended up starting my day without any kind of warm up practice for the contest. I had not even revised any relevant material.
Bitwise 2k7 started a little late than the announced time of 1300hrs. And as usual, I thought to attempt the "easier" problems ( 100 points ) first. It was based on graph theory where one was required to find out the vertice(s) having the minimum distance to all other vertices in a given tree. Initially, I started with an O(n^3) implementation and when I found the response of the system to be "Time Limit Exceeded" ( which was kind of obvious with such a naive approach to the problem ), I improved it to O(n^2). Even though, I tried harder I could neither change the complexity nor the response of the system. After 2-3 failed attempts I decided to concentrate on some other problem and come back to this one at a later time.
Problem 4, had two parts, the initial part was to decide whether a certain door k out of n will be open or closed having gone through a certain toggling scheme. It was kind of easy. The next part was a variation of the classical Tower of Hanoi problem. No matter how hard I tried, my algorithm was not matching the given sample input/output. I asked the admins to look at the problem again for any possible mistake in the statement or sample input/output. But this time they were not as quick in response as they were for the last event. After around 10-15 questions fired by different teams, they answered only one. The overall contest also had attained height of mismanagement with problem statements being updated several times after the contest timer was started. Having tried for 2-3 hours on Problem 4, to my utter surprise, I found out that many other teams were cribbing about the correctness of its problem statement. I checked the rankings and was shocked to see that none of the teams ( not even those who were sitting at Top 10 ) could solve that problem. So I gave up on this problem too.
Then, I started yet another problem having to do with dynamic programming, coins and denominations. It was a variation of the classic denomination problem. Not that it was too hard to do it, I was kind of getting low because of failures and hunger. We went out to have a dinner at a small restaurant just opposite to IIT where we discussed yet another problem involving prime number and modular arithmetic. I thought to give it a shot after coming back, but that damn "Time Limit Exceeded" was not getting out of my sight.
Finally, we decided to give up as we were still sitting at zero where other Top 50 teams begged more than 800 points. I had never been so dejected in a long time. I was literally ashamed of myself.
Today morning I read a couple of articles on Modular Arithmetic and
Fermat's little theorem and realized why my implementation was not fast enough to defeat that "Time Limit Exceeded" demon. For Problem 1 ( The one with the vertices ) I learned that the middle vertice(s) of the longest path in the tree always have minimum sum of distance to all other vertices. How to find the longest path in a tree? Well, start from any vertex A and find out the furthest vertex B from it. Now start with B and find out the furthest vertex C from B. Path B to C is the longest path and its middle vertice(s) are the ones that we needed to find out. Running time?? O(n)
The bottom line is that I have got rusty. My programming skills and algorithm designing skills have fallen down. It seems I have not been doing much brain stimulating work for a long time. May be this failure is an indication for me to start honing my skills and in addition to giving exercise to my body I should give enough exercise to my brain as well.
The arrogance had fogged the part of the brain which does rational thinking, and I ended up starting my day without any kind of warm up practice for the contest. I had not even revised any relevant material.
Bitwise 2k7 started a little late than the announced time of 1300hrs. And as usual, I thought to attempt the "easier" problems ( 100 points ) first. It was based on graph theory where one was required to find out the vertice(s) having the minimum distance to all other vertices in a given tree. Initially, I started with an O(n^3) implementation and when I found the response of the system to be "Time Limit Exceeded" ( which was kind of obvious with such a naive approach to the problem ), I improved it to O(n^2). Even though, I tried harder I could neither change the complexity nor the response of the system. After 2-3 failed attempts I decided to concentrate on some other problem and come back to this one at a later time.
Problem 4, had two parts, the initial part was to decide whether a certain door k out of n will be open or closed having gone through a certain toggling scheme. It was kind of easy. The next part was a variation of the classical Tower of Hanoi problem. No matter how hard I tried, my algorithm was not matching the given sample input/output. I asked the admins to look at the problem again for any possible mistake in the statement or sample input/output. But this time they were not as quick in response as they were for the last event. After around 10-15 questions fired by different teams, they answered only one. The overall contest also had attained height of mismanagement with problem statements being updated several times after the contest timer was started. Having tried for 2-3 hours on Problem 4, to my utter surprise, I found out that many other teams were cribbing about the correctness of its problem statement. I checked the rankings and was shocked to see that none of the teams ( not even those who were sitting at Top 10 ) could solve that problem. So I gave up on this problem too.
Then, I started yet another problem having to do with dynamic programming, coins and denominations. It was a variation of the classic denomination problem. Not that it was too hard to do it, I was kind of getting low because of failures and hunger. We went out to have a dinner at a small restaurant just opposite to IIT where we discussed yet another problem involving prime number and modular arithmetic. I thought to give it a shot after coming back, but that damn "Time Limit Exceeded" was not getting out of my sight.
Finally, we decided to give up as we were still sitting at zero where other Top 50 teams begged more than 800 points. I had never been so dejected in a long time. I was literally ashamed of myself.
Today morning I read a couple of articles on Modular Arithmetic and
Fermat's little theorem and realized why my implementation was not fast enough to defeat that "Time Limit Exceeded" demon. For Problem 1 ( The one with the vertices ) I learned that the middle vertice(s) of the longest path in the tree always have minimum sum of distance to all other vertices. How to find the longest path in a tree? Well, start from any vertex A and find out the furthest vertex B from it. Now start with B and find out the furthest vertex C from B. Path B to C is the longest path and its middle vertice(s) are the ones that we needed to find out. Running time?? O(n)
The bottom line is that I have got rusty. My programming skills and algorithm designing skills have fallen down. It seems I have not been doing much brain stimulating work for a long time. May be this failure is an indication for me to start honing my skills and in addition to giving exercise to my body I should give enough exercise to my brain as well.
Posted by
Saurabh Joshi
at
3:24 PM
Labels:
flashback,
programming
Thursday, February 01, 2007
Parzania : A distorted reflection of Gujarat Riots
So I am back to the blogs after a long break. Life is going on as routine and events happening not worth mentioning. But something happened that forced me to write today, something that evoked memories of gujarat riots. Yes, I am referring to movie "Parzania".
Last sunday evening me and pranjal went to see a movie at PVR Saket. Though the movie has been praised by critics, I did not like it much. It seems to be a fashion to make movies on "sensitive" issues and show that you ( producer / director and the whole league ) are "concerned" about those who suffered those horrific series of events.
The thing I did not like most about the movie is that they depicted the police force as an evil spectator and accomplice. I am not saying that police was acting like an angel during the events and may be some incidents might have happened which caused the notoriety the police has gained. Bollywood keeps on depicting our police force as a demon and then we all yell that police does not perform its duties very well. If someone who has done good deeds is always been criticized for his/her wrongdoing, will there be any motivation to keep on doing good? Isn't it the case that lack of appreciation cultivates a tendency not to take pain in doing something right ( because no body would care/mention/appreciate )?
I had been there in gujarat. I am born and brought up in gujarat itself. And I must say that the biggest villain was media. Stating baseless rumors as facts, presenting events in a sensitized form, showing provoking clips/statements this is all media has done. Should not they act responsibly? But who is to blame, after all, we like things presented in this manner. We always try to hide our irresponsible behavior by criticizing someone.
So called "Top class" reporter barkha dutt was standing on a lonely highway and screaming there is no security force there? What should I say about that asinine woman? Gujarat has thousands of kilometers of highway, what did she want? A policeman at every 50 meter on the highway and leave the burning cities unattended?
Army batallions were air lifted from Jodhpur to get them as fast to gujarat as possible. Those army men did not took a rest. But did we appreciate? My friends were stuck in vidyanagar because of curfew. No mess, no shops and no food. It was the police who came to the rescue, searching for such caged souls and escorting them to Anand railway station. They did not ask whether the students that they are helping is hindu or muslim, the just performed their duties. Alas! it all goes unnoticed. When the mob came to our place and burned shops at the ground floor, police did came. What do you think a group of four people, three carrying a lathi each and one carrying a vintage pistol could have done against a mob of 3000 people? I have seen police officers begging the mob to keep cool. And the way they depict in the movie is that police watched the entire scene taking satanic pleasure in whatever was happening.
Is it police' fault that we do not have enough policemen? Is it police' fault that it is not well equipped and poorly paid? At the time of riots, they were staying in tents in a sensitive areas so that people could feel safe, but no body cared asking them even for a glass of drinking water.
Well, may be I had a lot to write but my anger towards the movie was subdued because of the delay in this writing. And even from a movie point of view, having english as a language while you are filming on a lower class background???
Besides, I still don't understand what was the point of making this movie after years of those horrific past. Did they want to revive the wounds of victims? It is such kind of distorted and exaggerated representation which had damaged gujarat's reputation irrevocably. Gujarat was pushed to a sixth place in industrial investment, because they say gujarat is an "unsafe" place.
For me, gujarat is much much safer than any other place in india where girls can stroll at almost midnight without worries. May the peace prevail!!!
Last sunday evening me and pranjal went to see a movie at PVR Saket. Though the movie has been praised by critics, I did not like it much. It seems to be a fashion to make movies on "sensitive" issues and show that you ( producer / director and the whole league ) are "concerned" about those who suffered those horrific series of events.
The thing I did not like most about the movie is that they depicted the police force as an evil spectator and accomplice. I am not saying that police was acting like an angel during the events and may be some incidents might have happened which caused the notoriety the police has gained. Bollywood keeps on depicting our police force as a demon and then we all yell that police does not perform its duties very well. If someone who has done good deeds is always been criticized for his/her wrongdoing, will there be any motivation to keep on doing good? Isn't it the case that lack of appreciation cultivates a tendency not to take pain in doing something right ( because no body would care/mention/appreciate )?
I had been there in gujarat. I am born and brought up in gujarat itself. And I must say that the biggest villain was media. Stating baseless rumors as facts, presenting events in a sensitized form, showing provoking clips/statements this is all media has done. Should not they act responsibly? But who is to blame, after all, we like things presented in this manner. We always try to hide our irresponsible behavior by criticizing someone.
So called "Top class" reporter barkha dutt was standing on a lonely highway and screaming there is no security force there? What should I say about that asinine woman? Gujarat has thousands of kilometers of highway, what did she want? A policeman at every 50 meter on the highway and leave the burning cities unattended?
Army batallions were air lifted from Jodhpur to get them as fast to gujarat as possible. Those army men did not took a rest. But did we appreciate? My friends were stuck in vidyanagar because of curfew. No mess, no shops and no food. It was the police who came to the rescue, searching for such caged souls and escorting them to Anand railway station. They did not ask whether the students that they are helping is hindu or muslim, the just performed their duties. Alas! it all goes unnoticed. When the mob came to our place and burned shops at the ground floor, police did came. What do you think a group of four people, three carrying a lathi each and one carrying a vintage pistol could have done against a mob of 3000 people? I have seen police officers begging the mob to keep cool. And the way they depict in the movie is that police watched the entire scene taking satanic pleasure in whatever was happening.
Is it police' fault that we do not have enough policemen? Is it police' fault that it is not well equipped and poorly paid? At the time of riots, they were staying in tents in a sensitive areas so that people could feel safe, but no body cared asking them even for a glass of drinking water.
Well, may be I had a lot to write but my anger towards the movie was subdued because of the delay in this writing. And even from a movie point of view, having english as a language while you are filming on a lower class background???
Besides, I still don't understand what was the point of making this movie after years of those horrific past. Did they want to revive the wounds of victims? It is such kind of distorted and exaggerated representation which had damaged gujarat's reputation irrevocably. Gujarat was pushed to a sixth place in industrial investment, because they say gujarat is an "unsafe" place.
For me, gujarat is much much safer than any other place in india where girls can stroll at almost midnight without worries. May the peace prevail!!!
Posted by
Saurabh Joshi
at
11:23 AM
Friday, January 12, 2007
Esterel : Syntax and Indent files for Vim
The other day I was programming in Esterel with my favourite editor Vim. And it turned out that I did not have syntax and indent files which would make my life easier while using Esterel.
I could find syntax file for esterel from somewhere, and I modified, indent file for shell scripts to suit for esterel.
You must add following 3 lines to your .vimrc file :
au BufRead,BufNewFile *.strl set filetype=esterel
au! Syntax ESTEREL source /usr/share/vim/vim63/syntax/esterel.vim
:filetype indent on
Change the source where you had put the syntax file for esterel.
Ideally it should go to $VIMRUNTIME/syntax and $VIMRUNTIME/indent respectively.
Anyways, here are the links for the syntax and indent file for esterel.
I could find syntax file for esterel from somewhere, and I modified, indent file for shell scripts to suit for esterel.
You must add following 3 lines to your .vimrc file :
au BufRead,BufNewFile *.strl set filetype=esterel
au! Syntax ESTEREL source /usr/share/vim/vim63/syntax/esterel.vim
:filetype indent on
Change the source where you had put the syntax file for esterel.
Ideally it should go to $VIMRUNTIME/syntax and $VIMRUNTIME/indent respectively.
Anyways, here are the links for the syntax and indent file for esterel.
Wednesday, November 29, 2006
May I know the time please?
I got bored by reading papers so was going through iitb.h to get some refreshment :-) and here is what i found
-------------
Young Man: Sir, may I know the time, please?
Old Man: Certainly not.
Young Man: Sir, but why? What are you going to lose,if
you tell me the time?
Old Man: Yes, I may lose something if I tell you the
time.
Young Man: But Sir, can you tell me how?
Old Man : See, if I tell you the time you will
definitely thank me and may be tomorrow again you will
ask me the time.
Young Man: Quite possible.
Old Man: May be we meet two three times more and you will
ask my name and address.
Young Man: Quite possible.
Old Man: One day you may come to my house saying you were
just passing by and came into wish me.
Then as a courtsey, I will offer you a cup of tea.
After my courteous approach you will try to come
again.This time you will appreciate tea and ask who has
made it.?
Young Man: Possible
Old Man: Then I will tell you that my daughter has
and I will then have to introduce my young and pretty
daughter to you & you will admire my daughter.
Young Man: Smiles. ;)
Old Man: Now onwards you will try to meet my daughter
again and again. You will offer her to go out for a movie together and a
date with you.
Young Man: Smiles
Old Man: My daughter may start liking you and start
waiting for you. After meeting regularly you will fall in
love with her and propose her for marriage.
Young Man: Smiles
Old Man: One day both of you will come to me and tell me
about your love and ask for my permission.
Young Man: Oh Yes! And smiles
Old Man: (Angrily) Young man, I will never marry my
daughter to a person like you who does not even own a
watch.
-------------
Young Man: Sir, may I know the time, please?
Old Man: Certainly not.
Young Man: Sir, but why? What are you going to lose,if
you tell me the time?
Old Man: Yes, I may lose something if I tell you the
time.
Young Man: But Sir, can you tell me how?
Old Man : See, if I tell you the time you will
definitely thank me and may be tomorrow again you will
ask me the time.
Young Man: Quite possible.
Old Man: May be we meet two three times more and you will
ask my name and address.
Young Man: Quite possible.
Old Man: One day you may come to my house saying you were
just passing by and came into wish me.
Then as a courtsey, I will offer you a cup of tea.
After my courteous approach you will try to come
again.This time you will appreciate tea and ask who has
made it.?
Young Man: Possible
Old Man: Then I will tell you that my daughter has
and I will then have to introduce my young and pretty
daughter to you & you will admire my daughter.
Young Man: Smiles. ;)
Old Man: Now onwards you will try to meet my daughter
again and again. You will offer her to go out for a movie together and a
date with you.
Young Man: Smiles
Old Man: My daughter may start liking you and start
waiting for you. After meeting regularly you will fall in
love with her and propose her for marriage.
Young Man: Smiles
Old Man: One day both of you will come to me and tell me
about your love and ask for my permission.
Young Man: Oh Yes! And smiles
Old Man: (Angrily) Young man, I will never marry my
daughter to a person like you who does not even own a
watch.
Monday, November 27, 2006
Unique Role of Java in Programming Language Innovation
I was lucky to attend IBM IRL workshop on Next Generation Programming languages and Environments on 20-21st of Nov at India Internatinal Centre. Writing below some details of the first talk. Though, there were many talks in the workshop. I am able to recall only a few so wont be able to write about all the talks in my posts.
Unique Role of Java in Programming Language Innovation
------------------------------------------------------
Dr Bob Blainey of IBM Software group being a distinguished engineer and chief java technologist was no doubt the right person to talk about role of java in driving next generation programming languages and environments. He said that at least three mejor extension of java coming up to aid different programming need.
X10
--
X10 is a java extension which is designed to address the need for
concurent programming. One can not ignore the major shift towards
exploiting parallelism as much as possible. Next generation
programming languages can not ignore this shift and they have to
provide programmers construct which make use of underlying
parallelism.
There are a few constructs added in java, some of which I am listing
below.
Place :- This is a logical construct which can be mapped to physical
place in a sense that a place could be mapped to different processor
or a different machine altogether. The X10 framework assumes
distributed memory model and gives control to program in a GALS (
Globally Asynchronous Locally Synchronous ) environment.
Activity :- Activity resembles classical java threads. An activity can
access or modify only those objects which resides in the local place (
place in which the activity is residing ). So if an activity wants to
access a remote object, it has to first create an activity at the
remote place and then have to communicate with that newly created
activity to get the desired result. BadPlaceException is thrown in
case an activity tries to access a remote object.
Clock :- Those who are familiar with typical multi threading/multi
programming environments would say that this object acts as a barrier.
Different activities can register themselves with clocks and use it
for the purpose of synchronization. A place can have multiple clocks
and different activities can register for more than one clocks as
well. There is no global clock in the framework which makes it
globally asynchronous.
A container (e.g. array ) can be distributed across places. For
example programmer can decide to distribute array in such a way so
that an array of size 10 ( 0..9) its elements A[0] A[5] A[6] belong to place1
and
A[2] A[8] A[9] belong to place2. This distribution makes it difficult
to construct a simple for loop which will go through all the array
elements and update it because there is a possibility of a
BadPlaceException. To take care of this situation a projection
operator is introduced. For example,
for( point [i] : A | here )
where "here" refers to the place associated with the given scope just
like "this" refers to the object. This way one can iterate through all
the points ( elements ) of array A only residing within current place.
async( place ) { //some code } - This construct allows programmer to
execute a certain task at a remote place. It is not like a remote
procedure call in a sense that the calling module will not be blocked.
In fact, the code will run as an independent thread which may or may
not communicate back to the calling module after the invocation. In
other words, an asynchronous thread of execution is created at a
remote place to execute certain piece of code.
Many more constructs were described but unfortunately I am not able
to remember other details :-(.
XJ
--
XJ is an augmentation of Java is designed to address need for XML &
Web services. It extends Java syntax as well as semantics. One example
may look like :
Article A = new ( <>
<> getTitle() < /article_title >
getArticleBody() < /article > );
I am not able to recall the exact syntax but it looked much like the
code I mentioned above.
Metronome
--------
Java with a real-time flavour. Major feature is handling garbage
collection with real-time constraints. I really wonder what kind of
algorithms would it take to perform garbage collection with such
constraints. What happens when the GC is halfway through marking the
live nodes and it has to relinquish control to another thread to
satisfy the constraints? Or what is GC is halfway through the
compaction ? I would really like to know the underlying details which
handles these intricacies.
I would like to end this post by a quote which Dr Bob Blainey
mentioned during his talk.
"Claiming that Java is easier than C++ is like saying that K2 is
shorter than everest" -- Larry O' Brian
Unique Role of Java in Programming Language Innovation
------------------------------------------------------
Dr Bob Blainey of IBM Software group being a distinguished engineer and chief java technologist was no doubt the right person to talk about role of java in driving next generation programming languages and environments. He said that at least three mejor extension of java coming up to aid different programming need.
X10
--
X10 is a java extension which is designed to address the need for
concurent programming. One can not ignore the major shift towards
exploiting parallelism as much as possible. Next generation
programming languages can not ignore this shift and they have to
provide programmers construct which make use of underlying
parallelism.
There are a few constructs added in java, some of which I am listing
below.
Place :- This is a logical construct which can be mapped to physical
place in a sense that a place could be mapped to different processor
or a different machine altogether. The X10 framework assumes
distributed memory model and gives control to program in a GALS (
Globally Asynchronous Locally Synchronous ) environment.
Activity :- Activity resembles classical java threads. An activity can
access or modify only those objects which resides in the local place (
place in which the activity is residing ). So if an activity wants to
access a remote object, it has to first create an activity at the
remote place and then have to communicate with that newly created
activity to get the desired result. BadPlaceException is thrown in
case an activity tries to access a remote object.
Clock :- Those who are familiar with typical multi threading/multi
programming environments would say that this object acts as a barrier.
Different activities can register themselves with clocks and use it
for the purpose of synchronization. A place can have multiple clocks
and different activities can register for more than one clocks as
well. There is no global clock in the framework which makes it
globally asynchronous.
A container (e.g. array ) can be distributed across places. For
example programmer can decide to distribute array in such a way so
that an array of size 10 ( 0..9) its elements A[0] A[5] A[6] belong to place1
and
A[2] A[8] A[9] belong to place2. This distribution makes it difficult
to construct a simple for loop which will go through all the array
elements and update it because there is a possibility of a
BadPlaceException. To take care of this situation a projection
operator is introduced. For example,
for( point [i] : A | here )
where "here" refers to the place associated with the given scope just
like "this" refers to the object. This way one can iterate through all
the points ( elements ) of array A only residing within current place.
async( place ) { //some code } - This construct allows programmer to
execute a certain task at a remote place. It is not like a remote
procedure call in a sense that the calling module will not be blocked.
In fact, the code will run as an independent thread which may or may
not communicate back to the calling module after the invocation. In
other words, an asynchronous thread of execution is created at a
remote place to execute certain piece of code.
Many more constructs were described but unfortunately I am not able
to remember other details :-(.
XJ
--
XJ is an augmentation of Java is designed to address need for XML &
Web services. It extends Java syntax as well as semantics. One example
may look like :
Article A = new ( <>
<> getTitle() < /article_title >
getArticleBody()
I am not able to recall the exact syntax but it looked much like the
code I mentioned above.
Metronome
--------
Java with a real-time flavour. Major feature is handling garbage
collection with real-time constraints. I really wonder what kind of
algorithms would it take to perform garbage collection with such
constraints. What happens when the GC is halfway through marking the
live nodes and it has to relinquish control to another thread to
satisfy the constraints? Or what is GC is halfway through the
compaction ? I would really like to know the underlying details which
handles these intricacies.
I would like to end this post by a quote which Dr Bob Blainey
mentioned during his talk.
"Claiming that Java is easier than C++ is like saying that K2 is
shorter than everest" -- Larry O' Brian
Subscribe to:
Posts (Atom)