Saturday, July 23, 2016

Elon Musk's Masterplan Deux for Tesla

Elon Musk went public with his master plan for Tesla -- this is worth a read.

The key points here are: self-driving and sharing!

The killer proposition is that self-driving cars, lease their cars to the fleet -- so rather than sitting in their driveway or parking lot -- (85% of most car's lives) -- your car is out there earning you money -- more or less offsetting any mortgage costs or even net positive for you. I'm sure Uber is paying close attention to this.

Then, there is the big swing at trying to go after public buses and trucks. Now, this has huge implications. Lets trucking first -- my several estimations, trucking is a big employer in the US -- such a disruption has huge implication for jobs.

Now, if we look at self-driving buses -- this is interesting in of itself to reduce costs. He lays out some revamp on bus design -- not so interesting.

Let me try and throw my stab at an even bigger moonshot idea of the sharing economy -- where buses optimize routes around their customers -- customers are asked to locate themselves onto an optimal route for the bus pickup. So here's how it goes:

  1. customer selects on app where they want to go at the time they are ready and range of distance that they can walk/drive to.
  2. The routing algo works out the nearest bus going in the correct direction and works out the pickup point for the customer
  3. Customer makes their way to pickup point

    There is a critical mass of shared road traffic beyond which this game is ready to roll. Like any sharing ride business -- this about critical mass, and large vans just take this to the next level.

Tuesday, July 19, 2016

Liquidation & Section 75

Recently, I had the pleasure of having a paid holiday going kaput, because lowcostholidays, the company I booked it with going into liquidation.

That opened me up to the wonderful world of  Section 75 of the consumer protection act. This means your credit card must protect purchases over £100. The claim is still under process so we will see how this goes. But this makes me think of using credit card for payment wherever feasible.

Monday, July 18, 2016

Urban Wildlife: You'll know what this spider did this Summer


Look what I found this morning in the back-garden. The spider is wrapping some more yarn around this poor fly. If anyone knows exactly what's going on, or which species of spider this -- it will really help if you leave a comment.

The other thing of interest for me was that this is my first video with my new Samsung S6 -- the quality is remarkable (the one uploaded here has been compressed) -- I will upload the original on youtube soon. The ability to focus on this tiny spider really spell binds me to the advances in the common camera-phone :)

Machine learning for chess

Having spent some time hacking away at stockfish, and understanding its heuristics, it makes it clear how simple rules Based approach is good enough to make stockfish the strongest open source chess engine.

I've been meaning to take some machine learning approaches at chess. There looks to be some promising work by erik bern which is worth exploring. Hopefully I will sort some time out and have a play with some approaches and will have something to share.

Essentially we would use positions as data and moves as assigned labels in a supervised learning. Worth a go!

Sunday, July 17, 2016

Profiling Python Code

While trying to optimize some code, I discovered cProfile profiler for python. This is pretty nifty.

It can be invoked on the command-line as a -m option, e.g.:

python -m cProfile

Brexit is about values

Thought provoking read LSE's Eric Kaufmann argues value driven data correlates heavily with Brexit!


In this post I will attempt to solve CodeChef's NDIFFPAL problem and explain my thinking as we go:

As a first observation, if we have all characters of a string identical, e.g. "aaa", we will see that there are 6 different index combo's ==> (1,1) (1,2) (1,3) (2,2) (2,3) (3,3). After some scribling around for relationship of string length and number of index combo's, this reduces easily to Triangular numbers.

Now, if we think of all the input to the puzzle that are not triangular numbers, if we reduce that number to a sum of triangular numbers that have appeared before it. e.g. 13 = 6 + 6 + 1 => so, one can represent this as "aaabbbc". The largest input possible is 10000 => closest floor triangular number to this is 9870 -- so the 140 index triangular number.

I think might as well generate all the triangular numbers till we hit the largest input and then decomposition, finally link that to printing unique strings. On second thought that it very inefficient since most of those will not be needed.

What we really need is a way to find the largest triangular number smaller than a given number and then note that and reduce the running number by this triangular number.

EDIT: An even better hack is to hard-code the 140 triangular numbers and binary search the array. This would be super-quick.


  1. There were much easier solutions acceptable since this is a very 'loose' problem. e.g. just repeating the character set and printing the number of character as the input would suffice as a decent base case.
  2. Figurate Number are an interesting field to explore further -- this will probably re-appear a lot in problem solving!
  3. Hard-coding can be king for time limits
  4. ASCII to int and vice-versa

Here is the solution:

Book Ack

I helped review  Magued Iskander's  Innovative Techniques in Instruction Technology, E-learning, E-assessment. He shares an acknowledgement -- nice of him.

CLR soutions

Programming contests

