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.
Brillant! I was looking for this function but I didn't know its name in Rust.
Fyi we can also usemax_by_key
without negatingword.chars().map...
Turns out only
min_by_key
with the negation works,min_by_key
returns the first element if they are equal, whilemax_by_key
returns the second element if they are equal.beautiful use of min_by_key just to avoid reversing the iterator
reopened at the top, closing here.
Fixed.
The first multiplication on the second line is the inverse of the function call on the first, the compiler shouldn't expect that, and the whole point of the multiplication is that it's not an inverse of the square root.
Caching repeated expressions is something every compiler is expected to know how to do, along with commuting additions and multiplications and inlining of small functions. Sometimes they'll even convert a cached value into a repeated expression, if they decide that register allocation is worth the extra CPU cycle. And modern CPUs won't even need that extra cycle.
By extra work, do you mean the ternary? I think it's better than spending five lines on the same.
This is a beginner kata.
This comment is hidden because it contains spoiler information about the solution
It happens in Ruby at least
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
can I be given a gist of how this works?
That's a bug/feature with the output console. It interprets the stuff output as HTML rather than as plain text.
It's not my best ;)
Cute. It wouldn't pass any code review, but it's still cute.
Very nice solution!!
Loading more items...