How To Read More

Yesterday, I bought Rs. 1000 worth of books, and also spent Rs. 1000 on a family movie night. Somehow, my psychology is weird enough that the money spent on books seemed like an extravagance to me, whereas the dinner was no big deal – something I do regularly. But, when I think about it, I’ll spend weeks reading the books, then my wife will read them, and later I’ll lend those books to other people. In terms of value/entertainment-per-person-per-hour, books are easily 10 to 100x cheaper than any other thing I spend money on.

In other words, I should be spending much more on books.

Buying, Borrowing, and Lending Books

  • Maybe buying: So, I’ve started buying books. And, I often buy even those books where there is only a small chance of me reading it. Because if I buy 10 books, and end up reading only 1 of them, that’s still a good investment. My mother comes from the generation where buying a book is a big decision – she reads reviews in newspapers, asks her friends if any of them have read the book, goes to the store and spends 10 minutes browsing the book, and only then considers buying it. I am slowly converting her to the philosophy that if she even thought “maybe I should check out this book” I will go ahead and buy it on Flipkart/Amazon.
  • Indiscriminate Lending: One of the biggest problems with lending books, is the fear that they’ll not get returned. Trying to keep track of who borrowed which book, and asking for it back is too much work. I stopped worrying about this long ago. I lend books indiscriminately, and don’t worry about whether it will come back. There have been 2 or 3 cases where I ended up buying a second copy of a book because I needed the book, and couldn’t figure out whom I’d lent it to. This is a small price to pay for being able to spread good books.
    • The one thing I do to increase chances of getting books back, is that on the book, I write “KABRA” in really large block letters using a thick marker pen. This ensures that the borrower never forgets whom they borrowed a book from, and eventually they return it.
  • Buying Second Hand Books: There’s a raddi-paper shop on Baner Road that keeps a stack of second hand books, and sells them at really low prices – Rs. 10 or 20 or 30 depending on the size of the book. I go there once every few months, and end up buying 5 to 10 books on each visit. Being able to buy books so cheaply really helps with making it easier to do the maybe buying and the indiscriminate lending described above.

How my reading increased in the last few years

I used to read a lot in my childhood. And this significantly reduced after I started working. Only in the last few years, I’ve managed to again pick up a habit of reading regularly. I think this is because of 3 major things I did: setting up the Kindle app on my smartphone, subscribing to an online library which delivers physical books to my door with just a click of the mouse, and setting up reading queues as described below.

  • Reading Queues: One of the problems I used to have earlier is that when I heard about a book, I was usually too busy to even think about reading, and later when I was less busy, I wouldn’t have appropriate books handy. This might be a problem specific to my and how I function, but I’ve managed to get around it by having reading queues.
    • Reading Queue #1: The online library that I use, BigBooks, allows me to create a queue of books that I want to someday borrow from the library. Whenever I hear about some book that I want to read (usually through social media, or my friends), I check if BigBooks has a copy of that book, and add it to my queue. So, when I am done with the current book, I simply go to the BigBooks website, and ask them to deliver the next book. They randomly pick one book from my queue and send it across.
      Note the important thing here: A book get added to the queue when I hear about it; and I get it in my hand when I have time to read it. This separation has significantly increased my reading.
    • Reading Queue #2: For books that are not available with the library, I usually buy a kindle version and have it delivered to my phone. This book now sits on my phone, ready for me whenever I have some free time – this can be while commuting, while waiting for a meeting to start, while standing in some line somewhere. I read in small chunks of time. It’s amazing how much reading you can get done this way. I finished all of Crime and Punishment by just reading it during the interstitial gaps in my days.
    • Reading Queue #3: Whenever I find an article online that seems interesting, but is too long for me to read right away, I use Amazon’s “Send to Kindle” feature to send that article to my Kindle App on my smartphone. This article now sits on my Kindle app until I read it – either in the next few days, or even weeks later, depending upon how busy I am. In this age of 140-character updates, being able to read long, well thought out articles is a superpower.

