Shouldn’t the end of the Declarative method be compared to needle.length instead of 3? Wouldn’t 3 only work for a needle array of only 3 elements since you are adding 1 for each match? Otherwise very interesting comparison.

After years of teaching music in Austin, Shanghai and Yangon, I’m making a career change to my other passion, software development.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store