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.
Almost did the same thing...but I changed the trait bounds on
array_diff
to also require thatT
implement theCopy
trait.Then I used
iter
andcopied
instead of just usinginto_iter
like I should have...because I initially misspelledinto_iter
while trying this exact thing :PYes, but array sizes are quite small in test cases, so creating additional structures can be less productive in this specific case.
This code has O(n*m) runtime as for each element we have to re-scan in b from scratch.
nvm it was just a typo.
This compiles and runs perfectly. Could you copy your code here?
i tried this and kept getting an error when
a[]
was emptyCan you submit a Rust translation or at least check the code, now that you can see it all once you solved it?
This comment is hidden because it contains spoiler information about the solution
Feel free to pass me a fix for that kata.
Thank you for the fun exercise!
Rust translation of the kata doesn't handle floating point comparisons well. Usually, with the tests that include floating numbers, it is common to specify the precision with which they should be compared. However, I cannot see what this kata has to do with floating numbers. They don't add any value in comparison to integers, only technical problems.
My code had problems in dealing with numbers that are more than 4 digits long. There are no such numbers in example tests. I used 20000 and 1, with expected output (3, 10000, 21001): 1000, 10000, 10001.
After refreshing the page, the problem with negative inputs seems to be solved. Thanks!
Range of random tests and rand generator have been modified. I tested my solution lots of time with
if n < 0 { panic!() }
and all tests worked fine. Maybe you could post your code (mark it as "spoiler") and I will try to see what happens.Nope. It still tests my function on negative numbers:
thread 'random_tests' panicked at 'n = -7458'
.CW has not implemented the "rand crate" so I wrote a small random generator... and it generated sometimes negative numbers! I fixed that (I hope:-) Could you tell me if it works now? Anyway lot of thanks for your post!
Loading more items...