Retired

Remove Zeros (retired)

6,529 of 6,542AustinBrunkhorst
Description
Loading description...
Arrays
Sorting
Algorithms
  • Please sign in or sign up to leave a comment.
  • hobovsky Avatar

    This kata is a candidate for retirement as it relies on contraints which are not enforced well, and are very difficult to enforce. Please join the discussion and share your opinion on whether this kata should be kept, or retired: https://github.com/codewars/content-issues/issues/167.

  • laurelis24 Avatar

    My first 4. But it probably too easy for a 4. There's even 7kyus harder than this. Anyway, enjoyed it.

  • Redareda15  Avatar

    i got only 1 false mixed test but i can't see the input so i don't know what the problemis

  • fishenal Avatar

    crazy 4kyu

  • DN20 Avatar

    wont even let me use shift and pop.. darkness

  • aulikhin Avatar

    This comment has been hidden.

  • momenGamer Avatar

    a good kata, but i think it would've been better if it was 5kyu or 6kyu

  • Supermedyk Avatar

    Weird kata. But I had fun solving it.

  • Vichnaya Avatar

    This comment has been hidden.

  • Vichnaya Avatar

    Id just like to ask what exactly temporary arrays and objects are

  • Vichnaya Avatar

    This comment has been hidden.

  • dallasUA Avatar

    Confusing description. And it definitely looks like 6

  • Abhi347 Avatar

    This comment has been hidden.

  • user3777975 Avatar

    This comment has been hidden.

  • user3777975 Avatar

    Clarification of what types are considered zero would really make the instructions less ambiguous. I had to forfeit eligibility to see the test suite because I could not get the proper order for all falsy values that are expected to return [1, null, '5', '2', 8, 6, null, false, '0', 0]. This was the only test that failed. Without giving anything away with respect to the test suite or solution, I'll just mention that the input array's falsy values do not appear in that order, but those of string or number type that loosely equal zero do. I don't see why it should be left to each user to figure that out.

  • mAbdeen9 Avatar

    it's too easy for 4kyu

  • mangwu Avatar

    Can anyone tell me that eror cause? log: [ 1, 2, 52, 7, '3', 1, 0, 0, '0', '0' ] Expected: '[1,2,52,7,"3",1,"0",0,"0",0]', instead got: '[1,2,52,7,"3",1,0,0,"0","0"]'

    When I run removeZeros([1,2,52,7,"3",1,"0",0,"0",0]) in my IDE it returns [1,2,52,7,"3",1,"0",0,"0",0]. Where did I go wrong?

  • Kiranits Avatar

    Are you really??? It says that my answer incorrect cause of order!!!

    Expected: '[7,2,3,4,6,13,78,19,14,0,0,0,0,0,0]', instead got: '[7,2,3,14,4,6,19,78,13,0,0,0,0,0,0]'

  • noway2code Avatar

    This comment has been hidden.

  • Yikes! Avatar

    When I run removeZeros([1,null,"5","2",8,6,null,false,"0",0]) in my IDE it returns [1, null, '5', '2', 8, 6, null, false, '0', 0]. When I run removeZeros([1,null,"5","2",8,6,null,false,"0",0]) on Codewars it returns [1, null, '5', '2', 8, 6, null, false, 0, '0'].

    Eh?! Help pls :D

  • andrew666theyung Avatar

    very bad kata, description is not compliant to actual solutions big dislike lol

  • sQuare Avatar

    shit kata lmao

  • kujo205 Avatar

    wait,does it count as temporary array if i pass my array into another function?

  • zLuki Avatar

    No random tests

  • zLuki Avatar

    This comment has been hidden.

  • choo_king Avatar

    This comment has been hidden.

  • r4ng3l Avatar

    one of my favorites!!

  • kuniku Avatar

    this is too simple for 4 kyu, but good kata anyway!! thanks

  • jckim Avatar

    too easy for 4kyu..?

  • WestwardLand968 Avatar

    Node 12.x should be enabled.

  • Sebad Avatar

    It seems to me that arrays need a medium and entropy will cause all mediums to fail in time, making all arrays temporary in the long run. Which makes it difficult to use the input array, if i'm not allowed to use any temporary array. At least that is my excuse for not understanding the nature of how computer folk define temporary.

  • Maksim7415 Avatar

    At first I solve this kata without using any array.prototype and object.prototype methods, but I used JSON.stringify. All tests were passed but stringify() failed cause it's prohibitted. WHY? It isn't array or object prototype method! Description and tests to this cata isn't correct! But it was funny, when I solve it then using two temporary arrays and spread operator))))) What a f... going on with this tests!?

  • DjCtavia Avatar

    Just finished the Kata after a bit more than 40 minutes, and to be honest. I don't feel like this Kata belong to kyu 4. Should be more about 3 or 2 with all the constraint inside of it. Also, a lot of answer used arrays and methods linked to Arrays, I don't know if people trying this kata should do it or not, it's complicated for not much.

  • raghurambachu Avatar

    In solutions people use arr.length(which is part of Array.prototype) and also in description it was nowhere mentioned about replace is prohibited. Also clearly mentioned no temp array but in many solutions I can see temproary array being created. It seems kata is not properly described.

  • nejc.schneider Avatar

    nice kata! not too hard but makes you think.

  • Neiluz Avatar

    Honestly the rules just make the kata artificially a little harder. Community had fine may way to circumvent it. And even if you play it fair they are not that hard to reproduce. Definitly not a 4kyu.

  • tylerhq Avatar

    I was a bit confused about not using temp objects. It made me think I couldn't use variables at all. It's clear from the other solutions that I could have very easily used variables sooner and solved it immediately.

  • CaseyPitman Avatar

    Not a huge fan of the unecessary (and a few unstated) constraints. I get the purpose, but not sure how much value that brings. I geuss I learned something.

  • svltmccc Avatar

    This comment has been hidden.

  • evilhaxor Avatar

    This is free points.

  • kidCaulfield Avatar

    So i've solved this kata and learned a lot in the process. However the solutions have been withheld and it's saying I have not solved it.

  • user5251454 Avatar

    This comment has been hidden.

  • par5ul1 Avatar

    This comment has been hidden.

  • Buddha_B Avatar

    This comment has been hidden.

  • DemonKing Avatar

    This comment has been hidden.

  • Hallowizer Avatar

    Won't work.

  • spcbrn Avatar

    Great kata! I'd love to know how you disabled prototype methods in your test environment.

  • missKatiaPunter Avatar

    One of the most exciting katas to have solved. The best thing is - you are better off not knowing Array prototype methods to do it.

  • GeorgeGkas Avatar

    This comment has been hidden.

  • rasjani Avatar

    This comment has been hidden.

  • Tefferson Avatar

    Had some problems with false, but it is ok now. Good kata, I liked! :)

  • bkemper Avatar

    It's a bit easy when using destructuring to swap array elements...

  • lkurylo Avatar

    Please point out that the JOSN.stringify is not allowed also.

  • Aquila Avatar

    I think the kata description should be updated to say no regex. I originally wrote a solution using String.prototype.replace (which isn't an Object or Array prototype method) only to find on submission that replace isn't allowed.

    I enjoyed this kata, otherwise.

  • brunolm Avatar

    You are NOT allowed to use any temporary arrays or objects.

    I'm not entirely sure what it means exactly by not allowed to use temporary objects. Am I allowed to use temporary vars to store Number? (e.g. let x = array[i - 1])

  • koop22 Avatar

    I broke my brain )))

  • roya3000 Avatar

    awesome kata)))

  • hbakhtiyor Avatar

    However, you can still use the methods of an array, and can't resolve with the Regex.

    arr['slice'](i, 1)[0]
    arr['re' + 'du' +'ce'](i, 1)[0]
    

    You can use monkey patching method to built-in objects.

    I posted to the gist, and you can use it.

  • CodeVortex Avatar

    My two cents for this kata are:

    1. it is in bad need of renaming. Its current name ("removeZeros") is completely misleading as the intention of the process is merely shifting "zero" designated elements to the end of it. "shiftZeros", "moveZeros" or "trailZeros" would be way more appropriate names.

    2. it clearly does not belong in the 4kyu league. It should be at least 5 or 6. It is way too simplistic, even with all the non-sensical restrictions - like not using built-in language features (i.e. Array.prototype functions), reason of which brings us to:

    3. most of the constraints do not make any sense, do not benefit the kata in any way, and more importantly, cannot be strictly asserted by tests. Conformity is at the mercy of any warrior's willingness or morals.

  • amhed Avatar

    I feel this kata didn't help me advance in any way

  • computerguy103 Avatar

    This comment has been hidden.

  • trekforever Avatar

    This comment has been hidden.

  • parabola949 Avatar

    This comment has been hidden.

  • ooflorent Avatar

    This comment has been hidden.

  • XxxX88 Avatar

    there are lot of bugs in this kata, remove it

  • marutiborker Avatar

    This comment has been hidden.

  • laurent.malvert Avatar

    This comment has been hidden.

  • anhkind Avatar

    Can you help to check if something is wrong? I always get 'Code timed out' even my code passed a lot of tests ...

  • wthit56 Avatar

    Very restrictive without any word of it in the description. I'm not even sure why some of the restrictions are there. (.toString()?!)

  • wthit56 Avatar

    It's quite amusing that the comments given as part of the Solution Setup makes the test fail. I had similar problems trying to figure out how to stop people using built-ins. I resorted to setting all prototype methods to null, so it would throw an error that way.

    I can't really figure out how we're meant to solve this kata, though... Without even splice, or using temporary objects, we have to move all the items along every time we want to take out one of the zeros; is that right? Or a I missing something?

  • jpotapova Avatar

    I had word 'finding' within my comment block and this made my code fail with the following message: 'Array.prototype.find is prohibited'. I guess it should be allowed to use this word inside comments? Other than that - great!

  • OverZealous Avatar

    It's too bad this is the exact same thing as this kata, only with the limitation to not use built-in language features or temporary arrays.

    It would be nice if it had something more to it to differentiate it better, but I suppose it's technically different.