Monday, July 16, 2012

Grouping Permutation Strings

This is a straightforward problem.

Given N strings of equal length (K) on an alphabet, you have to partition them into sets, such that every set contains strings that are permutations of each other. Of course, a string can be added to only one set and if 2 strings get added to 2 different sets, they should not be permutations of each other.

This can be easily done in O(N*K) time by using a hashmap. Each string will be inspected once, and each character of the string will be inspected only once.

We will use a hashmap, that maps the permutation key to a set of strings. We iterate over the N strings to find the permutation key of each string. In each iteration, you need an array to keep counts of characters that appear in the string. This array size will be the same as the size of the alphabet. So it will be able to keep counts of all the characters in the alphabet, that may or may not appear in a string. Then iterate over the characters in the string. Whenever you see a character, increment the corresponding count in the array. After the string is inspected, the array of counts can be used as a key in the map. If 2 strings have the same counts for all the characters, then they are permutations of each other.

Here is the Java code.

// assume all lowercase strings
int A = 26 ; // size of alphabet is 26
int N = ... ; // number of strings
String [] allStrings = new String[N] ;

// code to populate the array with equal size strings
// ...
int K = allStrings[0].length ;
// all strings are of the same length

// we are using a map with a String as key
// and a list of String as a value
// By using a List (instead of Set)
// we preserve the original order of strings
// This may or may not be important depending on the problem
Map permutations_map = new HashMap() ;

// Now iterate over the array and find permutation key for each string
for (String s : allStrings) {
    // counting array length is same as alphabet length
    int [] char_counts = new int[A] ;
    for (int i = 0 ; i < K ; i++) {
 char c = s.charAt(i) ;
 int index = ((int) c) - ((int) 'a') ; // char math !
 char_counts[index] ++ ; // increment the count
    } // 

    // now the string representation of this array can be used as a key
    String bucket_id = Arrays.toString(char_counts) ;

    // add the string to the list in map
    // create a new list if needed
    if (! permutations_map.contains(bucket_id) ) {
     permutations_map.put (bucket_id, new ArrayList()) ;
    } // 

    List str_list = permutations_map.get (bucket_id) ;
    str_list.add (s) ;

} // 

The caveat : This is dependent on character math. It's no big deal, but if it is a problem for the alphabet, just use another map, tp map the characters into unique numbers that can be used for the array index. Simple.

NOTE : For small strings on very large alphabets, an alternative scheme will be better. But the idea given here is reasonable to find permutations within numbers, or ascii strings.

I used this to solve another problem. First I had to generate a list of primes, for which I used the "Sieve of Eratosthenes". Then, I treated each prime as a string of digits, and use the above algorithm to bucket them. That was only part of the solution. I will cover the remaining parts in later posts.

Here is the Java code for grouping the primes. Note that all the numbers are assumed to have the same number of digits. In particular, they were all 4 digit primes.

public static final long MaxNumber = 9999 ;
public static final int NumberOfDigits =
    (int) (Math.ceil(Math.log10(MaxNumber))) ;
public static final long Floor =
    (long) (Math.pow(10,NumberOfDigits-1)) ; // 1000
public static final long Ceiling =
    (long) (Math.pow(10,NumberOfDigits)) ; // 10000

public static String getBucketId (long num) {
    int digits_count [] = new int[10] ;
    int pow10 = Floor ; // start dividing by 1000
    while (pow10 != 1) {
 long digit = num / pow10 ; // left most digit
 digits_count[digit] ++ ; // increment the count
 num -= digit*pow10 ; // remove the left most digit
     pow10 /= 10 ; // for next iteration
    } // 
    digits_count[num] ++ ; // last digit remains
    return Arrays.toString(digits_count) ;
} // 

public static void insertIntoBucket
                  (String bucket_id, long num) {
    if ( ! BucketedPrimes.containsKey (bucket_id) ) {
     BucketedPrimes.put (hash_value, new ArrayList()) ;
    } // 
    List permutation_list =
                      BucketedPrimes.get (bucket_id) ;
    permutation_list.add (num) ;
} // 

public static void createBuckets
                    (int num_digits, List all_primes) {
    for (Long p : all_primes) {
 long prime = p.longValue() ;
 String hash_val = getBucketId (prime) ;
 insertIntoBucket (hash_val, prime) ;
    } // 
}
This creates the BucketedPrimaes map given a list of numbers, in this case the numbers happen to be primes. Every value in the map is a list of 1 or more numbers, that are digit permutations of each other.

Tuesday, July 10, 2012

What a week that was

The last week was very interesting for Sports and Science. Somewhat historic as well. Here is a quick recap of all the things that happened in this short time.

1. Spain's historic win at Euro 2012.
It's hard enough to win a Soccer tournament at such massively competitive world stage. Doing 2 in a row is way harder. Doing 3 in row, definitely deserves being labeled as historic. I wrote about it in my previous post.

2. Federer's win at Wimbeldon.
I don't think I have to say a lot about this, as this is obvious. Astonishing 17th grand slam title, regaining number 1 at the age of 30, what more a man can do ?

3. Anderson Silva's Win at UFC 148
Although UFC is gaining popularity, it still hasn't gone mainstream. More and more will be shown on Fox, so it just has begun its upward swing. Many think of it as too violent. I find it less violent than boxing, as often times the fights are decided by grappling skills. In any case, I enjoy watching UFC, and find Anderson Silva's 10th title defense legendary. In a field that requires insane physical fitness and a lion's heart, no one has been at the top for so long. And Silva does it convincingly. Jon Jones might surpass Silva's records, but till today, Silva has been the best pound for pound fighter in the world.

Now on to Science - where the discoveries are truly historic in nature.

4. Higgs Boson
The confirmation of this so called "God Particle" was one of the main objectives of Large Hadron Collider (LHC) at CERN. To be honest, I don't understand the theory at all. To my layman brain, Higgs Boson has always felt like the "aether" that was supposed to permeate the space. But of course, I believe the modern scientists when they tell us, that Higgs Boson is based on sound mathematics, unlike the discredited "aether". This week the CERN announced that they have indeed found evidence of Higgs Boson in LHC. This is the most important discovery in particle physics, and it confirms The Standard Model. I wish there were more accessible books that explain the Higgs Boson, and particle physics in general.

