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.
all languages edited
we need better random test generators (EDIT: javascript fixed and random tests updated)
Refactored to avoid having to sort the final list.
I"d suggest adding 4444 -> MMMMCDXLIV and 1999 -> MCMXCIX for testing all the prefix numbers. My original algorithm had a flaw which meant that these sometimes didn't work but it neverthless managed to pass an attempt because the random cases didn't happen to generate any of these that time.
Annoyingly, just after submission I've noticed that somewhere during editing and retrying, I've lost the optimisation of substr -> slice, so it's one character longer than it ought to be :-)
and you should, this is a 4 kyu after all
ofc, you can change the tests if that's needed.
That's not intended but I guess I can't do anything with it 😂
My solution is faster than that, so I guess I can further raise
n
or make timer stricter.But probably not after this kata being approved.
I figured out what the issue was (to do with large negative number arithmetic) and have fixed it and submitted my final correct solution. Removal of the incorrect one would be appreciated if possible.
If there's a way of removing the solution it shouldn't stay because it isn't a correct solution. As I mentioned, it fails about 5% of the time. It's also unfinalised and has multiple things I would tidy up before properly submitting.
Your solution will stay. Those solutions were not intended.
This comment is hidden because it contains spoiler information about the solution
Random tests are fine. Your solution is not precise on larger numbers.
Is there something wrong with the random test cases? Because it seems VERY inconsistent.
One run I get them right, the next run with the same code they are one off. If I do the calculation manually for those runs your expected answer seems 1 too high every single time.
My code runs fast enough to not be an issue, and it doesnt overflow anywhere so Im not sure what's going on.
My last DSA lecture was 37 years ago so either I've forgotten something vital or the state of the art has moved on a bit! 😊
Loading more items...