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.
I think sort_unstable would be a bit better
Whatever is needed, should be done, I think. Tests should include:
It is possible to generate such tests deterministically, and it would behoove a translator to implement such. I do not have the time right now, otherwise I'd fork and write one myself, but I'm sure Pearce is up to it.
Edit: Here's a sample algorithm:
For each test:
gen_bool(0.75)
to generate a positive case, otherwise a negative one. The first option lets you choose the exact number of each test, the second one relies on sufficent cases to produce the desired ratio.true but then you'd need two separate cases as opposed to one
I'd do it the other way around: generate
available
, and sample a random subset of those to form a recipe which is guaranteed to add up at least once. You can then play with the numbers for each ingredient.You can get closer to a 50/50 split without much complexity by either one (or both) of these two means:
recipe
towards having a smaller length andavailable
towards having a larger length. Most translations don't use the same process to generate both from what I've seen.available
after generatingrecipe
. This allows you to subsequently specify that, say 50% of the time, you merge all the keys (ingredients) ofrecipe
into whatever you got fromINGREDIENTS.choose_multiple
before collecting to a dictionary. I don't know if this is convenient in Rust, but it was easy to do in C#.So far the chance of not getting a 0 is 4-5%; I think you should at least incorporate the first approach since most translations do it and it helps even the odds a bit.
Done and done. Pass by value makes it easier for the consumer, but by reference is the better api decision, and at this kata level they can handle it.
Ingredient diversity and count have been reduced for random tests. It's still likely to be mostly 0s, but before there was a decent chance they'd all be 0s. A more nuanced approach would be possible, but require complexity beyond what I think is necessary.
clone()
.It does not whow which is expected and which is actual tho, and from a default message users cannot easily figure out what they returned, and what kata wants? Or can they?
Unless by "right" the message means what is, well, right.
There is many bad kata ;)
This one seems to be dead so I made one: https://www.codewars.com/kumite/65ff3b40e827ae02791d1c56?sel=65ff3b40e827ae02791d1c56
impl Into<String>
is more flexible and a superset of&str
.assert_eq
displays what is left and what is right, and is used by itself for many Katas.I don't know
Rejected because no answer to requests for more than one year. I think this is not approvable as is. It's always possible to create a new fork and make the required changes.
I feel like this is collecting two times, hence allocating on the heap twice?
Lol
Very nice! (Of course I think so as it's almost identical to mine :)
Just one note - You can avoid the reallocation of a new string when you reinsert the name by capturing the return from
new_leaderboard.remove(i)
. It returns the removed element, so you can just take that and stick it back in at the new position.no random tests
Loading more items...