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.
Rejected because of missing random tests. If you want to improve this you can fork this translation. Also please upghrade to JUnit 5 then.
i think var will make counter accessible via constructor, and there was no test for this case
Retired as a duplicate. See https://github.com/codewars/content-issues/issues/48
Duplicate, differences: -
midnight
; + hyphens betweentwenty [ord]
; + redundantam
/pm
in inputThis comment is hidden because it contains spoiler information about the solution
How does the instances have access to the
counter
variable? It's not passed as a method (e.gthis.counter
), it's not passed as a prototype either (e.gCounter.prototype.counter
).So how? Closure? That would make sense if we call it directly on the
Counter
function constructor, not its instances.Recursion is beauty here!
The problem was with my code indeed! I simplified the solution and it passed normally on Codewars now.
I have my local repo setup with TS, mocha and ts-node and I execute the
test
task in package.json to verify that all tests pass.It's with this setup that my erroneous code passed and I want to investigate further why that was the case.
When I executed via a classic node cli terminal locally, it threw the same memory error as Codewars did!
I will post here my findings when I find out what magic did the TS compiler and my code passed in the first iteration.
You might be running into an infinite loop or something... The error says you tried to allocate too much memory, possibly for a very big array. I'd bet that's from your code, and not the tests. Did you try logging stuff to console to see if that's the case?
In such case, it's difficult to tell why it does not work without seeing it. Kata seems to be OK.
It throws this error even with the sample tests which use simple and small arrays. The same sample tests and even more complicated ones with object references pass with flying colors locally. This memory error is very strange. That's why I posed the question tentatively and not marked as an issue.
Just solved the kata in JS and encountered no problems.
Did you try to run similar test case, with similar sizes of arrays, locally in your IDE? There's a big chance that it will fail for you also locally (this FAQ could be helpful).
I've authored a JS solution that works on my machine (at least for various cases that I created and the sample tests provided), however when trying on CodeWars I get this stacktrace:
Can someone please tell me if this error originates from my code or it's a CodeWars platform error?
The general error at the end reads "JavaScript heap out of memory" yet I am not using memory intensively, working with indices mostly, nor am I modifying input arrays.
This comment is hidden because it contains spoiler information about the solution
Loading more items...