Retired
No Duplicates Here (retired)
217 of 500thegsi
Loading description...
Arrays
Fundamentals
View
This comment has been reported as {{ abuseKindText }}.
Show
This comment has been hidden. You can view it now .
This comment can not be viewed.
- |
- Reply
- Edit
- View Solution
- Expand 1 Reply Expand {{ comments?.length }} replies
- Collapse
- Spoiler
- Remove
- Remove comment & replies
- Report
{{ fetchSolutionsError }}
-
-
Your rendered github-flavored markdown will appear here.
-
Label this discussion...
-
No Label
Keep the comment unlabeled if none of the below applies.
-
Issue
Use the issue label when reporting problems with the kata.
Be sure to explain the problem clearly and include the steps to reproduce. -
Suggestion
Use the suggestion label if you have feedback on how this kata can be improved.
-
Question
Use the question label if you have questions and/or need help solving the kata.
Don't forget to mention the language you're using, and mark as having spoiler if you include your solution.
-
No Label
- Cancel
Commenting is not allowed on this discussion
You cannot view this solution
There is no solution to show
Please sign in or sign up to leave a comment.
This kata is a subject to deduplication process here: https://github.com/codewars/content-issues/issues/136.
Please join the discussion to help us identify duplicate kata and retire them.
Retired.
Ruby 3.0 should be enabled.
Kata retired.
The kata is far too unspecific about what is considered an invalid entry (at least for
Ruby
). There should either be example tests showing what's expects or it should be explicitly mentioned in the description. Of course, all tests should also follow these criteria.maybe its just me but there is too much work with typechecking i saw the one line solutions if the purpose of this kata is to get to that clean one line solution then okay i don't mind
Not an issue.
The JS version does something very weird with datatypes, which is not specified in the Description and which I have absolutely no inclination to reverse engineer.
Also, the tests use
Test.assertSimilar
instead ofTest.assertDeepEquals
, so any difference between numbers and strings is lost in rendering test results.My honest opinion of this kata is quite unprintable.
Ha, you are spendind too much time with Voile.
on Voile, not with Voile.
Wait, that's not what you mean. I had a good row with him this afternoon on whether
_|_ :: () == ()
.Err, no, this is probably my own opinion.
Johan, I can fix the JS if I knew exactly what problem you have. What does it mean by "similar" values in JS?
Tests play very loose with datatypes. My solution has this
in it, and that's weird, given that the tests cast everything to a
String
( twice actually! ) before comparing it.But it's been a year, I don't immediately see what the problem is and I'm not about to invest time in it really.
I think
NaN
was taken out of the random generator later - author apparently didn't know thatNaN !== NaN
and couldn't think of! array[i]
(?!). I still think it's a trainwreck.The whole kata is broken in how it deals with
false
/true
(in ruby at least).You say to remove falsey values explicitly in the instructions, yet the ruby version submit random test cases include false and true values!
The only falsey is just for JS.
The random test case results do not meet the criteria
What language?
It's not clear what 'invalid' elements are. There's a note about no falsy values in javascript, but in a random python test it expects False to stay in the list.
It is language dependent, things like nill, undefined, etc. As JS can basically do odd things, there really are no invalids, hence you strip all falsy, only in JS.
On one of the tests comes to an object instead of an array, and is expected to return "Not an array". Questionable practice.
Not an issue.
This comment has been hidden.
Yes it should. Because the Kata specifically asks that the result should be sorted.
Oh okay. My bad, I didn't read the instructions well enough.
Dont' quite understand, why in test case list "['?', 'a', 'e', 'y']", the function should return 'Not an array' ?
What language?
The description is not too clear and the number first rule is broken. There are some tests with a number first expectation, while others have a string first expectation, expecially for specs with Stringed integers.
It means a number as a number, or a string with a number in it.
The tests don't test for all criteria. It intentionally leaves the criteria out because its included in the final submission test. That is poor Kata design. All test criteria, when provided at all, should test for all requirements.
What language?
The "numbers first" rule is broken in the random test cases.
The hand coded test cases expect
[3, "3"]
. The random test cases expect["3", 3]
.It means a number as a number, or a string with a number in it.
I don't get it. Why shouldn't the 1 be in the list?
"Testing for None, t, t, m, z, 2, 3, s, c, m, True, n, r, i, 9, q, 2, j, p, 1, z
It should work for random inputs too: [True, 1, 2, '3', '9', 'c', 'i', 'j', 'm', 'n', 'p', 'q', 'r', 's', 't', 'z'] should equal [True, 2, '3', '9', 'c', 'i', 'j', 'm', 'n', 'p', 'q', 'r', 's', 't', 'z']"
The description is too vague. For example the error, needs to be defined in the description.
Updated.
Does "with numbers before strings" has any meaning,if not it should be removed from the description because final solution and your description are two different katas/cases !!
I've already unlocked the solutions realized no one is accounting for special chars in the list. How is it that I'm getting this error : -> ['?', 'a', 'e', 'y'] should equal 'Not an array'
Description is incomplete and inaccurate. No mention that 'true' values are possible, and implies that numbers should come before stringified numbers, which is not the case. Also, implies that false valus should be removed, which is also not the case.
Description was updated.
All my tests pass except this one. I don't understand why False is in the answer. The instructions don't say anything about boolean values. Am I missing something?
Testing for 6, 8, 8, 0, e, False, j It should work for random inputs too: [6, 8, '0', 'e', 'j'] should equal [False, 6, 8, '0', 'e', 'j']
Very nice kata! And again stunned about the plentitude of ways to tackle problems like thise. Clear requirements and ample test cases. Nice one!
Explanation text should be divided in paragraphs. Overall good work!
Thanks, I have broken these down now, hope that is as you suggested.
Resolved.
Nice kata! Clear assignment, no tricks, thorough tests
You should give examples in the kata description of what you mean by 'invalid elements'.
Thanks for the feedback, I have done this.
The "The returned array should be sorted alphabetically as a string" piece of the instructions was confusing; I would recommend restating it as "The items in the returned array should be sorted alphabetically, with numbers before strings" or something...
Why the string '3' is expected to be before the number 3 (Python)?
Actually it is not, just checked all the test cases: by default sorting behaviour, numbers come before strings.
Yeah, you are right. Then vice versa: it's not clear from the description why the number 3 is expected to be before the string '3'.
I think you should add number 0 (zero) to array which is passed as argument. Some current solutions is not properly.
Sorry, I do not understand what you mean. Which solutions are the problem.
array.filter(Boolean) - This method will remove zero from the array, because zero is false. So test case should contain zero in array passed as argument to function. example: [0, 1, 2].filter(Boolean) // return [1, 2]
edit: Zero is valid value, or invalid like null?
Checking the original code, I would assume that all falsey values are like null.
I would also add that to the description, if the author is ok with it.
Yes, please add falsey values to the description. I will add a zero the the test case now.
Done :)
Translated into both Ruby and Python, if you wish to approve them :)
If you do, please let me know as I would like to edit the description a bit, taking into account that Python does not have arrays (it has lists, not that much different from a solver pov, but still worth a bit more precision).
Are you ok if I add random test cases to the JS version too?
I have approved the ruby and python translations. Thank you for making these! Yes, please add random test cases to the JS version.
Done :)
The random input is JSON.stringified, so everyone should be able to see it without ambiguity; I had to .join() the results, though, in order to make different versions comparable.
This comment has been hidden.
I think he could just
.join(", ")
the expected result and compare it with '3, 3, three': with a custom error message it could be the neatest way to handle it.This comment has been hidden.
You are right, but I found a bit more clear to use comma and space, both for readability and having it a bit more clean once it has to break on more than a line; well, I think it goes to personal preferences.
And I am still far from being a tensai, monsieur future deuxième place ;)
This comment has been hidden.
It might be true, yet the closer I get, the more I tend to focus on my shortcomings; I guess is my perfectionism kicking in not to make me too lax on certain aspects.
And you italian does not cease to amaze me; if I may make an appoint, "non mi sembra che tu sia molto lontano [cut]" would be preferable, as in case of doubt or uncertainty (as you are expressing a personal opinion with sembra) the use of subjunctive is more correct (not that your version was wrong and it can be fairly common in spoken Italian).
In a way it was well-played indeed, as I certainly did lack the skill to be in the same deck with you and many others around here. But even so, I can't stop to want more and more challenges ;)
Thank you, I have made this change to the solution. I am new to coding so all help is gratefully received.
I've passed all the tests, but get an error saying Object aye? has no method filter. But I can't find where aye? is passed in as a test array.