Tuesday, October 07, 2014

Quick Review - The race of my life

I just finished reading Milkha's autobiography - The race of my life. I loved the simple writing and the length of the book. I must confess that having seen the movie earlier made it easier for me to read the book, however the movie and the book do not map 1:1.

Milkha's book is filled with a story of tragedy of the bloody partition, determinism of a father to educate a child, hardwork and struggle of the youth of Milkha and his progress from an Army Jawan to almost a lieutenant, his days as sports administrator and his feelings for the current state of sports.

All the events in which he participated, the cultural gaps between India and the rest of the world and his ability to learn & improve and work hard with the coaches is clearly demonstrated. They are some hilarious moments about his sister Isher thinking he was shot during a race :)

A great read, should not take you very long to complete and you'll end up feeling motivated to reach your goals.

Sunday, August 17, 2014

Math by brute force

I came across a problem in a book on Combinatorics

In how many ways can 5 gentleman and 3 ladies be seated such that no two ladies sit next to each other?

The book's answer was 5!. Clearly not very believable, I decided to warm myself up and try and find an answer.

My first answer was

8! - 2.7! - 6.6!

Something did not seem right, so I decided to use brute force. I wrote quick python code to list 8! permutations (all of them) and discard positions with two ladies together (yes, I permuted classes with numbers and types). The answer was 14400. Clearly I missed something and the computer cannot be wrong - well brute force is usually slow but right :)

A little more thought and use of common sense got me to the right answer

8! - (3 C 2)*2*7! + 6.6! (via inclusion/exclusion principle)

I am so excited to use brute force to check my answers - do you?




Friday, May 23, 2014

Lessons learnt - cheap Android devices

One of the best things about an Android device is that it comes in various form factors and various price ranges. Over the years I've bought close to 6 Android devices. My first device was expensive and had no GPU hardware. I could not play games on it, so I decided to move to another one. This time I got a Nexus 4 as a gift

Then I decided to buy a device from an Indian manufacturer with a quad-core CPU/1GB RAM/GPU and a decent display resolution with a 5" screen (Karbonn S5). The device was cheap and I could not help but compare the device and be delighted with my purchase. Over the year of usage of this device, I learnt my lesson


  1. There are absolutely no updates for the device - why do I care, what this meant is that I was left open to OpenSSL heartbleed.
  2. The phone's hardware, touch screen started failing, some areas stopped responding
  3. The firmware on the phone was signed using test-keys. A lot of useful software started detecting the phone as rooted :)
  4. The key bottleneck for most software is not number of CPU's, but the amount of RAM/Speed of the processor and the quality of the GPU


Lesson learnt - buy a phone with good reliable hardware and frequent updates, use the cheap ones for experimentation and development

The good news is that since the hardware was cheap, I could easily replace it and keep the phone to try a cyanogenmod upgrade on it. Can't do much about the bad hardware though except use it as a device to try experiments on :)

Ranking and Unranking permutations

I've been a big fan of Skiena's Algorithm Design Manual , I recently found my first edition of the book (although I own the third ed...