# Category: Writing

• ## AoC: Day 07

The Problem Given a set of ‘rules’, figure out which bags could contain a given bag, and in part 2, how many bags could be contained in the given bag. My Solution In the prior year, the difficulty level ratcheted up fairly quickly, and I was beginning to get worried this year! Not to worry, […]

• ## AoC: Day 06

The Problem We have to combine all the single-character responses from groups of people in part 1, and count only the unique responses in part 2. My Solution Thankfully, a bit of sanity. I recognized both these as sets so just used the union and intersection operators. Quite happy with my input parsing as well — split into groups based […]

• ## AoC: Day 05

The Problem We need to convert a string that encodes the seat row and column to a seat number. In part 2, we have to find the missing seat number in the input data My Solution I came to AoC after a bit of a break and just wanted to get it done in time. […]

• ## AoC: Day 04

The Problem We’re given a bunch of data in key:value pairs that we have to count (part 1) and validate (part 2). If it walks like a dict and talks like a dict… My Solution I was consciously looking for opportunities to do a bit of comprehension, so figured out how to do just that. […]

• ## AoC: Day 03

The Problem We’re still in the relatively easy phase. In this problem, we’re given a map with trees marked in, and on a straight-line path, we have to count how many trees we encounter. The only thing to account for is that the map repeats horizontally, we have to replicate it as many times as […]

• ## AoC: Day 02

The Problem This was more of a string matching exercise followed by a bit of arithmetic on the extracted data. Part 2 involves a bit of logic. My Solution The first thing that came to mind was regular expressions with named fields. Its been a while, so I had to go back to the (excellent) […]

• ## AoC: Day 01

The Problem An extremely simple problem to kick things off, and one that shows up on many beginners programming tests: find two numbers from a list that add up to a specified number. Part 2 asks for three numbers that add up to the specified number. The list is not sorted. My Solution My solution […]

I recommend Advent of Code to everyone I meet. It is a wonderful way to develop your programming skills, since you’re completely on your own (other sites babysit you quite a bit, methinks). However, while doing the implementation is a great exercise, it is much more useful (especially if learning a new language) to look at what […]

• ## Toycathon 2021 – A Few Thoughts

I had the opportunity to contribute to (the terribly named) Toycathon –  a competition to promote “AtmaNirbhar Bharat” and “challenge India’s innovative minds to conceptualize novel Toy and Games based on Bharatiya civilization, history, culture, mythology and ethos”  A few observations (of course my own!) and  learnings follow: I’m against the entire AtmaNirbhar philosophy — […]

• ## Fractals

It is surprisingly easy to generate a fractal image. A schematic of the Mandelbrot Set is as follows. Start with the equation $z_{n+1} = z_n^2 + c$, where $c$ is a complex number. Your “image” is a 2d array whose rows and columns correspond to the real and imaginary parts of $c$. Set \$z_0 = […]

• ## Searching

Input Array size, data type, search algorithm, key. The key can specified as an index or as a non-existent value Output index, if key is in the array, -1 otherwise. Running time Program Generate the array of the given data type and size. Populate with random numbers in sorted order (duh!) Implement the usual suspects: Linear […]

• ## Sorting

This is so fundamental that you’re probably wondering why I even bother to put it here. Read on… Input Array size, data type, algorithm, sort order Output Running time of different parts of the code Program Create an array of the given data type and size, and populate it with random values Implement multiple sorting […]

• ## Command-Line and Options

Your programs should be parameterized and should take inputs at the command line (not prompt the user for inputs!) The command line can be used to control the behavior of the program: Specify the sort order Specify the algorithm Provide debug/progress information Specify output formats and destination To specify inputs: From a file v. generate […]

• ## Focus on Performance

Colleges don’t talk about program performance; I find this strange since they focus so much on student performance! Develop the habit of instrumenting your code by default — figure out the correct timer to use for your platform, and measure, measure, measure. Understand the interplay between the code you write, what the compiler does to […]

• ## Debug & Test

Learn how to debug your code. This is not just about the tools (research and get familiar with the appropriate tools for your language and platform) but also about writing code that is easy to debug and your mental model for how you approach debugging.  Think about how you can test the code that you’ve […]

• ## Version Control

git is the flavor of the day; so learn how to git. Force yourself to use the command line, this will help you understand the philosophy of version control in general, and git in particular. Create a github account and start using it. Use it to showcase your improving maturity as a programmer and developer, […]

• ## Editors

Learn how to use a good editor. I’m not going to get into a religious war here, so will not make any recommendations. However, once you’re touch-typing, you should be making changes to your code in terms of your thoughts, not in terms of your editor’s commands. Choose an editor that makes sense, and choose […]

• ## Touch Typing

The one, simple thing you can do to increase your productivity more than 10-fold is to learn how to touch type.  This isn’t just about improving your performance at the keyboard. It has to do with removing distractions and obstacles when coding. It’s about becoming one with the machine, translating the thoughts in your head […]

• ## The Developers Bookshelf

Algorithms & Data Structures I’ve found multiple perspectives deepens my understanding of topics. The following books cover roughly the same ground, but have very different approaches, and I’ve gotten different insights from each of them Introduction to Algorithms, Cormen, Leiserson, Rivest and Stein. The basics, written clearly and yet with rigor, this book should be […]

• ## Programming for the Programmer

Motivation Students aspiring to program come in all varieties. Some are good, some are not so good and this categorization is strictly within the same pool. The frustrating part (for me) is that the good programmers have a long way to go to become competent developers. And the not-so-good programmers are not so good for […]