A great quora answer set for links to Programming Contests.

Saturday, July 16, 2016

SPOJ: Prime Number Generator

Here is my first attempt at solving for SPOJ PRIME1 - Prime Generator. This one times out though I have a few ideas I thought I'd pen down for future implementations:

  • Prime generator: survey literature for given a range(x, y): best way to generate primes. In terms of primality tests -- there is no dearth of these. Miller-Rabin is quite well-studied.
  • Seeds: Find the best way to store all the seeds needed -- do I need to create a lookup for primes? or some other seeds. The space limits provided are of 1.5 Gig -- which can easily hold a hard-coded  list, though I'm not certain one would hit paging bottlenecks.
  • Create range lookups for already looked up primes: So, we get ranges (xi, yi) -- so long as  we can find the super-ranges from these such that they reduce these sets to cover all ranges asked for -- we can generate fewer lists and hold. This super-ranges should reduce the waste of re-producing the same lists
  • I'm not entirely certain if we will hit memory issues in which case might have to re-arch to spit out as we go.

    EDIT: None of the above was neccessary, just used the code from Rosetta Code to make it accept the timelines. Need to start using some profiling tools in the future to help with optimizing on mem and time.

EDIT: The on that passed:

Hindi grammar

Found this really useful guide on hindi vyakaran

Friday, July 15, 2016

DuoLingo, Skype pals & Telenovela method

As I revise my German, I thought I'll summarize some of the tools I found best in my language learning:
  • DuoLingo: This app is just amazing -- gamifying language learning -- its really great to pick up basic vocab and grammar and gets you to quite a decent level very quickly.
  • Skype pals: If you can use the intercambio format with native speaker in real life or over skype that works very well. 15 mins in 1 lang, 15 mins in other and then ping pong. Meetups are great for this as well.
  • Podcasts: I found podcasts like coffeebreakspanish really useful too. You can listen to them while working out -- great way to beat the boredom :)
  • Telenovela method: Now this is an interesting way and I have found this reasonably effective.
There are some great resources online by language and I will try and post them in due course.

Chess entertainment

If you want to run through some ultra-aggressive trap-ridden games -- take a look at Greco's games. Born is 1600, Greco notes several tactics and games -- though most are probably compositions. They are extremely entertaining -- do take a look :)

Chess Tactics: Counting

The single tactic that drastically improved my chess is Counting. This is simply counting points on pieces that if attacked and re-attacked will accrue. This is often key in openings and focussing on this will take away a lot of the naive pieces that you may give away up-front. Take a look at The Greatly Misunderstood and Potentially Challenging Tactic "Counting" to start you off. 

Gist-it : Embedding github code into your blog

Discovered this really useful tool -- Gist-it -- it lets you embed your github code into your webpage. Its brilliant!

Using Python dict for Graphs

I recently came across a coding contest question to find all the unique paths from one vertex to another and ended up using Python dicts for this. Some excellent guidance on Python Patterns - Implementing Graphs .

Here is my code:

Thursday, July 14, 2016


How many people would want a devolved London? The The Independent presents some interesting stats.


Just trying out the blogger app for android.  Very very very basic,  but I guess it does the job. You can always spruce it up when you're back at the desk.

Swimming Stretches

I always do a few shoulder stretches and hamstring and quadriceps stretches before and after the swim. Discoved MrSwimFit's  wonderful interactive guide on Stretches for Swim

Solving Mazes for Programming Contests

For programming contests we frequently have to solve for mazes, here is a naive approach to escaping a maze, that I used to solve for a maze problem. Also re-acquainted myself with Lee algorithm which uses a wave propagation approach.

Trapping the bishop

I'd written earlier about Trapping pieces. I had a great opportunity to do this recently. In this game on move 22, I find a golden opportunity to take advantage of a badly placed bishop along with double pawns. The bishop becomes useless for the rest of the game moving the action to the other side of the board. Love it when I get a a chance to practice some theory in the wild. 

Negative rates and economics

A lot of crazy mad hatter behavior seems to be demonstrated by the markets these days. Found a couple of interesting reads. Reformed broker tries to explain how bonds and stocks have done a musical chairs on us. Bloomberg view takes things much further challenging some fundamentals of econ 101. Leave a comment if you found these interesting.

Wednesday, July 13, 2016

Juno captures images in orbit

These are exciting times. There is a probe near each of the planets visible to the eye. Juno had just started returning images of Jupiter and galilean moons from orbit.  Fascinating stuff! 

Hobson's choice - Vaudeville Theatre