Books and Children

  • Reading is one of the most important habits you can inculcate in a child.
  • Many parents have strong feelings that children should read good books, or useful books, for some definition of good/useful. I don’t agree with this thinking. It doesn’t matter what the child reads. Anything is fine. Even if the parents think it is trash. Juvenile stuff like Captain Underpants, shallow romances like Twilight Series or Mills and Boon, is all fine. Any kind of reading helps the child in the long run.
  • It’s not easy to get a child to take up reading. With TV and computer games competing for their attention, books suffer, and parents exhortations don’t really work. In the last few years, I’ve seen that the more I and meetu read in their presence, the more the kids have started reading. And of course, limiting the amount of “screen” based activities they’re allowed in a day.
  • Buy and keep appropriate books around the house. You never know when a child will get interested in which book. I’ve had cases of my kids suddenly pick up and read a book years after I bought it and asked them to read it.

Which Programming Language to use to solve the Singapore Math problem

Being a programmer means that every once in a while, instead of doing real work, you spend time writing a completely pointless program just for fun. Which is how I ended up writing a Prolog program to solve the Singapore Math Problem that has recently gone viral on the internet.

This is Amit Paranjape‘s fault. He asked me, “Isn’t solving this problem simply a question of creating sets of dates that satisfy the various conditions, and then intersecting them until you’re left with just one date? Wouldn’t it be easy to write a program to solve this program automatically?” And he went on to ask, “Isn’t there already some high level programming language where such set constraints can be described at a high level, and the program solves the problem for you?”

Turns out, there is. The Prolog programming language is a general purpose programming language that allows us to specify high level predicates that must be true of your data, and then it automatically figures out which pieces of data satisfy all your constraints. It’s a rather different kind of programming language.

So, I couldn’t resist. Like many other computer science graduates, I learnt a little about Prolog during my undergraduate studies, and then proceeded to never encounter it anywhere in my real life. But here was a problem that seemed like it would be fun to solve using Prolog. The fact that I actually don’t know Prolog isn’t something that I let bother me.

So, I spent a few hours downloading a Prolog compiler, learning the basics of the language, and solving the problem.

And, indeed, Prolog is a good language to solve the problem. The solution is below. If you don’t know anything about Prolog, you might still be able to make some sense of the program by doing the following: Any statement of the form “abc(x,y).” should be read as: the property abc is true for x and y. And any statement of the form “pqr(X) :- abc(X,Y), jkl(Y,Z).” should be read as: the property pqr is true for any X if abc is true for that X and some Y, and jkl is true for that Y and some Z. And the statements involving setof are simply trying to count the number of elements satisfying some property.

Here’s the solution:

% This is the original data that Cheryl gave
birthday_candidate(may, 15).
birthday_candidate(may, 16).
birthday_candidate(may, 19).
birthday_candidate(june, 17).
birthday_candidate(june, 18).
birthday_candidate(july, 14).
birthday_candidate(july, 16).
birthday_candidate(august, 14).
birthday_candidate(august, 15).
birthday_candidate(august, 17).

% Now for some helper functions
% Any list that has more than one 
% entry is ambiguous
is_ambiguous(List) :- 
    length(List, Len), Len>1.
% Any list that has exactly one 
% entry is not ambiguous
is_not_ambiguous(List) :- 
    length(List, 1).

% These will be true only for a 
% Month or Date in the original list
candidate_month(Mon) :- 
    birthday_candidate(Mon, _). 
candidate_date(Date) :- 
    birthday_candidate(_, Date).

% If you're given a month, and there 
% are multiple candidate dates 
% in that month, then you don't 
% have enough information to
% deduce the birthday.
% Same thing for dates.
month_is_ambiguous(Mon) :- 
    candidate_month(Mon), 
    setof(D,birthday_candidate(Mon,D),L), 
    is_ambiguous(L).
date_is_ambiguous(Date) :- 
    candidate_date(Date),
    setof(M,birthday_candidate(M, Date), L),
    is_ambiguous(L).


% Albert's first deduction
% The month that Albert has 
% been told is ambiguous, because he 
% couldn't figure out the birthday
albert_month_is_ambiguous(Mon) :- 
    candidate_month(Mon), 
    month_is_ambiguous(Mon).

