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.
It would help if the tests have descriptive names. Something like "ShouldReturnOriginalTo2Places" would help indicated that they need to round (if they forgot it was in the spec).
Also, the example in the description should have the 2 places ("...the function should return an original price of $100.00")
Mispellings and grammer errors. Suggest:
Yes, the tests do not explicitly check for this, so will randomly fail but mostly pass.
I'm not sure how you would perfectly check for this, but this has less of a chance of it passing without ever returning a maximum:
This comment is hidden because it contains spoiler information about the solution
I agree in both cases (don't like errors, too early for
Maybe
). I guess the main question is, do we want the Kata to be opinionated, or should it leave it up to the user?Since the problem isn't defined for
k <= 0
, you can't just fill in a value. It also hides problems when using elementAt.I think the way you did it (using
undefined
) is the most mathmatically sound way, but it gives no help in fixing the error (generic "Prelude.undefined" error message).I think returning a specific error message will help with debugging. So I would vote for expecting an error to be thrown.
One problem I had with this on the 99 questions originally is it doesn't say what 0 or less should return. It is left up to the programmer to think about what that means. Shouldn't that be specified?