Hobsons choice at the Vaudeville has strong performances from Naomi Frederick playing Maggie & Martin Shaw playing Hobson. Hobsons choice has shades of King Lear - story about a tyrant father and 3 daughters running a shoe shop. It goes into the Victorian mores of class relations and gender issues. But its mainly about the determination of Maggie the eldest finding her place in society and Hobson in King Learish fashion losing all and then finding humility. The production set is one to watch for.  3 stars.
Here is the script on Gutenberg:

PS: Didn't realize this is the same Martin Shaw who played a brilliant and crafty titular role in Rhodes. 

Sunday, July 10, 2016

Dhanak (film) (5 Stars), Manganiyaars, Nusrat Fateh Ali Khan

First and foremost let me start with a short review of the Nagesh Kuknoor super-awesome children music travel saga Dhanak! Dhanak is story of two very sweet and direct  kids Chhotu and Pari, who embark on a tour in search of Great King Shahrukh Khan ji so that he can help return Chhotu's eyesight. Along the way they meet a cast of colorful characters. The backdrop of rural Rajasthan is as much a character. These 2 children give a heart-melting performance to make this the breakout film of the season. 5 stars from me.

The Mast Qalandar song lights a flame to my cords. Reminding me of the Manganiyaar's Seduction -- the group of musicians who set the Barbican on fire a few years back. These musicians bring a new meaning to orchestra, with their conductor extracting an amazing vocal and instrumental treat out. A performance that should be on every folk music lover's bucket list.

Mast Qalandar then brings me to Ustad Nusrat Fateh Ali Khan -- I remember going through some interesting backstreet deals to score tickets to his concert many many years back. His performance opens my eyes to sufi music. Qawalis are never cooler. He did so much to bring the 2 Stans (Hindustan and Pakistan) nearer.

Let me round it off with a shoutout to Satrangi for their Rajasthan episode.

Trapping Pieces

I've been meaning to read the next module in Dan Heisman's awesome Tactics book. I did not however expect to fall for this -- I come out feeling both happy and stupid that I helped create an example of trapped rook here.This game  -- Notice how on move 17, I ask for this. Black ends up winning the rook without a loss! This nailed the game for them. Its somehow beautiful.

Folk Music of India

Discovered Satrangi--a new TV travel/music show focussing on the regional folk music of India. Learned a lot about the various forms across the country. Especially love that they speak to the youngsters. Folk music is alive and growing! Wow! Zeeq are doing a great job by producing this!

Indo-Aryan Languages

On another linguistic hunt, I discovered that Rajasthani, Bihari and Pahari are not closer to Central languages but to the Western, Eastern and Northern branches. This is quite different than the culturally how I would classed these groups. Very interesting!

Super movies of Khandesh

While exploring the liguistic map of India, I discovered a few interesting branches of Indo-Aryan languages. The Central branch that has Hindi also has Dakhini -- which is the language of the Deccan which developed independently to Urdu in the southern sultanates. Many will recognize it is as Hyderbadi. Well anyway, there is a huge treasure trove on movies from Khandesh in Khandeshi.

Loads of these are available on youtube -- they're comedies and parodies and are super-low budget entertainers. A documentary on the making one such movie Malegaon ka Superman -- is aptly named Supermen of Malegaon which follows the  lives of those involved in this genre. Improvisation and jugaad is the name of thee game here. The most touching line comes from the writer who says that noone fathoms the pain of the writer. The writer imagines and conceives the movie investing so much of his being.  But only 20% of what he conceives makes it to the film and he has to suffer eternally the pain of not being able to share the rest.

There are actors with dwarfism as well as other genetic conditions also find parts here and have actually played some key roles.

This is a funny genre to enjoy and a great one to watch for improvised film-making! Enjoy!

Saturday, July 9, 2016

Jaya He -- One of the most interesting Museums and tickets are free(... or super-expensive depending on your accounting method!)

Been meaning to write about this one for a while now! The Chhatrapati Shivaji International Airport (CSIA) hosts one of the best hidden gems of Mumbai -- and its free to visit while you wait to transit or board your flight.

It has an excellent museum and art gallery -- where is it -- it is the airport -- its all over -- arrivals departures, baggage claim security --- its curated in the most clever manner possible. And you can even explore it from home with one of the most interactive websites.

Next time you're at Mumbai airport, make sure you keep some time to check this one out. They also have a museum store -- which sells some nice related art work. There is actually a nice commercial store called Out of India -- for souvenirs, BTW (not related to Jaya He).

Back to Jaya He -- I love the "Thresholds of India" theme -- these majestic facades of India -- screaming welcome as you arrive. I learned a lot from these.

Then there are the urban art works -- reacting to the cities of post-lib, post-sat-tv, trans-IPL India -- where every one has a mall, a slum and a metro. Some interesting artists here.

It's a great example of how to make airports interesting -- its a wet dream for buffs like me but also makes the space pretty for the art-allergic! I hope Dubai, London and JFK are watching...