% In addition, Albert knows that 
% Barnard doesn't know.
% Meaning that each date that he can 
% deduce is ambiguous for Bernard
albert_knows_bernard_doesnt_know(Mon) :- 
    albert_month_is_ambiguous(Mon), 
    forall(birthday_candidate(Mon,D),
    date_is_ambiguous(D)).

% Bernard's first deduction

% The date Bernard has been told is ambiguous,
% did could not figure out the birthday.
bernard_date_is_ambiguous(Date) :- 
    candidate_date(Date),
    date_is_ambiguous(Date).

% After hearing what Albert said, 
% Bernard's database is constrained by 
% the results of albert_knows_bernard_doesnt_know
bernard_constrained(Mon,Date) :- 
    bernard_date_is_ambiguous(Date),
    albert_knows_bernard_doesnt_know(Mon),
    birthday_candidate(Mon,Date).

% But then, Bernard said that he 
% now knows the birthday; which means 
% that Month isn't ambiguous for him
bernard_now_knows(Date) :- 
    setof(M, bernard_constrained(M, Date), Mx),
    is_not_ambiguous(Mx).

% Albert's second deduction

% After hearing that Bernard now knows 
% the birthday, Albert's database is 
% constrained by the results of bernard_now_knows
albert_constrained(Mon,Date) :- 
    bernard_now_knows(Date),
    albert_knows_bernard_doesnt_know(Mon),
    birthday_candidate(Mon,Date).

% And Albert said that he now knows. 
% Which means Month isn't ambiguous 
% for him
albert_now_knows(Mon) :- 
    setof(D, albert_constrained(Mon, D), Dx),
    is_not_ambiguous(Dx).


% Final answer: take results of 
% albert_constrained and further constrain it 
% by the fact that albert_now_knows
% and we get a single final answer.
final_answer(Mon,Date) :- 
    albert_constrained(Mon, Date),
    albert_now_knows(Mon).

Notes

  • The answer is 16 July, in case you were wondering.
  • Considering that this is probably the second Prolog program that I’ve ever written, I’m sure it is a terrible program. In fact there are lots of ways in which the program can be improved, but, I have real work to do. So this quick-n-dirty program will have to do.
  • In fact, there exist theorem provers (like Coq) that are even more ideal for this job. But those are far too specialized, and I did not want to learn a theorem prover just to solve this problem.
  • Which brings me to the question, why did I even bother doing this in Prolog? Considering that Prolog has not been, and will probably never be used in any serious programming work that I do, why bother? The more generalized version of this question is this: if there is a non-standard programming language (like Haskell, Lisp, Erlang, O’Caml) whose use in industry is uncommon, should you, as a serious programmer, with real work to be done and real deadlines, learn them in your free time? The motivated reader is encouraged to leave a comment below with the answer. Or, if you don’t know the answer and want my answer, please send me an email.

And, here’s a link to the original problem if you feel like solving it yourself. And here is another problem and yetanudder problem that require similar type of thinking to solve.

As evaluation capabilities of employers improves, importance of conventional degrees will decline -DB Phatak, IIT Bombay

Recently, I heard Prof D.B. Phatak of IIT Bombay speak at ACM India’s Workshop on Computing Curricula. He talked about various ways in which MOOCs and technology will (should?) transform higher education in India.

Here are a few points I found interesting:

  • Current universities in India have a rigid course structure. This leads to problems like: Smarter students cannot learn fast. Slower students cannot learn slower, unless they fail the course, in which case, they get exactly double the amount of time. If you already know the material of a course, you cannot prove this and skip the course.

  • This is arrogance from the Universities. In any other industry, this kind of behavior would not be accepted by the customers. Why do students still flock to universities?

  • Employers currently recognize only conventional degrees from ‘reputed’ universities, and hence, to get jobs, students submit to the unjustified arrogance of universities.

  • This will change. A degree from a university is just a first filter. Employers really care only about your capabilities, and as they get better at evaluating the capabilities of students reliably and scalably, especially through the use of technology, the reliance on conventional degrees from conventional universities will reduce.

I take this to mean that more and more employers will start using automated evaluation technology like Reliscore (which DBP mentioned in his talk!) to evaluate the capabilities of students instead of relying on conventional degrees, and we will see the rise of self-taught students who learn from MOOCs.