Book Review — Grokking Algorithms by Aditya Bhargava


The word 'grokking' refers to 'understand (something) intuitively or by empathy' and it is the intuition part that this book attempts to impart via some really awesome illustrations.


First off - this is not a book for people who have completed Computer Science or have learnt algorithms. However it IS a wonderful book for beginners or as is mentioned on the cover 'for curious people'.

The chapter on dynamic programming alone makes this book highly worth reading.

Pros -

  • Very easy to understand and grasp the underlying intuition
  • Everyday relatable examples of the algorithm usage
  • The high quality illustrations
  • Written in a fun and engaging manner so easy to dive in and keep reading
  • Chapters are independent, so can pick without needing to read in sequence


Cons -

  • Minimal algorithms covered and in less depth
  • Not a substitute for the more formal books in this area
  • Will not help you master algorithms. This book is to start the journey into algorithms


Book Review — Things to make and do in the fourth dimension

 Math is stranger than fiction and this book is filled with the many curiosities of the math world. It contains a glimpse into its intriguing lanes in an entertaining manner along with optional hands-on activities to enjoy.

Each chapter is not so much in depth that it is akin to a text book but just enough to get you started to play with the math, if the topic interests you. Dive in — you’ll be amazed at the sights (with a little math humor thrown in).

I won’t claim to have understood it all.

For e.g. The multidimensional world which was just too bizarre.

(A helpful tip by Geoffrey Hinton — “To deal with hyper-planes in a 14-dimensional space, visualize a 3-D space and say “fourteen” to yourself very loudly. Everyone does it.”)

But there is something in it for everybody.

Some delightful snippets -

  • Different-sized infinities
  • The strange cut outs from Mobius loops
  • Prime numbers ( considered pointless math till 1940 !! Now basis of digital communication )
  • A sphere that increases in size even when bounded by other packing spheres (26th dimension onwards) !! Weird is an understatement !
  • Ramanujan summation where sum of all the positive whole numbers = -1/12 ! Used in string theory ( I am still trying to wrap my head around this )
  • Knot theory — Trying to find one method to know if a tangled string is a knot and if so how to undo it with minimal effort. Why bother ? Biologists may be able to devise new wave of medical treatments based on this
  • Uncomputable numbers !!! ( No amount of exclamations will do this justice ! )
  • Description of Gödel’s incompleteness theorem. Short, succinct and intuitive
  • Riemann Hypothesis, e, π, Φ, infinite hotel do get a mention ( almost de rigueur I think )

An engaging book about math; The language the universe speaks to us in. Fall into the fascination and there’s no going back.


Step-by-Step guide to restore old photos

 A few months back, Microsoft shared code for old photo restoration. The implementation was in pytorch.

I tried to use the code to restore some old damaged snaps. I found that not all old photos can be enhanced. Reasonably well defined blemishes and lines are handled well but diffused areas of damage don’t fare that as good.

Nevertheless it is a very impressive photo restoration using AI.

This is a step-by-step guide to using the code to restore your old photos using Google colab.

You need —

a. Gmail ID to run the colab notebook

b. Old photo (≤500 x 500 pixels only)

1. Copy the colab notebook

Save the colab notebook at this link to your own gdrive so that you can use this notebook in your google colab environment.

Save copy of the colab notebook to your gdrive
Image for post

2. Change the run time environment

Change the runtime type to Python3 and the hardware accelerator to GPU as mentioned at the top of the notebook.

Image for post
Image for post

3. Run the notebook cells

Run all the cells till the section ‘Try it on your own photos’. So all steps under ‘Git Clone’, ‘Set up the environment’, ‘Run the code’ need to be completed.

Image for post

4. Upload the files to be restored

When you run the cell after the heading ‘Try it on your own photos!’ you will see a button to ‘Choose files’. You can choose multiple files or a single file.

Image for post

5. With scratch or Without scratch flag

After the files are uploaded in the next cell — choose the restoration type. If the photos have scratches then simple add the flag --with-scratch at the end of the code. Otherwise no change to be made.

Image for post

6. Results display

After this cell completes its run, the result is displayed side by side with the original input picture.

Image for post

7. Download the results

Run the next cell which copies the output to a zip file and downloads this zip file. This downloaded file will contain the resultant restored image(s).

Image for post

8. Issues

Scaling images

If you upload a file that is more than 500x500 pixels — the large image is skipped and not processed.

Image for post

You can scale images in GIMP or use any image editor tool to ensure it is within the limit prescribed.

Incognito Mode

If you run the colab notebook in Incognito mode you may come across this error message.

Upload widget is only available when the cell has been executed in the current browser session. Please rerun this cell to enable.

To overcome this — you can either run the notebook in regular chrome window or use whitelist cookies from google like this -

https://[*.]googleusercontent.com:443

For more details — check out this stackoverflow link.

References:

User Interface design and User Experience

Recently the story of the student who lost his seat in IIT due to inadvertently clicking the wrong link made headlines.

The story is sad and hopefully the Supreme Court will allow him to get a seat on humanitarian grounds. One of the assertions by IIT was that; withdrawal is a conscious two-step process. The student has to enter a reason for withdrawal. While I don't know the UI(User Interface) for IIT - I wonder could the experience have been made better so such an error could not have easily happened ?

If you approach the UI design thinking that ~90% of the students who get into IIT will not reject the seat, then perhaps the design could have been different.

Consider, instead of just asking for 'reason for withdrawal' - could additional UI elements have made the student realize what he was doing ?

  • Red exclamation point ❗️/ stop sign 🚫
  • Clearer message - 'You will lose your seat' !!! ( Certainly more meaningful that using the word 'freeze' as the articles suggest. )
  • Simplification of language and double check - 'Are you sure ?' 🔴
  • A waiting period before accepting the withdrawal ( this could pose issues to other candidates of course )
  • A separate mail / call confirming the withdrawal

UI design and UX (User Experience) design are vast fields with the attendant deep knowledge and experience required for best results. This is not restricted to software alone either. Add in making design decisions which will help people with special needs, health issues, color blindness, deafness etc., it is a field that cannot be under-rated. And it begins with one question -


Who is the audience and what do we want to help them accomplish ?


There is never a perfect UI design that can ensure no errors but gentle nudges (not always gentle as the dark patterns in UI show) towards a desired outcome is  part of the design and UX. 

And what can be more desired than a seat in IIT to a JEE Aspirant ?

References : 

  1. Nudge 
  2. Dark Patterns in UI
  3. Dark Patterns in ecommerce sites
  4. Interfaces designed to trick you