This website collects cookies to deliver better user experience
Recursion Breakthrough
Recursion Breakthrough
Recursion! Ah!
I've never felt like I didn't 'get' recursion. On a high level, I feel like I have a strong intuition for where/when it's used and how it works. (Or maybe a strong enough intuition to fool myself into thinking I get it).
But I'll be honest here and say that actual recursion problems - those have tripped me up way more than I'd like. Way more.
Like so much of coding, the devil's in the details. When and what to return, what base case to establish, where and how to use inner functions. It's been hard for me to put those elements together successfully to solve problems.
Recently we were assigned the 'Rock Paper Scissors' toy problem. I spent a good chunk over two days thinking the problem out, and whiteboarding the problem solving process. What a pain. I have sheets of paper and snippets of code to attest to my futility. But it always felt like the solution was right there and so I didn't give up.
Well, I found the solution. And better yet, I feel like I've found a way to solve these problems. It feels awesome.
I certainly didn't come up with anything groundbreaking. In fact, I'm sure if I re-watched our instruction from pre-course, there'll be a lot of what I did in there. But I know I learn from experience, and feeling the problem solving process emerge from my struggle makes me feel a lot more connected to it.
Tomorrow I'll post the code and walk through it in small chunks to demonstrate how I worked inside out and came to an answer.
On a side note, I was wondering about this learning process when I was in the midst of fighting with this problem. And I wonder about it now too, after having solved it. Did the struggle make me better?
Namely, how worth it was it (and is it) to put so much effort into coming up with my answer? One way I conceptualize it is that my brain/body is aware of how much time I put into this. So does it dedicate more computing resources (processing power, recall/storage, pattern recognition/algorithm efficiency) to 'learning' it, commensurate with the effort expended? Would that time have been better spent (when perhaps naively thinking about learning-ROI) from looking up the answer, or the solution to similar problems and then moving on to the next problem? In other words, same time invested, but spread across more problems? It's almost like running a marathon vs HIIT training. Both will get you in better shape. How is the learning experience (and result) different?
As I wrote above, I feel really connected to the solution -- at least I do for now -- and am optimistic that I have a new clarity when it comes to approaching and thinking about these problems. If that proves to be true, it was time well spent.