In my previous post, I said that "I feel that algorithms and mathematical-type programming is something I need to improve on". That was an understatement. I am terrible at them!
As evidenced by my struggle with the 2nd problem! (And these are the easy ones!)
Never has the term impostor syndrome felt so appropriate... :(
But who wants to read that sob story! Rather, let's take a look at what I learned!
For example: The most obvious thing to do is to forget about excluding the one number in the multiplication and make sure you first get the products of all the numbers multiplied. From there, it is then far easier to focus on excluding the one number from that point than it is to get tangled up in a misguided attempt at solution.
Now that I found a solution, it is time to consider some improvements:
On the bright side, I found a solution just as I was thinking I should step away and take a breather. Additionally, I discovered jest-extended which is a collection of useful and convenient assertions. Specifically I used .toIncludeSameMembers to ensure the outputted array matched the expectation.
That being said, I took a read through problem #3 and I feel more impostor-like than ever! I know on a surface level what a binary tree is but...
Update: I refactored my solution according to my suggestions, you can find my comments here.