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.
Fire all the pancakes and send OP to culinary school
This is a clever use of Linq, however it's poor performance due to needless heap allocations and iterates over the array multiple times.
This should not be marked best practice.
How many heap allocations does it take to screw in a lightbulb?
This comment is hidden because it contains spoiler information about the solution
AFAIK, it's because i64 implements the trait Ord, which contains those methods.
I didn't even think of that. I used if
To clarify what Mitchell wrote:
Because
reduce
returnsOption<T>
, its execution may be aborted any time with the?
operator which unwrapsResult<T, E>
andOption<T>
and gives you the inner value, or propagates the errorE
/None
to the calling function.since no constraints for the arguments are given in the statement,
add_binary(!0u64, !0u64)
would cause overflowAgree. Besides this operates on bytes, will fail on Unicode.
? operator short circuits None from inside the reduce closure if the i64 parsing fails in the map closure.
Could you please elaborate, how the code works in "reduce"? I assume that at some point the closure may end up with a None. Does "reduce" continue on "None" or aborts the reduce loop due to the "?" operator?
This will panic if the passed in string is empty.
I wouldn't recommend this as a "Best Practice" because it isn't clear when first viewing the code, that it will panic.
That is cheating!
Ok fair enough
Not really. Allowing incorrect solutions to pass is always an issue while not allowing some correct solutions pass some of the time is less of an issue. Since the "incorrect solutions" we're talking about here is almost always "generating simple sequences", they absolutely cannot be tolerated.
Loading more items...