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.
For some people it's considered to be the best practice to put break in each case block, even when it's unnecessary like in this example. Reason is that someone can change the code but forget to add break statement which might lead to bugs that are hard to trace.
I know it's 11 months old but thanks for explaining this (as if it's a Stack Overflow answer!), it really helped me understand.
This theorem doesn't work for this kata. Think about how to reduce number of cycles of the loop - that's helped me a lot. Before that I got interrupt (more than 6 seconds). After improvement - all tests have been completed in ~ 0.3s (<300ms)
It seems like you are now checking for this but don't mention it in your spec?
I started writing an explanation - but this is better: http://floating-point-gui.de/
Floating point math is notoriously dodgy in most programming environments, and JavaScript is no different. For example,
0.1 + 0.2 == 0.30000000000000004
. You'll have to work around it to solve this kata.Thanks for this comment! I was able to troubleshoot the issues, and I think it should be working now!
I can't submit right now, but it seems like now you check that the state falls back to regular in test 15, then you suppose in test 16 that eating a ghost increases points by 10, but the state is now regular, so it occurs to me that this test is wrong since the value should be 0 when you ask for 10, then in test 17 you eat an other ghost, suppose that a life is lost, but a life is already lost in the previous test, therefore you suppose 2 when its 1. I also mention that since I can't submit working code, I can neither see spoiler content nor actual test cases.
edit: This should now be resolved. Thanks for the feedback!
This comment is hidden because it contains spoiler information about the solution
My mistake. I corrected it.
AFAIK the docs should refer to the current stable implementation while the codewars-runner config is for the beta Docker system, which has an opt-in button in your account settings.
Anyway, if you need to speed this up, try to think of a good maximum value for one of the loop variables.
For large values, there's a little theorem from number theory that could help:
Oh, I thought it was 5 seconds... - https://github.com/Codewars/codewars-runner/blob/master/lib/config.js
This comment is hidden because it contains spoiler information about the solution