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.
Gripes with the description that I feel should be addressed:
The PHP random test cases are broken.
I know they're broken because I SOLVED IT!
drop-in hotfix included in this post! (down near the end)
Sorry if this is a litte long-winded, pretty new to this.
There are 2 core issues here:
A Fatal error within the random test-cases.
This was mentioned 2 years ago by another user.
I originally thought this was a memory leak due to some pile-up of
Node()
objects somewhere, but after more investigation this doesn't appear to be the case.This appears to correlate more heavily with the next issue. (though, it's hard to say exactly how?)
This can be avoided by creating new nodes rather than linking nodes. (
$node->next = new Node($other->data);
)Mangled inputs making the random tests effectively impossible.
This was mentioned 5 years ago by another user (the issue mentioning 'DEAD LOOPS' (I'm unfamiliar with the term, but I think they're correct?)).
The random test cases are re-using the previous solution for the next tests input.
These random tests appear to take the form of "append a to b, then append b to a" (in pairs), with the issue being that list_b for the alternate case will contain the previous solution instead of the swapped input.
This is possibly due to literally having swapped the input variables (after users have mutated them), instead of fully re-constructing them for the alternate test-case.
This can be worked around by using global variables to cache the previous inputs and outputs, to determine if one's been mangled, and restore the correct input.
Here are the functions, setup and teardown that made this kata possible for me. (I'm hoping this won't get spoilered, because I really have tried to keep it spoiler free).
There's almost certainly other ways to tackle this once you know how the bugs work, but this should (hopefully) be a decent drop-in hotfix:
I hope this helps someone out there!
I'm not really raising this issue looking to see a fix to a 5+ year long issue, people have lives to live, and I'm not looking to demand free work.
I just hope to make the purpose of this post clear and give others the chance to solve this kata, because I really have enjoyed the series so far! <3