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.
This comment is hidden because it contains spoiler information about the solution
how does this one peform the multiply by 9 on odds?
C# Translation
I wouldn't blame you for doing that.
Do specify which languages it applies to; Haskell asks for
Int -> Int -> Int
, so can't go wrong, and there's probably more strongly statically typed languages where that's the case. But for eg JavaScript, it would be a good idea. Well, defensible.Math, programming, floating points - pick any two.
I guess I should open an issue in Multiply then. I've got
Expected: 15, instead got: 14.999999999999993
withMath.exp(Math.log(a) + Math.log(b))
there.Apparently, I didn't do enough reading! Thank you so much for your input, btw. It's far easier to just downvote, and I appreciate you taking the time to give me feedback.
Your random tests are vulnerable to input modification.
Also, don't just have random tests. Have some fixed tests as well. With some edge cases.
Did you read available documentation on publishing your first kata? You're making a lot of typical inexperienced-first-timer mistakes.
That's rounding. DO NOT ROUND. ( This has been endlessly discussed, but possibly not in places you'd ever come as a new kata author. )
Also, do not use strings to encode floating point values. Use native floating point values; that's what they're for. ( Get your datatypes straight! )
An error margin of
1e-12
would be perfectly acceptable ( errors should be on the order of1e-18
anyway ), but something around1e-9
is standard. ( Just useassert.approximately
. )If you insist on rounding to two decimals and encoding as string, the obvious error margin is
1e-2
- the last digit can be one off. Also, you'll have to write your own testing wrapper that'll compare strings.If floating point values are allowed, probably up to two decimals, I think I'll need a error margin. What I'm not too sure of is what the error margin should be.
You never know what people will do that's mathematically correct.
Assuming they will not divide by
3
, then multiply by3
is just that: assuming.Or better without a margin because everything apart from the result is an integer.
Ok! I will give it a try. Thanks for the suggestion!
Please don't round. Please just ask for a floating point value and test by comparing with an error margin.
"Call a built-in" is a worthless kata idea.
Very cool! How does this work?
Loading more items...