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.
They are basically the same. As per the documentation:
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.
These methods are lazy.
@newmaidumosa sorry for long reply. that's good question, but i've never used it before. you can define them directly
Fixed
here. comments visible, and links to the solution page. The code itself isn't visible, but all comments that aren't flagged are readable
and I wish you could think about the spoiler flag... ;p
If you guess a few things you can figure out how to transform them directly :
-if there is no number part then ...
-if there is just one latter then ...
IIUC it's basically 'does not cheat by importing the reference solution'.
If you are failing that test and you think your code is legitimate, put your code here in a 'spoiler' comment and raise as an issue.
This comment is hidden because it contains spoiler information about the solution
Initial value for
foldr
. You have to fill in something, and it must be able to be any type for the whole thing to typecheck. It is then thrown away becauseconst
discards its second argument unevaluated. :]thanks)))
I’m happy to help
Loading more items...