Today I was reading through an article on Dev.to by Ben Greenberg about an interview coding challenge, and I got hooked and had to try it for mysel...
For further actions, you may consider blocking this person and/or reporting abuse
This is great! I can't even begin to describe my love for Ruby. It is such a clean language.
Not fully optimized script to do the same in python
Nice! Thanks for sharing. :) Have you seen the built-in Counter class? This seems like a perfect use-case for it.
Bonus! On my machine, this version is even 5 times faster than the best Ruby version!
This is great. Will use counter effectively. Thanks for showing me counter(). :-)
I wondered if I could do better performance-wise, based on knowledge of the problem that the more general built-in classes couldn't take advantage of. Ended up with this:
Testing both implementations a few times suggests this way is faster, but only 1% or so.
Might try this in go, just for the practice...
Nice! I haven't used
fromkeys
before. That's a nice alternative to defaultdict (and you don't have to import anything!) if you already know the keys you need.Python is on my list of things to learn soon and can't help but remark how much it "looks" like Ruby without knowing much about it yet.
"...without knowing much about it yet." This is great about python. Nice challenge this one. :-)
Nice post. It's an interesting look at how algorithmic complexity can be trumped by real-world details.
But I think you'll find that the performance is not exactly in the
each_char
(which is probably lazily evalutated) but is caused by:each_char
O(1)
)Thanks, that’s super interesting! Good to consider for future block usage. I can’t think of a way to speed up the block setup and tear down, but I wonder if I’d pick any performance up by switching the hash keys to symbols. I’ll have to do some ‘sperimenting 👍🏻
Obvious (!!!) question to ask: What if the text does not fit into memory?
Distributed version in Scala with Spark:
Thanks for the amazing community. The way you welcome your new users are amazing. Hey Wait did you check this Solarmovies alternatives Thanks
Interesting challenge. I want to see how it can be gracefully implemented in Go, even it will be more code than Ruby, but it can be elegant. github.com/plutov/practice-go/tree...
I am deeply attracted by your post. It is really a nice and informative one. I will recommend it to my friends. Also, you can read this: Putlocker
Here is solution for same problem in Go - github.com/plutov/practice-go/blob...
Thanks for sharing this article. Also see the thetechbytes.net.
Thank you for telling us but can you tell me how to add images in footer of this site: youtech.ooo/
want to Improve your grammer and fix other mistakes while writing here we have grammarly free trial to get premium features for free.