...and regression (or feelings of). Not the code kind. The bad kind.
but first...
Learning and Applying
I solved a simple search problem the other day and then compared my solution to another that I found online.
Here's how I set up my loop:
while (some_item !== target)
etc
and here's how they set up theirs:
while (left_index <= right_index)
etc
The second resulted in cleaner code with fewer if/else checks (although maybe that wasn't the fault of the while statement and instead was just poor code throughout). But what I like about the second while statement is that the condition checks for values that the code changes (the left- and right- indexes are incremented). The condition itself gives us a preview of the code in that it gives us an idea of what to look for in the code block.
More importantly I applied this to a different (related) problem and got a lot of satisfaction about identifying the application and then using it. Sweet!
Regression you say?
Well, I was given an assignment and thought I did pretty poorly on it, not passing all of the tests on 2/3 problems and not even reaching the third within the allotted time. I thought they were easy problems too! I'll chalk it up to a tired mind after a long day, but I'd like to re-visit them and knock them out soon. Hopefully I can also consider solutions that are more time-efficient too (compared to the solutions I provided in the test suite).
Feels like a step back, but I've got my head up.
Top comments (0)