Very nice! I love your choice of method name 😂 And it's great that you went back to refactor once you realized there were optimizations you could make. No matter what "stakeholders" say about features driving revenue, any developer worth their salt knows that a clean codebase drives features. 👍👍🙌
Not a pretty solution, but it seems to work in Ruby
Returns
WAIT. Here's a much cleaner solution in Ruby.
Which returns
This is why you refactor!
Very nice! I love your choice of method name 😂 And it's great that you went back to refactor once you realized there were optimizations you could make. No matter what "stakeholders" say about features driving revenue, any developer worth their salt knows that a clean codebase drives features. 👍👍🙌
Thanks. I can't think of X's and O's without Gossip Girl.
Clean codebases are so much easier to work with. Not to mention, cost and performance savings.
It turns out that you could avoid the
#downcase
withstring.count("xX") == string.count("oO")
I don't know whether the performance would be significantly different, though it would avoid creating a couple of extra string instances.
There are some other interesting variations for
#count
, such as using it to count lower case letters with"abGvf".count("a-z")