5. Dark Matter Detected
With all the celebration about the Higgs Boson in the media, one other equally important discovery did not get as much mention. For the first time the dark matter was "observed directly". Dark Matter by definition does not interact with other matter. That's why it has been hard to detect it in spite of it being 5 times as plentiful. The only way to detect it as via its gravitational effects on neighboring matter. On the same day CERN announced about Higgs Boson, Nature announced about the first detection of dark matter "filament" joining 2 clusters of galaxies. Dark Matter is even more mysterious than Higss Boson, but it's at the cosmological scale, not quantum scale. I do not know if this discovery proves the hypothesis of Dark Matter. It does seem extraordinary, confirming that although we know precious little about the universe, we are perhaps on the right track.

Sunday, July 1, 2012

The Greatest Soccer Team Ever

It's very rare to watch history in the making, and much rarer to realize that in real time. I think the time has come to declare just that.

About 6 years ago, the Spanish National Football team made a crucial decision. Having realized their inability to out-muscle their opponents, they decided to adopt a playing style that has now come to be known as "Tiki-Taka". This style was not their invention - some credit goes to the Barcelona team during the early 90s under the super-successful manager and a legendary player himself - Johan Cruyff. It has been evolving since then. The Barcelona team under Josep Guardiola (a pupil of Johan Cryuff) and the Spaniards just took it to the level of absolute perfection. There is a significant overlap between the rosters of Barcelona and the Spain National Football team, and the playing styles are nearly identical.

The Dutch made "Total Football" famous and highly effective in the seventies. In this style, the players can switch positions and reliance on specialists is reduced. Barcelona's "Tiki-Taka" takes this basic idea even further and adds more elements to it. In this system, the players can be physically small, as long as they are technically talented and exceptionally fit. They make quick passes to each other, with just one or two touches before passing. It requires exceptional team coordination, vision and space awareness. A typical pattern in this system is triangulation, where 3 players keep advancing field position while passing ball to one another. Others join in as needed to make new triangles.

But the style is just a technicality if it isn't successful. Barcelona has won 15 titles under Guardiola, and Spain just became the first country to ever win 3 consecutive titles - Euro 2008, World Cup 2010 and now Euro 2012. And of course, success of the style depends on the caliber of the players as well.

The relationship is mutual. This style has created a generation of great Spanish players and the continued success of the style depends on their greatness. Xavi, Iniesta, Villa, Fabregas, Silva, Torres, Pedro - the list is endless. In Euro 2012, they were without Puyol and David Villa - and they still won. This combination of individual talent and a great style, has been a perfect match. Hence, I have no hesitation in claiming that we are indeed watching THE greatest national soccer team ever.

Such claims are often met with skepticism. What about Brazil with Pele, or the Dutch team of 70s ? Comparing players across generations is hard, comparing teams is even harder. What is great about Spanish team today, is that it is not dependent on some key players - rather it depends on having many players that play the system exceptionally well. Surely, Xavi has been the architects on many attacks - but the success doesn't just depend on him. Messi makes Barcelona the ultimate club team ever, but he is not part of the Spanish team. That's the point. Spain doesn't need a Pele or a Maradona or a Platini or a Zidane. There is no one player without whom the whole edifice will collapse.

A key idea of the system is to keep possession at all times. In many games, Spain has possession for 70% of the time, and routinely complete 500+ passes every game (with 80%) accuracy. If your opponents do not get the ball, how will they score ?

This style of play also generates criticism. Spain's goal margin in wins is often 1-0. People find the game slow, some go as far as calling it boring. I can see why they might feel it that way. But I find their play mesmerizing. It's like watching an intricately choreographed ballet. Elegance and precision are two words often used to describe their play.

What's remarkable is this style is not a secret. Other teams have been studying them, trying to copy some of their ideas, but more importantly figuring out ways to defeat them. Neither Spain, nor Barcelona is invincible. Chelsea has had success against Barcelona. But overall, both Spain and Barcelona have maintained their position at the peak for a long time. This playing style, and the physique of current players makes the long crosses and headers a bit rare. Very few players are over 6 feet. I don't mind that.

You cannot defeat them because you cannot take away the ball from them, and if you get the ball, you cannot score a goal against them. That's true. Often during the Tiki Taka talk, what gets little mention is Spain's defense. In the entire Euro 2012, Spain played more games than everyone else except Italy, but there was just one goal scored against them. Just ONE. This was when their main defender Puyol could not play the tournament due to an injury. Think about it. Victor Valdez is considered to be the best goalkeeper Barcelona has ever had. And he is a reserve for Spanish team, because current goalkeeper and captain Iker Casillas is on track to be called one of the greatest goalkeepers ever. Spain's coach has the reverse problem - who to keep on the bench ! The talent pool is very deep.

No matter what you think of this being the greatest team ever, it's beyond doubt that Spain and Barcelona have redefined Soccer. And this happened in last 5 years. Many great teams have come and gone, many more will surely come in future. But very rarely a team is credited for starting a new School of Soccer playing. I consider myself to be absolutely lucky to have watched Spain - and in particular Barcelona play. It has been a pure joy. Thank you Spain, thank you Barcelona !

Here is a very nice video explaining this style of play - not goal scoring, just passing.

Sunday, June 17, 2012

GaDiMa-3

How good is your Marathi ? Take this test :-) What does "कार्मुक" and "सायक" mean ?

A context would certainly help.

जोड झणि कार्मुका, सोड रे सायका,
मार ही त्राटिका, रामचंद्रा !

In गीत-रामायण, महाकवी ग.दि.मा. has written songs on situations that are hardly obvious candidates for writing poetry. But write did he. And fabulous poetry on every such occasion. Here, seeing the demon Tratika, sage Vishwamitra orders Shri Raam to kill her. The entire song is just one big command and its justification.

As you can guess now, "कार्मुक" means bow, and "सायक" means arrow. Actually I am guessing too. My Marathi-English dictionary doesn't have the word "कार्मुक".

Here is another test for you. Now that kind of धृपद (refrain) forces a difficult choice for यमक (rhyme). How many words can you come up with that rhyme with "रामचंद्रा" ? Quickly :-). Anyway, this is the list of words that GaDiMa used in this song : अभद्रा, मुद्रा, तंद्रा, मानवेंद्रा, मृगेंद्रा.

