What steps I follow to solve a programming exercise or problem?

Most beginning programmers focus on challenges that are one layer deep, and that’s ok. An example is something like, “Find the sum of all of the numbers in this list.”

It’s a rather straightforward problem in which the outcome is well defined. The problem-solving steps to a beginner might basically be:

  1. Ok, I need some way to get the program to extract each number individually (iteration!)

  2. That extracted number needs to be added to some sum.

A slightly more intermediate programmer will go another layer or two and deal with nested data or data from multiple sources. Figuring out how to make JSON data from an API call turn into actionable results is a much more interesting challenge.

First, figure out what data you need. (I want to know how many times tweets that include #MyBrand get retweeted vs. tweets that include #CompetitorsBrand, so I need to figure out how to get a representative sample of recent tweets that contain those hashtags that will give me retweet info)

Then, figure out how to get that data. (I figure Twitter must have an API, so I learn the right requests.get() parameters and see what I’m dealing with. Maybe the data gets returned in JSON format and looks like this [full disclosure: I have no idea what Twitter API data actually contains]_:{Hashtag:{…#MyBrand:{Date: 1/2/34:{User: x, Tweet:y, Retweets:z}}}

Next, figure out how to make the data you can get == the data you need. (Ok, based on the above JSON data, I need to get the third dictionary value nested under the date following the hashtag. I can use this in lots of different ways, but maybe I just want to add this number to a list for now. I’ll download the results into a file and use a file called to try to extract what I need for dates in the range of 1/2/34 to 1/5/34. If I can get it into a list, I can then probably work with it…)

Next, figure out what this data is relevant to (ie, what info you’re trying to abstract from this data). (Ok, I have a list of all the retweet numbers for every day in that date range. What do I need to do with this to make it actionable? Well, I guess I need a total so I can compare the results from #MyBrand to #CompetitorsBrand in the same range. How do I sum all the numbers in a list? Wait! This sounds like that question I did as a beginner!)

The rest tends to look a bit more like the simple programming question above.