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.
You could've added the rule of knowing the total of interior angles at your own from the number of sides of a polygon, which is
180(n - 2)where n is the number of sidesSo the input becomes, the angles vector, and the number of sides of the polygon, for triangle it's 3
Rejecting because no random test, no failure messages.
Due to changes between 1.44-1.66, the
rng.gen_range()takes now not two, but one range parameter. I've changed that so now the translation works for 1.66 as wellhow random are these puzzles you generate?
a. The function is not exported
b. The return value is a non-existent variable
LGTM
Can this be merged?
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:
recipetowards having a smaller length andavailabletowards having a larger length. Most translations don't use the same process to generate both from what I've seen.availableafter generatingrecipe. This allows you to subsequently specify that, say 50% of the time, you merge all the keys (ingredients) ofrecipeinto whatever you got fromINGREDIENTS.choose_multiplebefore 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_eqdisplays what is left and what is right, and is used by itself for many Katas.Loading more items...