More often than not, Marathi is not soft and sweet on ears. This song has particularly harsh sounding words - like the यमक. In spite of that, the लय (rhythm) is impressive. Take the following as an example.

अतुलबलगर्विता, मूर्त ही क्रूरता,
ये घृणा पाहतां, कृर मुद्रा

How many other Marathi poems/songs that you know that have words "कृर", "घृणा" and still has a beautiful lay ? Such construction is not uncommon in Sanskrit, and there is a clear Sanskrit influence here.

This may not be as famous song as others from Geet Raamayana. I like it a lot, it's a very good प्रासंगिक कविता (situational poem).

I found the following YouTube video in case you are interested. I am not impressed by the singing. When I was a kid, I have heard Sudhir Phadake singing it in a live performance. He would bring out the वीररस and रुद्रारस as GaDiMa intended. That is missing from this rendition. If you haven't heard this song in a while, it will give you the idea of the tune, that's all.


Previously :

Monday, May 21, 2012

Viral Storm



Book Review : The Viral Storm
Author : Nathan Wolfe
My Rating : 3 out of 5

The complete title of the book is "The Viral Storm: The Dawn of a New Pandemic Age".

I came to know about this book from "The Colbert Report" when the author Nathan Wolfe was interviewed. He boasts an impressive resume. He was previously a tenured professor at UCLA, now he is a professor at Stanford, has published numerous papers with many years of field research in remote parts of the world. He is more than qualified to write a book on this topic.

The world of microbes is fascinating but largely ignored by anyone who is not in medical field. There aren't as many PBS Nature shows on them as there are on other species. We talk about them only when there is an outbreak. But for Nathan Wolfe, this microscopic world has been a lifelong obsession. He started out as a researcher, and now heads the unique efforts of a not-for-profit organization called Global Viral Forecasting Initiative.

The idea behind such an organization is very interesting and is explained at the very end of the book - how to predict (and prevent) future outbreaks. Their tool-set is diverse and innovative. It even includes analyzing Google search patterns and trending topics on Twitter. But what is a pandemic ? How does it start ? How does it spread ?

Nathan Wolfe argues that understanding these questions is important because it's almost certain that there will be new pandemics and new lethal viruses. To explain that, he starts from the very beginning, at the dawn of human evolution, when our primate ancestors ventured out of the forest into the savannah. The microbes have been evolving with us, and continue to evolve like any other life form.

For any virus that wants to affect as many hosts as possible, there should be means to spread. We are not just a super connected world with fast means of mass transportation. As the author puts it, we are also an "intimately connected" world, where blood transfusion and organ implants give new avenues for the viruses to spread.

There are many such insights in the book. Now I know, this cannot be a relaxing discussion. So the author tries hard to be an optimist and not an alarmist. He obviously is passionate about the topic and is at the forefront of preventive efforts. That passion comes through.

But it's not as satisfying as I hoped it would be. Often times it feels like a book about "who's who" of the "virus hunters", and less about explaining scientific ideas to outsiders. The researchers deserve credit, but it would be nice to learn more about the topic they are researching. Hence, it feels like written by an executive and less by a scientist. I wish he had spent more of the pages on explaining more about the biology concepts related to the discussion. If advanced topics in math and physics can be explained to laymen, I am pretty sure it's possible for biology as well.

I can still recommend it, because it's a worthwhile reading about a field we rarely hear about.

Friday, May 4, 2012

Julie and Julia

Movie Review : Julie and Julia
Director : Nora Ephron
Genre : Drama
Starring : Meryl Streep, Amy Adams, Stanley Tucci, Chris Messina
Released : 2009
My Rating : 6 out of 10

Anyone who has any interest in cooking has heard of Julia Child. Her first book "Mastering The Art Of French Cooking" was released in 1961, and it created culinary revolution by making fine French cooking easily accessible to American households. Still widely available, and universally loved, it is a true classic. Subsequent TV show, "The French Chef" confirmed her as the American Cooking Icon. (To be honest, I have read those 20 pages of detailed description on how to make an omelet, and I still cannot make a good French Omelet. But that's hardly Julia's fault.)

In 2002, a Queens resident Julie Powell. decided to cook all the 524 recipes in this classic in a year, and blog her daily experiences. She needed a distraction from a stressful job and her husband suggested this idea because of her love for cooking. This blog became popular, and Julie Powell wrote a book about that one year in her life.

That book is the inspiration for "Julie and Julia". It examines the lives of both women. They never met in person, so the movie flips back and forth between the two stories from two different periods. Sometimes, these switches work, sometimes they seem forced.

There are some interesting situations and funny moments. I didn't know that Julia Child took to cooking because she didn't have much to do while her diplomat husband was stationed in Paris. She tried different classes - including bridge, but eventually joined a cooking class, because she loved French food. She wasn't readily accepted, but she persevered. Her struggles and subsequent successes give a good insight into her personality.

These occasional moments fail to cover the movie's flaws. Neither story is particularly exceptional and to stick to the theme - both are a bit bland. Not all life-stories are eventful, and in such cases, the script writers have to rise to the challenge of making them engaging. In this movie that didn't happen, hence it feels long and drawn out.

I am a fan of Meryl Streep, but her acting in this movie felt very unnatural. I know she was trying to sound like Julia Child, but it was so forced and monotonous, that it became a bit irritating. Amy Adams did her best, and she succeeds in being cute most of the time. The problem is, her character is selfish and not really that likeable.

Overall, I was not too impressed with this movie. And I love cooking. It's an above average movie, and if you don't have too high expectations, you might like it. It's correctly rated PG-13, but kids will be frankly bored.

Tuesday, May 1, 2012

Generating Prime Numbers Using Sieve of Eratosthenes

Generating a prime is occasionally needed in solving coding puzzles. It's a pretty straightforward task, whether you stick with a naive brute force solution or with "Sieve of Eratosthenes". I am going to use this one later to show a solution for a more involved problem.

The "Sieve of Eratosthenes" is a very old method of generating the primes, named after an ancient Greek Mathematician who invented it. It's intuitive to understand, and efficient.

You start with number 2, and mark all numbers up to N that are divisible by 2 as non-prime, by just hopping forward 2 places, till you reach N. Then you start with 3, and mark every third number as non-prime. Next number 4 is already marked as non-prime, so ignore it. Then start with 5, and mark every 5th number as non-prime. And so on.

