when you click the button, I record a srart time. after all tests(1500 random tests and a few fixed tests) finished, I record another time, and then end time - start time, finally I got a time value.
The reason? ;-)
Because some "evil" user wrote memorizing programming code, which is not the way I want. It calculates the value of each year in the range(1000..275760) and stores them in an array. The whole process needs 3000-4000ms. Of course, if this kata is not a challenge edition, this is a valid solution.
However, the solution I want should be able to quickly calculate each result. This is the significance of the challenge.
Of course, if I increase the range of years, such a solution will be timeout. However, if I do this, I will hear some users complain that "the number of years is exceed the range of JS Date()!"
So, my way is set a time limit 500ms to ban such solutions.
Can you clarify this?
"12 seconds is too long :] So, in this kata, the time limit is 0.5 seconds(500ms)."
For what? I guess it's for a number of executions.
Only 4 fixed assertions in the entire Test Suite is far from sufficient for preventing logically flawed and/or hardcoded solutions from passing. Please either (1) increase the number of unique, distinct fixed assertions to at least 20 including edge cases or (2) even better, write 100+ random tests as per standard Codewars practice and is favored over just 20+ fixed tests.
Your example solution seems to indicate you didn't know there's a standard Array method for this. There is. If the point of this exercise was to point out there is a standard Array method for this, it worked for you. :P
I'm getting this failure as well, if the pass/fail properties are not magicArrays then the chainable tests will fail, otherwise the getSplit test will fail. Any suggestions?
EDIT: durr, just needed to define the method props as non-enumerable :)
Thanks for the feedback.
I just removed all the date functions and it passed.
Here is my result:
Thanks. This answers my question.
One more thing... Can you please try again and make sure your solution works in under 500ms?
when you click the button, I record a srart time. after all tests(1500 random tests and a few fixed tests) finished, I record another time, and then end time - start time, finally I got a time value.
I don't think you understood my question.
I'm wondering what exactly is limited to 500ms.
Is it the whole test suite of a few thousand tests?
The reason? ;-)
Because some "evil" user wrote memorizing programming code, which is not the way I want. It calculates the value of each year in the range(1000..275760) and stores them in an array. The whole process needs 3000-4000ms. Of course, if this kata is not a challenge edition, this is a valid solution.
However, the solution I want should be able to quickly calculate each result. This is the significance of the challenge.
Of course, if I increase the range of years, such a solution will be timeout. However, if I do this, I will hear some users complain that "the number of years is exceed the range of JS Date()!"
So, my way is set a time limit 500ms to ban such solutions.
Can you clarify this?
"12 seconds is too long :] So, in this kata, the time limit is 0.5 seconds(500ms)."
For what? I guess it's for a number of executions.
What do you do to the void case?
I can't see (un-flag) your response
This comment is hidden because it contains spoiler information about the solution
As @JohanWiltink said, the testing is too limited even for an easy
8 kyu
. More specifically:Codewars Forums - Kata Best Practices - Have Full Code Coverage
Only 4 fixed assertions in the entire Test Suite is far from sufficient for preventing logically flawed and/or hardcoded solutions from passing. Please either (1) increase the number of unique, distinct fixed assertions to at least 20 including edge cases or (2) even better, write 100+ random tests as per standard Codewars practice and is favored over just 20+ fixed tests.
Duplicate:
https://www.codewars.com/kata/enumerable-magic-number-3-does-my-list-include-this
Your example solution seems to indicate you didn't know there's a standard
Array
method for this. There is. If the point of this exercise was to point out there is a standardArray
method for this, it worked for you. :PTesting is too limited, even for an 8kyu.
If anybody wants to run the code in browser and use the debugger, here's a Chrome Extension to help you
https://github.com/bojan88/Codewars-JavaScript-debugger
I'm getting this failure as well, if the pass/fail properties are not magicArrays then the chainable tests will fail, otherwise the getSplit test will fail. Any suggestions?
EDIT: durr, just needed to define the method props as non-enumerable :)
Loading more items...