Monday, December 16, 2013

Safe House

Movie Review : Safe House
Director : Daniel Espinosa
Genre : Action / Mystery
Starring : Denzel Washington, Ryan Reynolds, Brendan Gleeson, Vera Farmiga
Released : February 2012
My Rating : 4 out of 10

I generally like action movies featuring secret agents, spies, special forces and what have you. I do not expect much realism. Let there be convenient coincidences and unbelievable twists. Let the protagonists have super human skills. Just don’t give me time to think and keep me glued. For example, that’s what movies like Taken and Bourne movies did. Alas, it’s much harder to use that formula and there are many more flops than successes.

Safe House has the right although generic idea consisting of three main elements. First, a rogue agent, Tobin Frost (Denzel Washington), once an elite, now a legend. He has resurfaced and is in possession of secrets that he plans to use for blackmail. Second, a young aspiring agent Matt Weston (Ryan Reynolds) who is trying to prove himself. He unexpectedly finds himself in a tricky situation of trying to outsmart Frost. Third and last, a mole high up in the command chain that knows every move these two are going to make.

It’s starts off well. Weston is stuck in a claustrophobic job of maintaining a safe house. He clearly is not prepared for these complications. Before he even gets a chance to comprehend the situation, he is a target of well trained mercenaries who are more well informed than he is. It builds up an interesting foundation.

That should lead to a movie that just breezes through 90-100 minutes of fast paced scenes, witty dialogues and some double crosses thrown in for good measure. It should, but it doesn’t. There is a lot of running around and lot of chasing that doesn’t really go anywhere. And there are a lot of gunshots and ambushes that fail to raise our heartbeat. Even at two hours, it feels way longer than needed. The suspense is beyond predictable. That’s not a the real shortcoming. The fact is. we just don’t care what it is when the movie ends.

The screenplay is repetitive and unimaginative. I have never been to Capetown, South Africa, but I am willing to bet there aren’t that many areas there, where you can have a shooting match without ever being noticed by anyone, let alone cops.

It seemed to me that most of the actors were aware of all the flaws. Hardly anyone tries to be believable, as if their heart is simply not in it. Except Ryan Reynolds, who tries too hard. But at least he tried. I cannot say that about Denzel Washington, who otherwise is a fine actor. The rest of the cast gets very little screen time anyways.

There are many better spy thrillers out there. My recommendation is to skip this one.

Sunday, December 1, 2013

My first song :-)

More than a year ago, I noticed that one of my blog articles is getting lot of hits. I wrote that article, ”How To Write Lyrics For Hindi Movies”, as a sarcastic take on the quality (or lack of it) of lyrics found in Hindi movies. It was written almost 20 years ago on a Usenet group, and I just archived it on my blog. The search engines don’t have much sense of humor, so as you can see, this article appears at the top of search results! My apologies to those who were looking for real information.

That got me thinking. Why just lyrics? Why not compose a whole song? So here it is. A song written by me, tuned by me (!) and also sung by me :-) Don’t be afraid, read on.

First the lyrics.
agar maiN tum se yeh kahooN, mere dile mein hai too hi too
     mujhe hai bas teree hi aarazoo,
meree saaNso meiN hai too basee, aur manzil hai too meree
     ruh ko bhi hai teree justajoo

tere deedaar-e-ruKH-e-roshan binaa, zulmat-e-shab ho kaise fanaa
    gar haal-e-dil yeh kar duN main bayaaN
kya mere pyaar ko apnaaogi, ya rooth ke thukaraaogi
   kya hogaa tumhaaraa faisalaa

o meri jaan, o meri jaan
tere bin main kaise rahooN mujhe na KHabar hain na pataa
o meri jaan, o meri jaan
kuchh to kaho, yuN chup naa raho, ab aur naa lo imtihaaN
If you are feeling adventurous enough, you can listen to me singing it.

Now some clarifications. I have no illusion of being any artist. I am no singer, no lyricist and no composer. This is just a bit of fun. The lyrics are indeed written by me, and yes, I am the one singing it, if at all it can be called singing.

But the tune is not mine. It’s from one of my favorite Country songs, I told you so.