A simple observation helps most algorithms related to checking/generating prime numbers.
For finding a factor of any number N, you only have to check using numbers that are less than the square root of N. Because if N = x * y, and x > sqrt(N), then it must be true that y < sqrt(N).
You can use this observations is 2 ways.
1. When you are considering the factors to cross out the composites, you need to consider factors only till sqrt(N).
2. When you start crossing out, you can start crossing out numbers from factor^2. Anything composite below that would be a smaller multiple of factor, and would have been crossed out.
Here is the Java code :

// consider all numbers as prime to begin with
// init array of N flags to false
boolean is_non_prime[] = new boolean [N+1] ;
// NOTE : first index is 0

is_non_prime [0] = is_non_prime [1] = true ;
// 0 and 1 are not considered primes

for (int factor = 2 ; factor*factor <= N ; factor ++) {
    // no need to find composites of a non-prime number
    if ( is_non_prime[factor] )
        continue ;

    for ( int composite = factor * factor ;
              composite <= N ; composite += factor ) {
        is_non_prime [composite] = true ;
    } //
} //

After this, the array is_non_prime[k] = false for any number K that is prime.

Of course, this needs memory of N bits for storing the flags, which is not an issue in most applications.

Finding the computational complexity is a bit tricky. There are 2 loops, but the complexity is not O(N^2). The outer loop is executed K times, where K=sqrt(N). The inner loop executed only for primes, which is significantly less than K for large values of K.

Note that for factor = 2, there are N/2 operations because N/2 numbers will be crossed out. Then for factor = 3, there will be N/3 operations. Then N/5 operations and so on. So
Total operations = N/2 + N/3 + N/5 + N/7 + N/11 + N/13 + ...
  = N * ( 1/2 + 1/3 + 1/5 + 1/7 + 1/11 + 1/13 + ... )
The term in the parenthesis is "prime harmonic series" . It has been shown to have the upper bound of ln ln (N). Where ln is the natural logarithm, and yes, it's a double logarithm : log of log of N.

This means the complexity of our algorithm is O (N * ln ln N ).

The double logarithm make the second term quite small than N. That makes the computation complexity of "Sieve of Eratosthenes" almost linear, which is quite a feat.

Monday, March 26, 2012

Hummingbird

This is NOT a good photo. But this is the only one I have managed to take till now.

Anyone who has the slightest interest in nature photography probably wants to take a photo of a hummingbird drinking nectar from a flower. There is something magical about that sight. How they manage to hover just on the spot with frantic flipping of their wings, and smoothly glide from one flower to another. And they are pretty.

In spite of seeing them so many times, I hadn't managed to take any photos of them doing that till now. Because they don't hang around for too long. (I did manage to take a photo of one sitting on a branch. And also of a nest with eggs.)

So when I saw a hummingbird near the peach tree in my backyard on a weekend - this is what happened.

1. Frantically ran upstairs.
2. Got the camera out of the bag.
3. Removed the prime lens.
4. Put in the big 300mm zoom.
5. Set the mode to "Tv"
6. Adjusted shutter speed to max to see their wings clearly, not just a blur. This is at 1/4000.
7. Tried to find the hummingbird again. (Why are they so tiny ?)
8, Zoomed to max.
9. Click, click, click like crazy. (Thank you digital camera, no worrying about film cost.)

This is the result. Out of all the photos that had a hummingbird in it, only one turned out to be OK.


What I didn't realize was - with the shutter speed so high, the aperture is going to be wide open (it was f/5.6), making it difficult to get the focus right. So it's not very clear. Plus the zoom magnifies any shaking. But hey, it's still a photo of a hummingbird drinking nectar from a flower ! So it's at least a partial success.

Wednesday, March 21, 2012

Gary Kasparov on Gary Kasparov

Book Review : Gary Kasparov on Gary Kasparov Part 1 1973-1985
Author : Gary Kasparov
My Rating : 5 out of 5 stars

Gary Kasparov, the 13th World Champion, is often considered the greatest player in the entire history of chess. I am in agreement. When chess was my passion, Kasparov was my hero. Later, my favorite player became Anand, whose natural talent is perhaps a notch better. But Kasparov would always command a special place in my chess brain, however small that brain might be. I used to anxiously wait for the morning newspaper to discover the result of his championship games and the list of moves. It wasn't easy to get access to latest games in those days, when there were no computers, and chess books were hard to come by in India. But whatever games I got to see, were jaw dropping. This young man was from a different planet.

So when he writes a series of books about his own life and games, do I even have a choice ? Of course I am going to buy it as a Christmas present for myself, and of course I am going to love every page of it. But for the sake of review, I will keep my adulation aside and try to be objective. No guarantees though.

In case you don't know, in last 10-12 years or so, Kasparov has been working on a massive project - "My Great Predecessors" - a series of books about the past world champions and their challengers. The aim was to cover their games, a bit of history, and also the impact on the evolution of the game itself. A far-reaching and audacious goal. These books have been a huge success. They are not perfect. Famous chess historian, Edward Winter, has noted a few historical inaccuracies. The translation, from Russian to English, has created some uncomfortable sentences. But overall, these books are simply phenomenal. There is nothing else comparable to the encyclopedic nature of the entire series. I have them all and I am totally in love with them.

Later, he wrote another series of 4 books, Modern Chess, out of which 3 are about the 5 world championship matches between Kasparov and Karpov. Yes, these matches deserve that kind of treatment. Their importance on all aspects of chess, from theory to politics, cannot be overstated.

Why am I mentioning all this ? Because his latest series, about his own games, follows the same style. Lots of games, great analysis, helpful explanations, ample diagrams and the same fantastic production quality. And punctuating the games, is gripping historical narrative. This time, since it's about his own life, the book is in no small part, also an autobiography.

A collection of games by one player is rarely meant to be instructional. True, you can learn a lot about chess by studying how the great masters played the game. Some such works, like Alekhine's or Fischer's, have been suggested for improving your own chess. But that's a side benefit. The main reason is to get great enjoyment, and know more about that player. A lot depends on the quality of the games and the annotations. Well, these are games by Kasparov. The quality is naturally high, amazingly high. Goes without saying. The annotations are superb too. For an expert, there are enough variations, and for an amateur like me, the explanations are very accessible. Kasparov often points out the non-technical aspects as well, such as time trouble, or the psychology behind many key decisions. This has been true for all his books, and that's one of the main reasons to read them.

