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.
"Calculate a math formula" is not a novel idea.
Returning
time
compotent is pointless.Yup:
for
loop. There're 10 of these now.This is looking good. :]
Couple things you missed:
dist===0
is not a special case (this is why I wanted[[0,0]]
instead of[0,0]
:). you can remove that line from your example and reference solution.expected
values have somex.09999999999999
values in them. that should really bex.1
; you're seeing JavaScript floating point inaccuracy in action. assertApproxEquals is taking care of that though.for
loop. get hardcoded values from a hardcoded array, indexed with the loop. that also makes it easier to have some more random tests. it's not essential, but 50 or a 100 won't hurt. (if ever you find an edge case with a random test, make it into a fixed test!)Okay, I think I finally managed to wrap my head around this, random test cases and all. Please have a look if I missed/misunderstood anything. Again, thanks for helping out.
When working with floating point values, there should be no rounding. That's the whole point of
assertApproxEquals
.So
expected[1][0]
should now be6.1
instead of6
.Also, you now have only one test. A bit of copy/pasting to have some more would be nice. I especially wrote it so you only have to change
arg
andexpected
in one place.Well, I just pasted it in and it seems to be working. I'll try to figure out random test cases in a day or two. Thanks for your feedback and input!
Does this help?
I haven't tested it, this is just straight
head | keyboard > code
.That's exactly what I wanted to suggest ;)
I'm a little shaky on testing and it seems that implementing
Test.assertApproxEquals
will require overhauling the tests altogether because of the comparison I use. I'll try to figure it out, but, if you feel up to it, contributions are more than welcome ;-)I'll change the output for 0 (done). Thanks.
Rounding errors in the reference solution cause my valid solution to fail:
[1280,20]
really is correct! (UseTest.assertApproxEquals
instead of rounding.)No random tests.
Inconsistent return type:
gravity(0)
should return[[0,0]]
.Yeah, I didn't check around for similar kata, just wanted to try and publish my own. Because reasons. Guess I'll un-publish it in a few days.
An exact duplicate of https://www.codewars.com/kata/integer-to-english
Sorry about that. All fixed now. Thanks for pointing this out.
"fourty" ?!?
Better specify the numbers if you're going to use alternative spellings.