6 kyu
Hollow array
313 of 744aweleshetu
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.
The description is not clear enough. The rule "preceded and followed by the same number of non-zero elements" -> does "same" refer to the zeros? Or to the non-zero groups at the beginning and end?
That's about the non-zero elements, and you can see that in the sample test.
All languages should have fixed tests below to invalidate some cheezy solutions that check for summation == 0
[0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, -2, -1]
Had a lot of fun solving this kata, I'd might say relaxing rather than challenging.
This comment has been hidden.
firstly, this is not an issue, this is a question, so try to post with question tag
secondly, you could try using markdown syntax to make the code more usable for ppl trying to copy/paste your code.
you can read this in the meantime
This comment has been hidden.
That's not true.
Print the input to debug your code. What is a hollow array is well defined, not a kata issue, closing.
So you're saying if i pass 3 zeroes in the array[0,0,0], is this also a Hollow array? Can anyone share the test cases or should i post another question regarding it?
it is
what are you trying to achieve by getting the test cases ;)? if you are struggling to complete it, you can unlock solutions to see what other users have done
Yes. You can print the input as I suggested so you can see with which ones your code fails.
About
[0,0,0]
:Is it clear now?
C translation
(author inactive)
Approved
This comment has been hidden.
Hi,
not an issue, a question. Reading this might help: https://docs.codewars.com/training/troubleshooting/
Cheers
I get this erorr: /workspace/node/test.js:33 Is it okay?
There was a problem in sample tests. It should be fixed now. Save your code locally, click on
reset
and it should be fine.Really confused with the question! [2,0,1,0,0,0,1,0,2] will this return True or False?
Are they?
Suggestion for Typescript,
have:
static isHollow(x) {
want:
static isHollow(array: number[]): boolean {
Added some time ago
Solved this kata but I second to people who says that it is not well described. Wasted time on trying to figure out what are the rules.
Honestly one of the wrost kata's ive dealt with. Just got stuck with the edges cases for no reason. Question is not clear enough so I just finished the guessing and submitted it.
Just got stuck with the edges cases for no reason.
, No you got stuck with edge cases because you didn't understand the kata. If you don't understand a kata, please don't solve it because you will just kill your time guessing. Hope you learned that lesson from this kata tho :)This is either not well explained or the test cases are sloppy.
here is the definition of what an empty array is, according to the instructions:
An array is said to be hollow if it contains 3 or more 0s in the middle that are preceded and followed by the same number of non-zero elements.
considering that, how does this make sense: Expected: true, instead got: false [0, 0, 0] Expected: true, instead got: false [0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
please show me where the "non zero elements" are. Is the absence of anything at all to be considered as "non zero elements"?? seriously??!
next time i see your name in a Kata Senseï (hopefuly it is easy to recognise), I run the other way.
They don't exist, right ? which means those arrays are preceded and followed by
0
non-zero elements. Ask yourself, how many non-zero elements are in[]
?alright, alright, guess i might have been a little narrow minded here... thanks.
This comment has been hidden.
please don't post such things as an
issue
. if your code is stuck in infinite loop, it is your problem not the kata's problem. Had it been the kata's problem, i would not be able to publish it while running in an infinite loop. So don't get frustrated, just check your code again and again.In the kata description it is stated that zeroes must be
preceded and followed by the same number of non-zero elements
while in test cases I seeTest.assertDeepEquals(isHollow([-1,0,0,0,3]),true);
. There is only one non-zero element before and one non-zero element after0, 0, 0
. According to kata description there must be 3 non-zero elements, but not one. Please, clarify the requirements or test cases.not an issue. Read the description again... ;)
I found bug in my code and missing edge case - [0,1,0,0,0,1,0] Basically zeroes (symentrical and not) at the ends.
what have you found exactly ?
I assume [0,1,0,0,0,1,0] is not valid case but my code would mark this as valid and pass validations in task. here is code that passed all checks including [0,1,0,0,0,1,0] - https://www.codewars.com/kata/reviews/59bded50c02fe5cf6000051a/groups/59c284f43725a73477002336
resolved.
these are random tests and result (true/false) from my function but I'm still failing tests
[ 6, 2, 4, 2, 2, 2, 1, 5, 0, -100 ] false [ 0, 1 ] false [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, -2, -1 ] false [ -1, -2, 0, 0, 0, 2, 3 ] true [ 1, 2, 0, 0, 0, 3, 4 ] true [ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 1, 1, 1, -2, -1 ] false [ 2 ] false [ 3, 2, 10, 4, 1, 6, 9 ] false [ 3, 2, 10, 4, 1, 6, 9 ] false [ 1, 3, 9, 8 ] false [ -6, -3, -3, 8, -5, -4 ] false [ 0, 1 ] false [ 3, 2, 10, 4, 1, 6 ] false [ 6, 2, 4, 2, 2, 2, 1, 5, 0, 0, -12, 13, -5, 4, 1 ] false [ 1, 2, 0, 0, 0, 0, 0, 0, 3, 4 ] true [ 0, 1 ] false [ 1, 2, 0, 0, 0, 0, 0, 0, 3, 4 ] true [ 1, 2, 0, 4, 3 ] true
Not an issue, ask for a question. That's your code that is wrong, not the code of the kata.
About your problem: How could we know since you post only tests where your function works...
What an idiot my tired brains are today :)
This comment has been hidden.
I have the first edge case, But the second one is not the intention of the kata. Because the kata's intention is
zero
s in the array, notzero
s in a single number.But some solutions will allow the second case to pass.
So you need to check for that as well.
@ZozoFouchtra, thanks for the tips, your edge cases are now added. I hope you get some free points for your contribution :stuck_out_tongue:
Nice!
Why?
0
number of non-zero elements is still the same ;-)But what's this?
What's the mean of middle? the first element and the last element are the middle position?
That just means there must be only 1 cluster of
0
s.When the whole array is
0
they're of course centered at the middle of the array ;-)perhaps author's
middle
is not mymiddle
... I've solved it, althoughThis comment has been hidden.
This comment has been hidden.
https://www.codewars.com/kata/reviews/59b729d5677bf16e7b00003e/groups/59b73725677bf148240000d2
I managed to submit a bugged solution again.
Again, I'll leave it to you to find out why it's bugged ;-)
fixed