There is a great deal of personal detail, and it's such a joy to read. Kasparov is illuminating his life to show how he became Kasparov, the living legend. How did he start, who helped him, the turning points in his life and the emotional impact of every win or loss. To those who are unfamiliar with his persona, the great thing about Kasparov is, he is very human. He is not a chess machine. His emotional reactions during the game are well known. His attitude is famous - he wants to strike fear in his opponents' heart, he wants to dominate, he wants a crushing victory. He is a fighter who makes chess a sport rather than a game.

Please don't let that give you an impression that this book is used as a platform for bragging. The opposite is true. The tone is absolutely honest and humble. All successful people need a lucky hand once in a while. Kasparov writes freely about how luck played a part here and there. At a very young age, his talents were noticed by the great teacher, an ex-champion and a legend himself - Botvinnik. This patronage was crucial to Kasparov's success. In those days, Soviet Union had more talented chess players than there are fish in the Caspian Sea. Who was going to invite a young schoolboy to master tournaments ? Botvinnik put his respect on line, when he lobbied for Kasparov's inclusion on many occasions. Of course, Kasparov proved him right by winning in a spectacular fashion. But without Botvinnik's training and help, Kasparov would have undoubtedly taken longer to reach the pinnacle. And he admits it gratefully.

And not just about Botvinnik, Kasparov also talks about the guidance and support he received from many other players. And he talks about his losses. Yes, there are games here that he lost ! He explains how the losses he suffered at the hands of ex-champions, Spassky and Petrosian, helped him grow as a player. This is a rarity, and transcends the book into more than just "My Best Games" type of books.

We also get to glimpse how life was behind the iron curtain. Kasparov is Jewish, and had to change his last name to have a shot at success. Chess was more than a game to Soviet Union. There was always politics and intrigue. Ever since Kasparov was a teenager, he was on Karpov's radar. Karpov actively avoided playing him, but his assistants were always present at Kasparov's tournaments, studying him, assessing his strengths and weaknesses. Incredible ! There are many juicy tidbits - again like his other books - that make this series such an interesting read.

I highly recommend this book. Perhaps his best so far. Now I am waiting for the next two parts. And I hope, Kasparov will eventually write about his successors - Anand, Kramnik, Topalov and so on. If you have any interest in chess, get this book. Now.

Friday, March 16, 2012

It's a little too late

This is the first country song I remember hearing on the radio and I can trace my liking of Country music to this song, almost 10 years back. I was trying different radio channels while driving. The interesting words caught my attention, as well as the catchy tune, that I later learned is so quintessentially Country. This is the also first Country song I bought on iTunes !

Love, religion, family, pain and humor are recurring elements in Country lyrics, often within the structure of a story. This is a good example of wrapping a sad situation in humor. The video is kind of funny too.

This song topped the Country charts in 1997. But by then Mark Chesnutt was perhaps past his creative prime. Many of his previous songs were quite good. Especially songs like "Almost Goodbye", "I just wanted you to know" are really superb at showcasing his Country talents with smooth simple music.
Last night I came home at a quarter til three
And to my surprise she wasn’t mad at me
I thought she finally realized not to worry, I’d be home
And then I realized this morning she was gone

Oh I shoulda done this and I shoulda done that
I shoulda been there then she’d-a never left
I shoulda been hangin’ on every word she ever had to say

But it’s a little too late, she’s a little too gone
She’s a little too right, I’m a little too wrong
Now would be a good time to change
But it’s a little too late
Although You Tube labels this as "Official Video" the sound and picture are not in sync. Still enjoyable.



Previously ... Remember When

Monday, March 12, 2012

The Ghost Writer

Movie Review : The Ghost Writer
Director : Roman Polanski
Genre : Mystery / Thriller
Staring : Ewan McGregor, Pierce Brosnan, Kim Cattrall, Olivia Williams
Released : 2010
My Rating : 7 out of 10

When The Ghost Writer finished, a lot of small details came back to me - oh that's why that character did this or said that. Those small realizations made the movie worth the time. In spite of the outlandish premise, few convenient coincidences and at least one "oh, come on" moment.

Based on a novel, The Ghost by Robert Harris - which I haven't read - this is a genuine mystery movie. Very little action, no smart alec one liners, just a focused plot that lets the viewers connect the dots.

Retired British Prime Minister Adam Lang (Pierce Brosnan) is writing his autobiography. When his ghostwriter is found dead, another writer (Ewan McGregor) is hired in a hurry. We never learn his name ! My guess of the novel being told in first person was correct. When this new ghostwriter arrives, he finds himself in a tricky situation. Lang's marriage is breaking and at the same time, he is being charged for torturing suspected terrorists. As our protagonist tries to work hard given the circumstances, his investigation puts his life in danger.

Most of the story happens from the point of view of the ghostwriter. We know what he knows. That's how a good mystery should be. But it poses a tough challenge for the actor to carry the entire movie. Ewan McGregor is a perfect choice for this role. The ghostwriter wasn't that keen on taking this assignment, it's just thrust onto him. He slowly gets interested in finding the truth. In his typical style, Ewan McGregor underplays it well.

It's obvious that Adam Lang is loosely based on Tony Blair, with enough references to Iraq war and supporting USA. It's possible that your political views may distract you from the story. For me, it didn't matter at all. In any case, Pierce Brosnan does a superb job with the limited screen time. He has really moved beyond James Bond, proving how good he is as an actor. See Seraphim Falls as an example.

Olivia Williams, perhaps gives the best performance of the movie. A bitter wife, with ambitions of her own.

Another great performance - so to speak - is how and where the movie is shot. The location is absolutely perfect. Serene, posh and lonely. Maybe a bit scary too. It's worth watching just for this aspect, which has a sizable impact on the impression of the movie.

I know some of you might be turned off because the director is Roman Polanski. In spite of all his troubles, and personal flaws, he has definitely produced good movies. This is not his best, but it's quite good.

In case you are wondering - and I won't give any spoilers - the "oh, come on" moment for me was when someone uses Google search to connect the dots. Really, if this information was publicly available then why did no one else made good use of it ? Well, it's a movie, so let's just leave it at that.

