Footage

So after a fifteen year gap, I was in the Times of India yesterday, writing about the joys of working from home (I’d shared the clipping yesterday, sharing it again). The interesting thing is that this piece got me the kind of attention that I very rarely got with my six  years with the HT Media family (Mint and Hindustan Times).

The main reason, I guess, that this got far more footage, was that it came in a newspaper with a really high circulation. ToI is by far the number one English newspaper in India. While HT may be number two, we don’t even know how much of a number two it is, since it seemingly didn’t participate in the last Indian Readership Survey.

Moreover, ToI is read widely by people in my network. While the same might be true of Mint (at least until its distribution in Bangalore went kaput), it was surely not the case with HT. I didn’t know anyone who read the paper, and since my articles mostly never appeared online, they seemed to go into a black hole.

Another reason why my article got noticed so widely was the positioning in the paper – it was part of ToI’s massively extended “page one” (it came on the back of the front page, which was full of advertisements). So anyone who picked up the paper would have seen this in the first “real page of news” (though this page was filled with analysis of working from home).

On top of all this, I think my mugshot accompanying the article made a lot of difference. While the title of the article itself might have been missed by a few, my photo popping out of there (it helps I have the same photo on my Twitter, Facebook, LinkedIn and WhatsApp – thanks Anuroop) ensured that anyone who paid remote attention to my face would end up reading the article, and that helped me get further reach among my existing network.

ToI is going to pay me a nominal amount for this article, far less than what Mint or HT used to pay me per piece (then again, this one is completely non-technical), but I don’t seem to mind it at all. That it’s given me much more reach among my network means that I’m satisfied with ToI’s nominal payment.

Thinking about it, if we think of newspapers as three-sided markets connecting writers, readers and advertisers, it is possible that others who write for ToI do so for below market prices as well, for it has an incredibly large reach among “people like us”. And that sets the size-related network effects (“flywheel” as silicon valley types like to call it) in action among the writer side as well -you don’t write for money along, and if it can be sort of guaranteed that a larger number of people will read what you write, you will be willing to take lower payment.

In any case, this ToI thingy was a one-off (the last time I’d written for them was way back in 2005, when I was a student – it’s incredible I’ve given this post the same title as that one. I guess I haven’t grown up). But I may not mind doing more of such stuff for them. The more obscure the paper, though, the higher I’ll be inclined to charge! Oh, and henceforth, I’ll insist my mugshot goes with everything I write, even if that lowers my monetary fees.

 

Coin change problem with change – Dijkstra’s Algorithm

The coin change problem is a well studied problem in Computer Science, and is a popular example given for teaching students Dynamic Programming. The problem is simple – given an amount and a set of coins, what is the minimum number of coins that can be used to pay that amount?

So, for example, if we have coins for 1,2,5,10,20,50,100 (like we do now in India), the easiest way to pay Rs. 11 is by using two coins – 10 and 1. If you have to pay Rs. 16, you can break it up as 10+5+1 and pay it using three coins.

The problem with the traditional formulation of the coin change problem is that it doesn’t involve “change” – the payer is not allowed to take back coins from the payee. So, for example, if you’ve to pay Rs. 99, you need to use 6 coins (50+20+20+5+2+2). On the other hand, if change is allowed, Rs. 99 can be paid using just 2 coins – pay Rs. 100 and get back Re. 1.

So how do you determine the way to pay using fewest coins when change is allowed? In other words, what happens to the coin change problems when negative coins can be used? (Paying 100 and getting back 1 is the same as paying 100 and (-1) ) .

Unfortunately, dynamic programming doesn’t work in this case, since we cannot process in a linear order. For example, the optimal way to pay 9 rupees when negatives are allowed is to break it up as (+10,-1), and calculating from 0 onwards (as we do in the DP) is not efficient.

For this reason, I’ve used an implementation of Dijkstra’s algorithm to determine the minimum number of coins to be used to pay any amount when cash back is allowed. Each amount is a node in the graph, with an edge between two amounts if the difference in amounts can be paid using a single coin. So there is an edge between 1 and 11 because the difference (10) can be paid using a single coin. Since cash back is allowed, the graph need not be directed.

So all we need to do to determine the way to pay each amount most optimally is to run Dijkstra’s algorithm starting from 0. The breadth first search has complexity $latex O(M^2 n)$ where M is the maximum amount we want to pay, while n is the number of coins.

I’ve implemented this algorithm using R, and the code can be found here. I’ve also used the algorithm to compute the number of coins to be used to pay all numbers between 1 and 10000 under different scenarios, and the results of that can be found here.

You can feel free to use this algorithm or code or results in any of your work, but make sure you provide appropriate credit!

PS: I’ve used “coin” here in a generic sense, in that it can mean “note” as well.

Pizza from dominos – good and bad

Last night we decided we wanted pizza from dominos for dinner. Having been used to Swiggy, I instinctively googled for dominos and tried to place the order online.

There is one major fuckup with the dominos website – it asks you to pick the retail outlet closest to you, rather than taking your location and picking it yourself. And so it happened that we picked an outlet not closest to us.

I quickly got a call from the guy at the outlet where my order had gone, expressing his inability to deliver it, and saying he’ll cancel my order. I gave him a mouthful – it’s 2016, and why couldn’t he have simply transferred the order to the outlet that is supposed to service me?

I was considering cancelling the order and not ordering again (a self-injurious move, since we wanted Dominos pizza, not just pizza), when the guy from the outlet in whose coverage area I fell called. He explained the situation once again, saying my original order was to be cancelled, and he would have to take a new order.

Again – it wasn’t just a fuckup in the payment in the Dominos system, in which case they could’ve simply transferred my order to this new guy. So I had to repeat my entire order once again to this guy (not so much of a problem since I was only getting one pizza) and my address as well (it’s a long address which I prefer filling online).

Then there was the small matter of payment – one reason I’d ordered online was that I could pay electronically (I used PayTM). When I asked him if I could pay online for the new order he said I had to repeat the entire process of online ordering – there was no order ID against which I could simply logon and pay.

I played my trump card at this time – asked him to make sure the delivery guy had change for Rs. 2000 (I’d lined up at a bank 2 weeks back and withdrawn a month’s worth of cash, only that it was all in Rs. 2000 notes). He instantly agreed. Half an hour later, the pizza, along with change for Rs. 2000 was at my door.

The good thing about the experience was that the delivery process was smooth, and more importantly, the outlet where my order reached had taken initiative in communicating it to the outlet under whose coverage my house fell – the salespersons weren’t willing to take a chance to miss a sale that had fallen at their door.

The bad thing is that Jubilant Foodworks’ technology sucks, big time. Thanks to the heavily funded and highly unprofitable startups we usually order from, we’re used to a high level of technology from the food delivery kind of businesses. Given that Jubilant is a highly profitable company it shouldn’t be too hard for them to license the software of one of these new so-called “foodtech” companies to further enhance the experience.

No clue why they haven’t done it yet!

PS: I realise I’ve written this blogpost in the style I used to write in over a decade ago. Some habits die hard.