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.
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 :-)
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.
This comment is hidden because it contains spoiler information about the solution
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! 😊
Still working on this, so I don't want a solution but unless I'm missing a "trick" answer or a clever simplification based on some mathematics I'm not familiar with, this seems extremely hard for a 4kyu problem. I've tried about 8 quite different approaches and have yet to have one that manages to come in under the 12 second limit. How did it get this rating?