As you can see, the movie has some flaws. Almost all thrillers seem to have some. It's still lot of fun and worth watching, and gets my recommendation. This maybe OK for older kids, if they like reading mystery/thriller/intrigue type of novels.


Sunday, March 4, 2012

Whole Wheat Artisan Loaf !


Baking a good whole wheat bread is much harder than baking regular white bread. Whole wheat flour is heavy and not easy for the yeast to break into. As a result, the bread doesn't rise as much and is denser.

I have been trying to perfect the whole wheat bread for a long time now. In my bread machine, the 100% whole wheat bread always comes out amazing. But that doesn't give me as much satisfaction. I want to do all steps by myself and bake an artisan loaf using only whole wheat flour.

Now, I cay proudly say that I can bake a 100% whole wheat artisan loaf, that looks good and tastes good. Of course, it's denser than white bread, but still has a very soft and airy crumb.


I used the same proportions mentioned in the recipe I have given before. I made one modification, based on idea given by Peter Reinhart.

I boiled the water needed in the recipe. To that, I added 1/3rd of the whole wheat flour required in the recipe. Then let this mixture sit overnight. The hot water kind of cooks and breaks down the tough flour and makes it easy for yeast to extract sugar.

Next day, I added rest of the dry ingredients - remaining flour, salt and yeast. And followed the rest of the steps as is. I am very used to handling wet doughs, so I can shape it well and score it. Scoring not only makes it look beautiful, but also helps it rise to a good shape when it's in the oven.


Now, I have to crack the sourdough. Next would be the whole wheat sourdough. Then I would achieve everything I wanted to achieve in bread baking !

Tuesday, February 28, 2012

Just Go With It

Movie Review : Just Go With It
Director : Dennis Dungan
Genre : Romantic Comedy
Starring : Adam Sandler, Jennifer Aniston, Nicole Kidman, Brooklyn Decker
Released : 2011
My Rating : 4 out of 10

After the over-the-top-crudeness of "You Don't Mess With Zohan", director Dennis Dungan and actor/producer Adam Sandler have teamed up to give us a movie that's being labeled as a "romantic comedy". Disappointingly, it is neither romantic nor funny.

Danny (Adam Sandler) is a rich and successful plastic surgeon. He has a fake wedding ring and pretends to be in an unhappy marriage, just to have one night stands with young women. When he meets Palmer (Brooklyn Decker), he thinks he found the love of his life. But she thinks he is married. And so the lies start. He has to introduce Palmer to his wife, with whom he is supposedly getting divorced. To play that part, he requests his secretary, Katherine (Jennifer Aniston), who is a single mom. Naturally Palmer hears about the children, and Danny gets sucked into saying bigger and bigger lies.

That's a good enough plot for making a nice predictable romantic comedy to enjoy and forget. Alas, the execution guarantees only the "forget" part of it. I haven't watched the original movie (or play) "Cactus Flower" from which this is adapted, so I cannot offer comparisons. I doubt, if it was as forgettable as this one.

I would have never thought Adam Sandler can be as ineffective as he is here. The attempts at being funny are pathetic - not crude, not gross - just lame. Of course, a big reason is the script which feels like written by an intern. Jennifer Aniston tries hard, really hard to make it work - but it's obvious that she is trying, and it doesn't feel natural. Brooklyn Decker was not chosen for her acting, so why bother evaluating it ? And Nicole Kidman would probably like us to not just forget the movie, but also her role in it.

No Adam Sandler movie is for kids, you should know that by now. But seriously, don't watch this one, rather spend that time watching an episode or two of your favorite sitcom.

Tuesday, February 21, 2012

Hidden Reality

Book Review : The Hidden Reality
Author : Brian Greene
My Rating : 3 out of 5 stars

The complete title of the book is "The Hidden Reality : Parallel Universes and the Deep Laws of the Cosmos".

Brian Green is a professor of Physics at Columbia University. His first book "The Elegant Universe" was a major New York Times Bestseller and has been made into a similarly titled Nova series. And with an appearance on the hit CBS sitcom, "The Big Bang Theory", he is one of the rare physicists that can claim a celebrity status.

His first book opened the doors to The String Theory for laymen like me. I had always heard about it, and thanks to Brian Greene, I know the basic outline of it. His second book, "The Fabric Of Cosmos", was also well received, and personally, I liked it more than the first book.

To say that the physics of 20th century is not intuitive would be an obvious understatement. Neither Einstein's Relativity Theory, nor the Quantum Mechanics sit well with our everyday life experiences. That's a limitation of our senses. The predictions of these theories are verifiable by scientific observations.

String Theory is not completely there yet. It has the potential, and far better minds than mine believe in it. So I see no need to question it, but much of the content in the second half of Brian Greene's first book felt a bit speculative. Of course, he was aiming to introduce the readers with the cutting edge research, and he succeeded in it.

Why do I mention that ? Because his latest book, "The Hidden Reality", is even more speculative. Again, he is introducing the readers to the latest thinking in physics. To untested theories, which may be proven wrong.

The core theme of the book is about the various flavors of the multiple universe theory. After the big bang, it's possible that multiple universes were created. Each having billions of galaxies. Our universe is just one of the many, or infinitely many. We may never detect those other universes, but Brian Greene outlines the logic, which indicates that, they are out there. But the very nature of the underlying idea makes me squirm - is this really science ? It's almost like, we can neither prove their existence, nor disprove it. To be fair, the author tackles such doubts head on. His justifications didn't convince me. This could very well be due to my feeble non-physicist mind. Nevertheless, this was a shortcoming of the book to me.

It could also be due to the order of presentation. The multi-verse theories are presented in first few chapters, and then their basis is questioned. A bit more effort in setting up the expectations about the speculative nature of the theories would have helped.

The tail end of the book is not as well written as the rest of the book. From a scientific point of view, he discusses questions similar to "How do we know we are not living in a Matrix ?". I am not fond of such debates. To me, these are exercises in futility. Maybe he wanted to discuss it for the sake of covering all aspects of multi-verse theories. That aside, his discussion is repetitive and tedious. Fortunately, it's a small part of the book.

