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.
is building a vector mathematically with mod and remainder faster that converting to a string and collecting?
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
really cool! any chance you could write an explanation?
not for very large numbers
This comment is hidden because it contains spoiler information about the solution
This is so nice!
I am not sure what I am supposed to be doing with null bytes
does Null => "<
z>" or just "z"?They are basically the same. As per the documentation:
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
I assume you mean that
i % 2
returns-1
for negative odd numbers whereasi & 1
is positive. But I fail to see where behavior is different for even numbers. See https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=1ba4abb31460c86f5c426d188672c5bbIt may also be worth adding that this is a good test for unsigned integers, but will not work in general for signed integers when using rust. Since
len()
always returns a positive number (usize
) this is a safe test in the above code.If you're trying to test odd/even for something that could be positive or negative, the
n % 2 == 0
test is a better choice.It does a bitwise AND. As all odd numbers will have the final bit set and all even numbers not, this is a good test.
Loading more items...