That’s the point of this exercise. If you are willing to plagiarize a tune, it’s extremely easy to come up with “your” song. The original lyrics give you an idea on where to start. The ready made tune provides a nice rhythm so that you can write fluid lyrics without having to worry about mundane stuff like meter ;-). In a couple of hours, you have a “new” song ready. No hard work required.

Maybe even more clarifications are needed. I am not advocating theft. Plagiarism is bad. It’s indefensible. Arguments such as “paying tribute”, “borrowing ideas”, or “making it more popular” are all flimsy, and wrong. I am just trying to illustrate how easy it is to plagiarize.

Monday, October 28, 2013

Calculating Integer Partitions

This post can serve as a nice interview question. Because some problems can be deceptively simple. Knowing the formula MAY NOT be enough to write an algorithm to compute it. Allow me to explain using the example of Integer Partitions. If you want the explanation on how this formula is derived, you can read it here.

To recap, Integer Partitions of a number, are ways the number can be expressed as sum of smaller numbers. And, P(N), the number of integer partitions of a positive integer N can be expressed as
P(N) = PP(N,1) = PP(N-1, 1) + PP(N, 2)
Where PP(N,k) is the number of partitions in which the smallest addend is at least k. And
PP(N,k) = 0 if N < k
PP(N,k) = 1 if N = k
PP(N,k) = PP(N-k,k) + PP(N,k+1)

Here is how it can serve as an interview question to test the programming skills. The “natural” recursive solution can be easily implemented as follows.

