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.
This comment is hidden because it contains spoiler information about the solution
The PHP version is quite lame in its checking of "count" use.
It literally regexes "/count/i" so my intermediate
$count
variable was erroneously flagged as hacking.I just renamed it to
$c
and it worked.This comment is hidden because it contains spoiler information about the solution
Great investigation @trashy_incel.
Indeed my beef was, among other things, that it was expecting stuff like "123abc" to pass.
the setup of this kata in PHP has really big issues. not only are most solutions wrong, including the author's, because they use the value
0.0
to detect invalid inputs, which means they fail the simple test caseassertSame(0.0, parseFloat("0.0"))
, but, contrary to all other languages, the random tests expect123.0
for something like"123abc"
, just because(float)
/floatval()
in PHP behaves differently than most other languages (e.g. for the same input JavaScript returnsNaN
, Python raises aValueError
, etc.)the description does not indicate the expected behavior at all, which means all languages likely fallback to the behavior of their builtin.
I made a fork there adding the
"0.0"
fixed test and replacing the reference solution with something saner, but i'm not going to self-approve, as this will invalidate all solutions.I checked the history of versions, those invalid solutions managed to pass because tests used the loose equality
assertEquals()
when the translation was published. it has since been changed to the more robustassertSame()
how did you determine that ? I tried a dozen solutions from the Solutions page and most worked. a few old solutions did not work because they perform no error checking at all and return
0.0
instead ofnull
for invalid inputs like"abcd"
I am not saying that the setup of this task is great, but I just completed this task in PHP.
The PHP version is impossible to pass, all the previous solutions don't work either.
Nah, it's poorly written.
There are no tricks, everything you need to do is literally written in the description: find the score for each person (gives you the formula) and sort the players by their score (or alphabet).
But it is absolutely written in a poorly convoluted way.
duplicate of this issue
fixed the order of expected and actual
fixed by upgrading to PHP 8.0
usort
the manual says:
Something's wrong with php.
Even solutions that should've been valid do not really work.
I can't get a fresh one to work either.
https://www.codewars.com/kata/reviews/5dea647d77902f0001e96d92/groups/5debd0568841740001276d82
Very poorly described, very few test examples, not a great kata at all.
I see, that's a good point then, if everybody calls them closures it's important to stick to them so everybody uses a common language.
That being said, I feel this is a limit on php part, being an implementation-derived rathen than spec-derived language (such as C, JS, Java and others) terminology is often used in a confusing and improper way.
That was a helpful discussion in any case for those that will read comments.
Loading more items...