FCC ‘Intermediate Algorithm Scripting’

I was able to improve a few of these. A regex made spinal case easier; in ‘drop it,’ you can do something similar with a ‘while(pop());’ destructor in c++; in ‘smallest common multiple,’ I switched the GCD function to a Euclidean algorithm from a brute-force one. I think the last one was the most improved; FCC has since added a test case that you need a little number theory to beat. Trying to brute-force it freezes your browser.

In ‘everything be true,’ I tried to switch it to use a forEach. It wouldn’t work and I couldn’t figure out why so I left it.

In almost all of my ‘for’ loops, I had ‘i’ instead of ‘var i’. I’m not sure why I did that.

I thought ‘steamroller’ was the most interesting. You might be able to optimize it by slicing the array so the function is only called on elements that are sub-arrays.

When a solution was updated I only put the new one on github. Maybe for the advanced ones I’ll push the old ones first then update them.

Here are the intermediate ones.