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
I would advise against
Object.freeze(Math)
since that doesnt prevent justdelete
ingMath
and redefining a newMath
object.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
Codewars test framework already has a method for determining if floating point numbers are within a margin, use
test.assert_approx_equals(actual, expected, margin=margin)
instead of measuring the delta yourself.Random is not seeded with
srand(time(NULL))
, so the random tests generate the same output each time.This comment is hidden because it contains spoiler information about the solution
The
BigInt
primitive is in stage 3/4 of the ECMAScript specification, and not all browsers/engines support it. The latest version of node to support it is10.4.0
and since this kata doesn't support10.4.0
, theBigInt
primitive does not apply.More accurately, it seems
replaceSpacess
is the name of the function that the test code uses to generate the expected solution, and that it was simply not included in the test cases. Thus, random cases can be bypassed by just making surereplaceSpaces
andreplaceSpacess
return the same thing.This comment is hidden because it contains spoiler information about the solution
This comment is hidden because it contains spoiler information about the solution
If I am understanding the description properly, the test cases seem to be incorrect. If
percentile = participants_you_are_better_against / all_participants * 100
, then for eachpercentile
,(percentile / 100) * min_participants
should be an integer, as people cannot be fractional. However, both the fixed and random cases don't reflect this.In the fixed cases,
50000 works and is smaller than 166667. In addition, 166667 does not work
166666.6 repeating works, but that would imply that non-integer participant counts are allowed.
Some examples in the random cases:
Either the test cases are incorrect, or the description is incorrect
Test #4's description is a bit off. Numbers 1-3 say
lowerCaseLetters should be {expected}
, but #4 sayslowerCaseLetters should be {input}
. If you would liked to show the input in the test description, maybe have something likelowerCaseLetters({input}) should be {expected}
Also, #4 is not very good as a random test. The input is a template filled with numbers and the output is fixed, which allows for hardcoding. True random tests would be the best, but if you must use template based tests, then thrown in some spaces or capitals rather than just having the alphabet with two digits between each letter.Random tests could be implemented; although, it will not be an easy task to do.
One-word search queries would be pretty easy. Generate a random word string for the text, and randomly pick or not pick one word from the string. However, multi-word random tests would be harder to accomplish.
One way could be to use a fixed boolean search pattern, such as
'({} AND {}) OR {}'
, and fill it with randomly generated words. You could then check using your own algorithm, and compare to the user's.There are probably multiple other better ways for implementing random tests. Anyone else have any ideas?
This comment is hidden because it contains spoiler information about the solution
Loading more items...