public static int recursivePP (int N, int k) {
    if ( N <= 0 ) return 0 ;
    if ( N < k ) return 0 ;
    if ( N == k ) return 1 ;
    return recursivePP(N-k, k) + recursivePP(N, k+1) ;

This is grossly inefficient. Because intermediate results are unnecessarily computed multiple times. Every time the recursion reaches a particular pair (a,b) it will issue another recursion and calculate it all over again. So the code is natural, but not smart. It would take forever to compute say P(100) this way. What’s needed is a solution based on dynamic programming that builds P(i) as i goes from 1 to N. To do that we need to store the table of values for P(N,k).

Consider the following code.
public static long[][] PPvalues = new long[100][100] ;

public static long iterativePP (int N) {

    if ( N <= 0 ) return 0 ;

    // init P(N,k) for N=1, k=1
    PPvalues[1][1] = 1 ;

    for (int i = 1 ; i <= N ; i++) {
    // mark PP(N,k) where N == k
    PPvalues[i][i] = 1 ;

    for (int j = i-1 ; j > 0 ; j--) {

        long pp1 = ((i-j) < j) ? 0 : PPvalues[i-j][j] ;
        long pp2 = (i < (j+1)) ? 0 : PPvalues[i][j+1] ;
        PPvalues[i][j] = pp1 + pp2 ;

    } //
    } //

    return PPvalues[N][1] ;

Now this performs incredibly faster than the recursive solution. O(N^2) is not ideal, but it’s not bad either. This answer should usually be enough for an interview question.

Unfortunately, it’s not enough for finding out the value of P(N) for large values of N. The reason is the memory complexity of the algorithm which is also O(N^2), and our computers have a very finite memory.  For example, even with 8G of RAM I could not calculate the value of P(10000) because there is simply not enough memory to allocate the table.

That was a real bummer. There is no quick and easy way to optimize this to take less memory. Using a better data structure to store only half the table, as P(N,k) = 0 for N < k, of course won’t help much, only by a factor of 2.

One possibility is to compute only a section of the table at any given time. Note that the formula requires only the current column and the previous column, to calculate the value of any cell. You can start from last 2 (rightmost) columns, and keep computing the table leftwards. So you have to store only 2 columns (current and previous), thus significantly reducing memory. That’s a good optimization. The resulting code will be too complex for an interview question though.

Fortunately, there is a better formula for coming up with an algorithm to calculate integer partitions. It is based on pentagonal numbers. But that’s a math question, not a programming question. I will explain that in another blog post.

Monday, October 14, 2013

Boardwalk Empire

Review : Boardwalk Empire
Aired on HBO (2010, 2011, 2012, 2013)
My Rating : 8 out of 10

There was a time when I had no patience for spending many hours to watch a seemingly endless storyline of a TV series. There is always a worry that so much investment of time may not be worth it in the end. That has changed now due to the quality, as well as easy availability of the content. For a well made series, the length becomes an advantage, as characters and subplots can be fully developed, to make it a very satisfying viewing experience.

The pilot for Boardwalk Empire was directed by Martin Scorsese. It was heavily promoted and reportedly is the costliest pilot ever. It was fabulous, and I got totally hooked onto it. I have watched the first 3 seasons live, and this is a combined review for all.

It’s hard to give a concise synopsis of a story that so far has had 35 plus hours of screen-time, and it’s not even necessary. At its core, Boardwalk Empire is a gangster story. But it’s not just a long Irish version of Godfather. Stylistically it’s closer to Goodfellas. There is no one single plot here. The series revolves around ambitions and internal conflicts of every character punctuated by the ever changing alliances of convenience and double crossings.

The premise is loosely based on historical facts of prohibition era Atlantic City, and its powerful political boss of Irish origin Enoch Johnson, named Enoch “Nucky” Thompson here. Nucky (Steve Buscemi) has the complete control of the city - as the gangster boss, leader of the bootlegging operation, city treasurer and a socialite who throws lavish parties. As a help, his brother Eli (Shea Whigham) is the sheriff. A returned war veteran Jimmy Darmody (Michael Pitt) is Nucky’s lieutenant. Chalky White (Michael Kenneth Williams), leader of the local black gang, runs the bootlegging operation for Nucky. A federal agent Nelson Van Alden (Michael Shannon) comes to New Jersey to investigate the rampant violations related to sale of alcohol. Nucky meanwhile falls for the beautiful housewife Margaret (Kelly Macdonald). These are just the some of the main characters that live in the Atlantic City. There are others, from the Jewish gang of Arnold Rothstein (Michael Stuhlbarg) from New York, and the Italians from Chicago including a budding Al Capone (Stephen Graham).

The list of characters may seem rather large, but each one is fully developed. This character development, along with the superlative acting by each is reason enough to be glued to this series. But there are many other strengths. I can guarantee that you would be impressed by the smartness of the dialogues. How often do you pay attention to the music of a TV serial ? You will do that here. It is superb. The production is simply magnificent. It works quite well as a period drama too.

The central character is of course Nucky Thompson, played by Steve Buscemi, the only widely known actor in the entire cast. As an authoritative leader, Nucky is amoral but not irrational. Steve Buscemi brings out all the different shades of the character, and there are many. As the series progresses we learn more and more about him, and other characters. Every actor gives his or her best, and it’s hard to pick a favorite. I can assure you that you will like a few characters so much, that you would complain that they needed more screentime. Which ones, depends on you.

This is a great series but it’s not perfect. It suffers from the same trap every series suffers. The desire to extend it, and keep it running. That requires infusion of completely new characters, and some improbable turns. In spite of that, repetitiveness is unavoidable. In an ideal world, every good series will conclude at the right time. In this world, the temptation to squeeze more money out of the same formula trumps artistic integrity. I wasn’t happy with the 3rd season, for these exact reasons, although it was no less captivating. On the same note, I am perplexed about the current season 4. What more is left to be shown that can be called new?

I highly recommend watching this series. It feels like watching an Oscar calibre movie. I am obliged to include a strong warning. This is not for the faint of the heart. It’s about gangs, correctly rated as TV-MA. You should know what that means before you decide to watch it.

Tuesday, September 24, 2013

Kenya : Rural Images

This is my last post on the images from Kenya. I was ready to post this a few days ago, but decided to wait till the deplorable and horrible nightmare that was happening in Nairobi to be over. Having been to Kenya just three months ago and enjoyed the hospitality of the people there, my heart goes out to them. Truly sad.

So I am presenting these images without much commentary. Most of these were shot from a moving car, as we traveled through the rural areas to go from one wildlife area to another.

Last but not the least, some images from a bead factory we visited in in the outskirts of Nairobi. This factory employs mostly single mothers who make all the beads and related clay items, by hand.

 Previously :
Maasai Mara : Zebras and Wildebeest
Maasai Mara : Buffalo And Antelopes
Maasai Mara : Elephants And Monkey
Kenya : Giraffe, Hippo, Crocs and "Hakuna Matata"  

Monday, September 16, 2013

Kenya : Plants

Every place has unique flora and fauna. But when we mention Kenya, it's always the fauna that comes to our mind. Hardly anyone would think about the flora. I have tried to photograph some interesting plants, but I will be honest. Taking pictures of plants and flowers was not on my mind. I was focused on taking snaps of the abundant wildlife. Still once in a while something would catch my eye, and here it is.

You can click on any photo to start a slideshow.

The first tree that comes to mind at the mention of the the savannah is the iconic Acacia. They are everywhere.

Not just in the savannah.

But in the middle of farms as well.

Of course, Kenya is known for coffee. The beans on this are still not ripe yet.

Nothing but thorns!

Now some flowers. I do not know their names, sorry. If you know, please send a note, and I will update the post.
The next one is a very big flower.

The next one is one of the most common flowers. We saw it everywhere.

The purple flower shoots are coming up through a cactus.

The next one is also coming up through some cactus and thorny branches.

A shower of flowers !

The next is of course leaves arranged like a flower.

A pleasant surprise for me was the variety of cacti. I never thought I would be seeing so many different cacti. I love the cacti and succulents. Together as a species, they exhibit an amazing diversity of symmetries and geometry. I do not know names of most of them.

The first cactus is "candelabra spurge". It is really huge.

The resort at Lake Naivasha has a thicket of these with a paved pathway through these giants. The first one has a vine of purple flowers climbing on this cactus.

Now some cacti with flowers.

The most interesting plant for me was "golden showers". It has beautiful flowers, and the vine just spreads.

It can also climb a tall tree, and then you can see why it was named this way!

Wednesday, July 24, 2013

Maasai Mara : Lions and Cheetah

This is the last post related to animals in Kenya.

Like every tourist, I wanted to see a lion on my visit to Maasai Mara. The area has a good population of lions, supported by a couple of millions of herbivores. So there is always a good chance of seeing the feline predators - which includes lions, cheetah and a leopard.

We didn't see any leopard, as it is the shyest of the three. But the lions have gotten used to tourists, and boy, were we lucky or what!

First, photos of a Serval, a wild cat that gave us a fleeting view. It's hard to focus on a small animal that's hiding in tall grass, or running away from you :-( So apologies for these photos not being sharp.

I wish I had seen a cheetah sprinting behind a gazelle, but I had to be content with seeing one resting. It was about 50 feet away from us. Beautiful animal.

It was aware of us, but made no effort to move away.

The next photo is an unforgettable scene for me. Something that I have seen only in nature shows, and something I have dreamt of seeing.

A vast savannah, a predator waiting in the golden grass, looking at its food and thinking about how to make the move. The problem here was, the antelopes had noticed the lioness and the distance was too much. There was no scope for her catching them. The antelopes were aware of it, and kept on eating their grass, only to pause occasionally to make sure the lioness was not moving towards them. A common scene from the constant battle of life and death that goes on here.

The waiting game continued till we were there, giving me an opportunity to take some photos when the lioness turned her face towards us for some fleeting moments. That look can send shivers down your spine. It was good to be secure in the safari vehicle.
That lioness was less than 50 feet away from us, and I was thinking of it as the highlight of my visit to the Mara. I had no idea then that I would come even closer to another apex predator, a male lion, no less. This time the king and his queen were on a honeymoon. Really!

How close ? Take a look - we were much closer to the couple than those vehicles.

Then they got up and walked all the way to our vehicle. Literally just 5 feet away.

Fortunately, they were interested only in each other, and not in us.

They paid no attention to us, allowing me to take some more photos

That's one good looking but extremely scary animal.

That, was indeed the highlight of my trip!

This concludes the photos of animals. Next would be plants, and then some images of the rural Kenya.


Related Posts Plugin for WordPress, Blogger...