Loading collection data...
Collections are a way for you to organize kata so that you can create your own training routines. Every collection you create is public and automatically sharable with other warriors. After you have added a few kata to a collection you and others can train on the kata contained within the collection.
Get started now by creating a new collection.
Python translation:
Check comment
You might want to add that kind of thing as a test.
Done in this fork + Enabled Ruby 3.0
Gotta say, I don't really understand why this works the way it works intuitively, but people complaining that this isn't "best practice" or "uh muh readability", "maintainability", or "what about junior devs":
This is a code exercise, not production code.
Yes, in production you'd want better guard rails and input validation, and yes, you would want this documented to explain what it does. And yes, you'd need to validate that the ouput is sane since multiple odd occurances throws the math out the window lol (so maybe that would make this solution invalid for production as extra compute might outweigh the space benefits).
However, as a general point you shouldn't sacrafice performance of something so simple with a very clear objective to write more convoluted looping code that will take a junior some time to parse anyway.
If you know a clever way to do something that's performant, is little code, and achieves a clear focused objectives, you shouldn't dumb it down because someone might not get it. Let them figure it out, and learn, and make sure the rest of the codebase isn't impacted by someone not understanding a bit of code in it.
This is cool!!!!!;)
This comment is hidden because it contains spoiler information about the solution
.
good, you're on the right track
Everyday I learned bizzare stuff from here
thanks guys, my bad
You probably confused
d
andb
?No, d is on right side.
You are so full of yourself. You are in no position to tell people what they should and should not be proud of.
And who told you that OP, or anyone in this thread as a matter of fact, was a beginner? Everybody knows what 2.5x faster means. You didn't need to recite the entire hare and tortoise song-and-dance like you're talking to preschoolers. People know when they're being patronized, so have some tact.
Since you're so intent on quoting things, want me to leave off with something?
If LINQ is not a bottleneck, it is not a bottleneck. You are Dunning-Kruger personified.
I hope it's not a solution you're proud of. Linq is slow as a sloth in a tarpit. Very slow. Your code, while short (and maybe cool looking to those who care about looks over performance), is over 2.5 times slower than my plain, ordinary, "normal" algorithm.
It's like if our code was in a race around a track, mine would go around more than 2 and 1/2 times before yours went around even once.
Linq is the worst thing a beginner coder could ever learn.
Read the description again. There are letters that don't have point values assigned to them.
From the description:
Loading more items...