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.
Tests will never try to free an unallocated pointer (at least in Python).
There appear to be random tests in Python now, can you confirm that they are missing in other languages?
brilliant!
lmfao seems like I was blind haha
Yes, because the X in the middle is surrounded by ~ on all sides, which makes it a distinct island.
it's not a completely ridiculous solution though.
fun kata but it would be more interesting if there was a performance version
What is your point exactly, did the chicken lay an egg or the egg produce a chicken?
I asked chatGPT to solve this kata, and this function with regular expression is the answer.
Test cases don't cover case when after releasing memory we have two adjacent blocks. All three blocks have to be merged to one block, and then test should check it. Something like this:
const mem = new MemoryManager(new Array(80));
const pointer1 = mem.allocate(16);
const pointer2 = mem.allocate(16);
const pointer3 = mem.allocate(16);
const pointer4 = mem.allocate(16);
const pointer5 = mem.allocate(16);
mem.release(pointer2); // release left block
mem.release(pointer4); // release right block
mem.release(pointer3); // release center block
mem.allocate(48); // try allocate size = 3 * 16
My code doesn't cover this case but still passed all tests!
clever
Loved the Kata, interpereters are always fun, but I was able to brute force the random tests with a bit of good RNG.
Now I gotta find something else to do......
this is supposed to be two islands and not one ? Am I missing something?
I'm getting this error:
My code does pass the example tests fine; the issue is on the random tests. That said, I don't have a
.replace
in my code, so I'm not sure if this is my mistake or not. If it is, then the error message should be improved.I finally got top answer.
Loading more items...