If you are able to leave these complaints aside, the book is worth reading. The subject matter is really advanced, and making it accessible to general public is not an easy task. Considering what he is trying to explain, I have to applaud his effort. The previous too books did a better job, no doubt. But this book has many plus points as well. When they say, a certain star is at a certain distance from us, I had always wondered - is that the distance now, or when the light left that star or something else ? I found the explanation here very friendly. As was the explanation of Hawking Radiation of a Black Hole and its importance. Very well done.

I definitely recommend this book. You have to have the motivation and the curiosity to read books about cutting edge science. You already know if you are that type. If you want to start reading popular science books, I would rather recommend Brian Greene's first book "The Elegant Universe", or Simon Singh's "Big Bang", or even some older books by Gamow and/or Feynman.

Friday, February 10, 2012

Bottle Shock

Movie Review : Bottle Shock
Director :  Randall Miller
Genre : Comedy / Drama
Starring : Alan Rickman, Bill Pullman, Chris Pine, Rachael Taylor
Released : 2008
My Rating : 7 out of 10

If you think the typical strategy of using an underdog story to make a feel-good movie has nothing new to offer, you need to watch Bottle Shock. Based on real life events, this time the underdogs are the Napa Valley vintners in 1976, competing against the mightily snobbish French.

Steven Spurrier (Alan Rickman) is a multilingual Brit, running a fledgling "Academy of Wine" in Paris. His neighboring shop-owner and what seems like his only customer, gives him an idea of a publicity stunt to revive his business. A blind wine tasting competition between the French and the "new world" wines. So he comes to Napa Valley in search of finding some competition, although he is very skeptical to say the least. A chance encounter introduces him to Jim Barrett (Bill Pullman). His winery is also struggling, and he too is very skeptical of this snobbish gentleman - fearing that the competition won't be fair. Helping Jim in his wine-making, is his son Bo Barrett (Chris Pine), a new intern Sam (Rachael Taylor) and a Mexican immigrant Gustavo (Freddy Rodriguez).

It's a fictionalized account of what happened then between all these characters and how the competition was won by Napa Valley. In spite of the little publicity the competition received at the time, it put California on the wine map, squarely competing against the myth of the French wine. Lot of success depends on marketing and hype, especially in Wine industry, and this was the trigger that lit the fuse.

It's such an enjoyable movie that it's easy to forgive its flaws. It totally fails as a love triangle, mainly because Sam's character is so ill-developed. The commentary on racism feels very out of place because it doesn't add anything to the story. But the dramatization of the events leading to the competition is lot of fun, and makes the whole package stand out. The tone is always light, and goodhearted. The acting is just OK, except Alan Rickman,  and if I have to use typical wine lingo, adds a bright acidity to an otherwise mellow round bodied fruitiness :-)

I have to mention a couple of spoilers, so forgive me. When Jim asks, "Why don't I like you ?", Spurrier responds, "Because you think I am an ass... I am not, it's just that I am British, and well, you are not". So when Spurrier pays him for tasting, Jim asks his son Bo to take Spurrier on a wine tour. All vintners are surprised - "He wants to pay for tasting ?", and are happy to oblige. Oh, what times ! Today, tasting brings in a sizable revenue to Napa Valley. Good for our economy, but I still wish Spurrier hadn't started this damn tradition.

Whether you like wine or not, I definitely recommend this movie. A note : this is nothing like Sideways, which was a much better movie because wine was a backdrop, with focus on characters. Here, wine competition is the story, and people are just a sideshow. It's not for the kids, but it is much safer than Sideways.



Sunday, February 5, 2012

Hummingbird Eggs

 Hummingbirds are common in my area. I was able to take a photo of one - because it was resting ! See here.

I find them one of the most amazing creations of nature. Their nests are equally amazing. You would expect it to be tiny, and you would be wrong - it is even tinier than what you might expect :-)


It's only about an inch in diameter. It seems like made of mud and is glued to the branch. (Wikipedia tells me, a lot of spider silk is used to make it sticky). Here is another photo to give you an idea of the scale.



The eggs are as small as jellybeans !

No eggs were harmed in taking these photos ! But I didn't get to see the chicks. I didn't want to disturb anything, so didn't go near it again. From a distance, it was hard to see if the eggs hatched. Other birds, and even ants are likely predators of these eggs. The nest seemed empty after a few days :-(

Monday, January 30, 2012

Brilliancy by Aronian

Every January, Wijk Aan Zee holds the prestigious chess tournament. It is sponsored by Tata Steel, who bought Corus a few years ago, and have continued supporting the tournament. This year, it was won by Levnon Aronian from Armenia, who is among the only 5 players to ever cross the 2800 ELO rating.

His win with black over Anish Giri (a child prodigy himself, and a super-GM with rating over 2700) was a brilliancy. The entire game is very complicated, and is worth playing over. I would like to present just the final moves.

Be prepared to be amazed. If you want, you can pause here, look at the following position. With black to play, how will you proceed ?

Position after white's 41. Ra2

As you can see black (Aronian) has sacrificed the exchange (rook for a bishop). White doesn't have a strong attack, despite the open h file for his rook. On the other hand, black can build up strong attack on an open white king. That's easy to understand. But how should black proceed ?
41. ... Ne1!!
Position after black's 41. ... Ne1!!

The difference between a grandmaster and a wood-pusher (like me) is enormous. It's not just the memory, the knowledge, the ability to calculate many moves ahead or even the intuitive feel about a position. It's also the imagination. Calculating all the consequences of such a move is beyond us, that goes without saying. Truth is, we won't even try to calculate such a move, because such a move simply doesn't come into our imagination. This is where chess becomes what it is loved for - a truly unique combination of logic and art.

What's the point ? The threat is of course ...
42. ... Nd3+
and any way the king moves results in a lost position for white.
If 43. Kb1 Nc5+ wins the queen.
If 43. Kc1 Nxf2+ wins the rook.

White accepts the sacrifice. He doesn't have to, but finding the least damaging move in tournament play is extremely hard for such positions.
42. Rxe1
 Position after white's move 42. Rxe1

OK. But now what ? Black is down a full rook.
42. ... Qf4+!!
Black offers even more - now the queen. Of course, it's untouchable.
Position after black's 42. ... Qf4

If 43. Nxf4?? Rxe1+# is a pretty mate delivered with very little material.
That's the main point behind the knight sacrifice - to allow the queen to go to f4.

If the rook was still at h1, this queen offer wouldn't work, as the rook protects the e1 square from mate. But by being lured to come to e1 to capture the knight, the rook became a target instead !

