I’m smart and I didn’t just tell you that because I’m an asshole. Although we live in a world where intelligence is prized it is not always an advantage. Growing up smart meant being able to put in minimal effort and achieve competitive results, until it didn’t. Everyone who has ever slid by on quick thinking as opposed to hard work has at some point in their life faced an obstacle where the thinking just wasn’t enough.
Who doesn’t want to be Matt Damon in Goodwill Hunting? I certainly do, and because of this I try to solve complex problems in my head with minimal planning in an attempt to feed my untamable ego.
My first week at Turing, “a coding school,” I realized that I had to change. They gave use a problem called merge sort in which we were supposed to use recursion to break a sequence of numbers down and then order them from least to greatest.
Being my usual cocky self I decided that I didn’t need to “whiteboard” like my instructors suggested, I dove right in and for the next 5 hours had the incredible and horrible feeling that the solution was right around the corner. I’d run into one problem after another and devise workaround after workaround, each one becoming more convoluted.
Pushing through my stubbornness I admitted to myself that what I was doing wasn’t working. For starters, although I had been trying to use recursion the entire time I didn’t actually grasp what it was doing. I also had been to obsessed with putting in this:
[4, 1, 2, 5]
And getting out this:
[1, 2, 4, 5]
I had failed to think about what steps would need to occur in between the start and the finish. Steps that were simple enough for an unproven programmer like myself to grasp.
After talking with some of my classmates I realized that I first needed to break the problem into two pieces, breaking down and building back up.
I created a list of steps that if completed would be able to solve the problem.
- Create a function to split a given list
- Create a stop to the recursion
- Start the recursion
- Create a method the takes to arrays and puts them in order
In a few hours a managed to get my merge sort working and I swore to myself that from then on I would changes my ways and eat the elephant one piece at a time.