I promise I'll stop now. But I dug even further.
Think this is my favourite solution even though it's not the fastest.
https://andycroll.com/ruby/further-options-odd_sum-with-benchmarking/
@andycroll Super fun seeing all the different ways to skin this cat, and the trade-offs between performance and readability in such a tiny microcosm.
It is unfortunate, though, that a method named `odd_sum`, doing a thing with summation, ends up calling a method called `product` 😅
@andycroll My solution would've been your first one that was just a loop. That appears to be much faster than all the Enumerable stuff:
https://gist.github.com/davetron5000/fd23514a5090f78d9ab7a358715f2fce
@andycroll The funny thing is, I don't think your solution needs .uniq at all and removing it makes it way faster than all of them.
(I changed the loop version to use a set and it was slower than yours, faster than the others)
[meanwhile in the real world, 200ms network latency to the cloud-managed DB kills the entire app 😂]
@davetron5000 @andycroll Might fiddle with Set as well.
This is purely unravelling a jumper by pulling on a thread at this point.