Karnala Bird Sanctuary and Fort

We made a nice little visit to Karnala Fort on a Saturday last week. It's so close to Navi Mumbai and yet so many centuries away in time.

We had passed the sanctuary many times while visiting Pali Ganpati near Pen and this visit was many years overdue.

Getting here is actually quite easy -- less than an hour by road -- this is on the Panvel -- Alibaug highway -- so there are tonnes of buses from Panvel ST Depot. There are also the 12 seater massive auto-rickshaws and if you haven't been in one of those, its worth a trip in those.  Will be interesting to know what type of engines these babies use.

This was the week of onslaught of the monsoon, so it was amazing warm monsoon rain and as we got closer there was also mist and fog. It was green and wet all over.

My research had dismissed the climb as an "easy" one: I can attest that in the monsoon rain and fog it is definitely close to the top rating on difficulty. The paths are streams of either bogs or mossy rocks -- each having their own fun hazards. Also, a lot of the risky climbing at the top which has support railing during the dry weather, will be there to greet you only from a fallen wayside so there are a few hazards. But this shouldn't daunt you since you're likely to be surrounded by singing dancing dare-devil fellow trekkers in this season.

Karnala fort overlooks a key pass in this part of the Ghats which connects the hinterlands to the sea -- key trade-routes to Salsette and the seas beyond to inner Pune and further.

It was built by the Yadavs and the Tughlaqs in the 13th and 14th century. It has changed hands between the Gujarat Sultanate, the Nizam Shahi, the Portuguese, Marathas and Brits. I'm sure the Siddis from Murud must have had their eyes on this at some point.

The shape of the hill-top is fascinating It replicates your mood giving you a thumbs up when you finish a couple of tough climbs, but also taking the opportunity of showing a "up yours" when you're struggling.

There are pretty white crabs in the stream-paths -- very interesting. I will trust the other blogs that there are beautiful birds -- they were not the party birds of Bombay -- the blaring stereos of some of the trekkers didn't seem to attract them over. Sumeet music's Shantabai still has some place in Maharashtra to gain more fans -- India is such a growth market!

The initial climb is a tough one, the middle is a ridge -- a reward with great views. Then you hit the devi mandir. Talk about location-location-location -- make sure you take every blessing points you can manage -- you will be using each last one on the last ninety-nine yards to the top -- where it goes from 30% to 70% climb. 

The Gate to the outer walls is a true relief (poorly practiced pun intended). There are some dates and timelines on this one -- guess Brick Lane is not the only graffiti hub.

The water cisterns are amazing. At this point, I pointed to some villages from the top and my companion asks me to control my stomach bug meds. He clearly thought I had a case of the Doollally tap (been meaning to use this one for a while! hah!). Deluding. But no, I pointed out that if you look closely into the mist, there is actually an earth on which this fort rests.

From the top you can really appreciate the control this fort would have given the incumbent in seasons like this. 

The trip to top was awesome. This time the trip to the bottom was also going to be fun! I applied some religious side-jumps to get going. Then I get this deja vu that this feels awefully similar to what I do in some kind of descent sport -- oh yes skiing -- so started to jump to slice the slope in back and forth angle slices -- this nearly doubled the speed of the descent. The surface friction with the water and muck made it very similar. This was true fun!

This is a truly enjoyable short trek, the rewards, especially on a rainy day are like a short on Lehman. There is some suffering around you with those who didn't expect the drops but you can enjoy it if you adapt to it. Ok that was a bad analogy!

I hope more Mumbaikars explore this part of our barrio. Es muy bonita!

Dongri to Dubai via Dubai

I picked up a copy of Dongri To Dubai : Six Decades of The Mumbai Mafia at the airport on my way to London. It is a really fascinating read. I was born in the area that serves as a backdrop to the book. That had to make it an exciting starter for me. I returned there recently roaming the streets and then I saw this book on sale at an airport bookshop and snapped it. It has been worth the read.

We grew up with the events around the Bombay riots and blasts, and d-company have had their fair share of mind-space in the mind of the Bombayite.

This book builds the pedigree of crime that starts with petty theft and culminates in the pinnacle of international terror. There is the deification of d but that makes the read fun.

The attention to the pantheon of the major and minor demigods of Dongri makes it all the more savory.

Along with a movie and TV series I think there is something of a walking tour in here somewhere complete with very own made to order mugging. In seriousness, the book is great fun and makes you enjoy Mumbai that much more.

Can't give it a fiver cause the writing is a little half ready in some chapters - a rushed release?

An ode to a cast of characters that gave Mumbai the character - this book had to be written and begs to be read. (Cross-posted on Goodreads)