But that raises another question - why does the queen want to go to f4 ?
Because it's on its route to the intended destination.
Naturally white plays the only real move
43. Kd1
Position after white's 43. Kd1

Now comes the quiet but crushing move.
43. ... Qe4!
 
Position after black's 43. ... Qe4!

0-1
White resigned due to the unstoppable threats on the b1-h7 diagonal.
Black queen goes to d3 and/or b1 to give mate or just win a lot of material.
This e4 is where the queen wanted to come after it has forced the white king to get stuck on d1 by giving the check from f4. But the check from f4 was not possible as that square was protected by white's knight. The idea behind the knight sacrifice is to lure white's rook to e1, which very indirectly enables the black queen to safely go to f4. This is beyond brilliant.

The question Aronian must have asked himself is, how to make it safe for the queen to travel to f4 and then to e4. This level of reverse reasoning is beyond us. Even if the question was directly asked, we won't be able to answer it. But remember, he even had to invent the question itself ! It's like explaining a magic trick. Sometimes it seems obvious when explained. But figuring it out is not the real genius. It is to be the one that comes up with the idea behind the magic trick.

In three amazing moves, without capturing anything, black won the game.

Tuesday, January 24, 2012

Alcatraz

Review (First Impression) : Alcatraz
On Fox : First episode aired in Jan 2012
Rating : 4 out of 10 (based on pilot)

I am very selective when it comes to watching long TV series, whether its drama or action. It's a lot of commitment of time. Time, which can be used to watch something else, or just sleep. Very precious. I have a much higher tolerance for movies. If a movie turns out to be not so good, it only wastes a couple of hours.

So generally, I simply choose to not watch a TV series, till I hear a lot of good things about it, and then watch the entire seasons on DVD. It worked well for "Rome", and first seasons of 24. In other instances, I have quit midway in season 1 DVD itself, for "Tudors" and many others.

This year, I decided to try to be current. Alcatraz ads that were getting bombarded during the NFL games, hooked me on. Especially, because the story happens in my neck of woods.

After watching the pilot, I have to give up on this rather quickly. I was OK with the weird Sci-Fi like premise. Before Alcatraz closed, a lot of prisoners simply vanished. Now they are suddenly coming back, and causing mayhem. Some time travel is indicated, as they haven't aged a bit. This could have been interesting. But it isn't.

There are numerous problems. I can handle the unexplained. It's too early for explanations. But the ease at which the characters (the lady cop and the Alcatraz expert) accept the weird happenings makes it unbelievable. There is no shock, no confusion. They just accept it as routine case. Then there is this mysterious special unit whose sole task is to track and capture these bad guys. It's super secret, but our lady cop joins it with little effort. Even the civilian author gets initiated just like that. That one sequence gave me real bad feelings about this. And the guys who come back, have no problem adjusting to the modern times. No future shock. There is complete disrespect for viewer's intelligence.

Overall, this seems to be going the way of "Lost". Mysteries within mysteries, inexplicable events happen in such a way, that not only the viewers are dumbfounded, but even the writers cannot figure out how to get out the hole they dug themselves in. I gave up on "Lost" in just a few episodes of season 1. After reading about how the later seasons frustrated many (except the die-hard fans), I feel happy about not watching Lost.

Alcatraz may be able to handle its own enigmas better. Or maybe it won't. I don't see much point hanging around. And if it does manage to keep itself in check, I can always watch it on DVD. I seriously doubt it though.

Let's see what "Touch" does now.


Friday, January 20, 2012

Oxford Murders

Movie Review : Oxford Murders
Director :  Álex de la Iglesia
Genre : Suspense / Mystery
Starring : Elijah Wood, John Hurt, Leonar Watling
Released : 2008
My Rating : 5 out of 10

How do you take a decent mystery plot and convert it into a mess of a movie that’s so superficial in its attempt at being intellectual that it gets really irritating ? Answer : Oxford Murders.

Martin (Elijah Wood) arrives in Oxford to learn under his idol Professor Arthur Seldon (John Hurt), who, as expected, is obnoxious. There he meets Lorna (Leonar Walting), a nurse, who we learn later, had an affair with the older professor. A murder happens, and then another and a hunt is on for a serial killer who is leaving mathematical clues.

Nothing wrong with this idea. But the script is overly focused on appearing smart, and that desperation is obvious. It completely fails to impress us with all the references, because the it's just constant name dropping. Wittgenstein, Turing, Heisenberg, Fibonacci, Gödel, Pythagoras, Fermat - all the right names, and nothing else. By the way, Andrew Wiles did present his first proof of Fermat's Theorem during the same time period, but the movie changes his name for some unknown reason.

The love triangle is laughable, because we don't even understand why Lorna fell for any of those. The truth is, there is not one believable moment of human interaction.

This is all sad. The kernel of the mystery had potential for surprises. Actors are capable. (Elijah Wood is really trying hard to shed his Frodo Baggins image.) Camera work is not bad either. But the writing is amateurish. I think a lot of blame can also be placed on the original novel.

I cannot really recommend this movie. It's definitely not for the kids. There is no gore - the murders are "clean", so to speak, but there are disturbing images. If you are willing to endure pseudo-intellectual blah blah for a potentially good suspense idea, then by all means watch it.




Tuesday, January 17, 2012

Remember When

I "discovered" Country Music over 10 years ago. I was flipping channels on the car radio, and stopped when a tune sounded catchy. Then the lyrics caught my attention ... hmmm ... words that actually made some sense. Finally ! Then as I listened to more and more Country songs, I found songs that I can actually relate to.

I have a very open mind when it comes to music, movies, food and books. But I used to get turned off by vulgar music videos and lyrics that make no sense. Till I discovered Country Music. So I have decided to write about Country songs that I like !

Alan Jackson is one of my favorite artists. Great voice, simple touching music, and almost always, great lyrics. Starting with one of his best. This is almost poetry.
Remember when ... thirty seemed so old
Now looking back, it's just a stepping stone
To where we are, where we've been
Said we'd do it all again
Remember when ...

Remember when ... we said when we turned gray

When the children grow up and move away
We won't be sad, we'll be glad
For all the life we've had
And we'll remember when

Enjoy !

Related Posts Plugin for WordPress, Blogger...