Since 2016 my main coding language had been Java; that paradigm was shattered with Python in this class. MIT loves Python, and for good reason. The flexibility of Python offered a great 6.009, replete with puzzles and coding challenges.


6.009 was centered around programming principles. One stood out: Plan a task before starting it, and divide it up into separate functions instead of writing one large block of code. Other important lessons included understanding how objects and variables were referenced or stored in memory, and how to debug, e.g. inserting print statements every so often or running an iteration/small component of a program.


The class consisted of a dozen labs, each a programming challenge. They ranged from data analysis, such as fast implementation of a Bacon Number, to software-oriented, like constructing a LISP interpreter and calculator entirely from scratch. Tokenization and good recursion were key principles.


My favorite lab by far was a GPS lab, in which millions of nodes around Cambridge, Massachusetts were collected in gigabyte-size files from OpenStreetMap. Our goal was to pre-process the data and apply graph-traversal algorithms and heuristics to quickly compute a route from any point on the map to any other point. The algorithm included a precise distance calculator accounting for the Earth's curvature, involving trigonometry and square roots. The expected runtime for our final set of test cases was 60 seconds, with a timeout at 75 seconds. But I found a hack. The find-shortest-node subproblem implementation used the precise distance to decide whether to consider a particular next node in the path. But this burned excessive time, as computing sines and cosines is very slow. Instead, I made a quick "latitude heuristic": if the latitudinal distance (latitude difference / 360 * higher longitude * 2pi) between two points was larger than the then-shortest distance, then the node was already suboptimal; calculating precise distance is unnecessary. As a result, my solution soared from 72 seconds to 24 seconds, one of the fastest algorithms ever submitted for the lab.