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.
I don't like it that the example here suggests that the bible is a good book. Opinions about a particular religion shouldn't be part of these Kata's. The same is true for political opinions: "The democrats are good", or "The republicans are good", wouldn't do either. There's also no need to use this example, anything will do.
I edited my issue, I saw there was a mistake in my suggestion. One other thing that made me doubt your Kata was a typo:
solve("dabc) = True, because it contains a, b, c, d
should be:
solve("dabc") = True, because it contains a, b, c, d
Note the missing double quote in your instructions.
This is a language thing. I already commented on it, and it got downvoted. Not sure why, but English proficiency might be part of this Kata.
This comment is hidden because it contains spoiler information about the solution
The PHP version of the text align justify Kata has been broken for a long time.
I've got a working solution and I can see what's wrong with the current one, but I don't think I can edit the Kata test cases.
There are comments about this dating back at least a year. Clearly the original author doesn't care. What I can do? I've never authored a Kata, I'm quite new at this, so I haven't a clue. Tried several things, but to no avail.
I have to concur. There is only one sample test, and that doesn't really test anything. Then when you attempt the real test it just fails without really giving a good hint why. Tried all sorts, to no avail. It is always possible we have done something stupid, but there's just no way to know. I believe I followed all the rules to the letter.
Yes, if we would introduce "cycle length" then a lot more modifications would be needed. And although "cycle length" helped me to finally understand the task, I'm not sure it will be that helpful to others.
It could also introduce another misunderstanding. Concider this "infinite cycle":
P1 -> P2 -> P3 -> P4 -> P5 -> P6 -> (P3)
Would the "cycle length" here be 6 or 4? You could argue for 4 because the "cycle" jumps back from
P6
toP3
and therefore the "cycle length" must be 4. So, better not go there...I really find it hard to judge that. The reason I was confused was because I didn't understand the description well enough. I read it twice and then only concentracted on what it said about the task. That was my mistake. But looking at the comments here, I can see that more people struggled with this. Let me therefore try to propose a better task description. It now is:
"Though, rather than to analyse only the first encountered infinite loop and get stuck in it like the robot would be, your code will have continue deeper in the calls to find the depth of any infinite recursion or terminating call. Then it should return the minimal and the maximal depths encountered, as an array [min, max]."
My proposal would be:
"Though, rather than to analyse only the first encountered infinite loop and get stuck in it like the robot would be, your code will have continue deeper in the calls to find the depth of any infinite recursion or terminating branch. Then it should return the minimal and the maximal depths encountered, as an array [min, max]. Note that the depth of a terminating branch is, by definition, zero."
So I call it a "terminating branch" instead of a "terminating call", which is more in line with the text above the task description, and I added the note.
Will this help? I don't know. Getting these concepts across is just difficult.
Ah yes, now I understand! The term "cycle length" is very useful. I fully concentrated on the task description, which is talking about "depth". To quote:
The task is: "... to find the depth of any infinite recursion or terminating call. Then it should return the minimal and the maximal depths encountered ..."
and I assumed that "depth" meant how deep the recursion had progressed. But I neglected to read above the task description, under the heading: "No infinite recursion", that in such a case "the depth will be considered 0". It's all there.
So it all comes down to careful reading.
@Blind4Basics, I'll give some examples.
========== example 1 ===========
The script:
p234F2RP234F2LqP234
Containing patterns:
234 : F2RP234F2L
Base script:
P234
executing this gives:
P234 -> P234
(inf recursion, at level 1)return according to Kata: [1, 1]
So in this example we reach an infinite recursion at level 1, and the minimum and maximum recursion depth are set to 1.
========== example 2 ===========
The script:
p1P2qp2P3qP5p3P1qp5P6qP1p6F2q
(my own creation)Containing patterns:
1 : P2, 2 : P3, 3 : P1, 5 : P6, 6 : F2
the base script:
P5P1
and executing it gives this:
P1 -> P2 -> P3 -> P1
(inf recursion, at level 3)P5 -> P6 -> F2
(normal termination of branch at level 2)return according to Kata: [0, 3]
The inconsistency here is that, eventhough no recursion branch ends at level 0, we still have to report the minimum recursion depth as being 0. This is because there is a normal branch termination at level 2, and such a termination always sets the minimum to zero, regardless of the actual recursion depth.
The "testRandomMixedTests" contains the simplest script where this problem occurs:
P9P1P7P5P4p1P2qp2P3qp3P4qp4P1qp5P8qp7P5qp8P7qp9F2q
I hope this explains it a bit?
I solved the PHP version. I know this has been discussed here before, but I think there is indeed an issue with the minimal recursion depth. For a recursion branch, that doesn't end because of infinite recursion, I always had to set this minimum to zero, regardless of the actual recursion depth. This just doesn't seem right. I spent most of my time solving this inconsistency.
It all comes down to what is regarded as a recursion. I assumed that substituting a 'Pxxx' by it's 'pxxx????q' definition, and then executing its content, should be considered a recursion. At least that's what I counted for the infinite recursions. So why is it not counted in the same way for branches that have no infinite recursion?
When I write a PHP Kata solution, my comments are a dark gray color. They fade a bit into the background and this makes the code stand out. However, after submitting the solution, the comments have the same white color as the code, making the code look ugly.
I understand that the PHP code editor uses a different codebase as the PHP code viewer, but I think this discourages me from adding useful comments in the future. That cannot be a good thing.
So my request is simply: Can PHP comments also be dark gray when viewing the code? Preferably the color scheme should be the same, whether editing or viewing.
This comment is hidden because it contains spoiler information about the solution
Could this Kata possible be easier to solve in Javascript than in PHP? I only did the PHP version, but I found it to be more difficult than other level 4 Kayas.
All 12 current PHP solutions, including mine, use stuff from the PHP manual where it says in a big red box: "Warning: This function is currently not documented; only its argument list is available.". In other words: "Who knows what this does? Use at your own peril.". This is clearly not something you would ever want use on a daily basis.
Katas always seem have the same difficulty level, regardless of language, but perhaps that is not always right?