5 kyu

Moving Zeros To The End

77,805 of 192,073xcthulhu
Description
Loading description...
Arrays
Sorting
Algorithms
  • Please sign in or sign up to leave a comment.
  • smckaysmalley Avatar

    Would be appreciated to leave some detail about what the full test suite tests in the kata description. Even if it's only a statement that says to expect that the input could contain any data type.

  • Zlata Brain Avatar

    Great kata, but it is too easy for 5 kyu :)

  • Shawn402022 Avatar

    This comment has been hidden.

  • aryav-hash Avatar

    I think this testcase is wrong

    expected [ 'a', 'b', null, 'c', 'd', 1, 1, 3, 1, 9, {}, 9, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0 ] to deeply equal [ 'a', 'b', null, 'c', 'd', 1, false, 1, 3, [], 1, 9, {}, 9, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0 ]

    In the first array there is no 'false' however the second array has a false for some odd reason. There is also not a square bracket in the first array, however there is one in the second array. Can you help me out ?

  • big_M Avatar

    move the zeros to dart Translation Dart

  • Abhaykap Avatar

    too easy, it should be 7 kyu

  • evan.kroz Avatar

    This comment has been hidden.

  • PythonLatte Avatar

    Hey there! This is a great kata, but I, personally, believe that the kyu for it should be decreased a bit, as it is a bit less complicated/simpler than most other 5 kyu challenges. Other than that, though, it's a wonderful kata! Keep on creating :)

  • lezeroq Avatar

    Would it make sense to ask in the Details to solve it in place without allocating additional space for a copy of input? So the problem is really 5kyu.

  • janAkali Avatar

    Nim translation
    Can somebody review and approve it, please.

  • Flolopppi Avatar

    "expected [ 1, 2, +0, 1, +0, 1, +0, 3, +0, 1 ] to deeply equal [ 1, 2, 1, 1, 3, 1, +0, +0, +0, +0 ]"

    the log in my console when i hit "test":

    test Log [ 1, 2, 1, 1, 3, 1, 0, 0, 0, 0 ]

    wtf is wrong lol

  • M0hanrajp Avatar

    very good kata !

  • ixPost Avatar

    It was easy for me even tho I'm 7kyu. The 6kyu kata here: https://www.codewars.com/kata/search/my-languages?q=&beta=false&order_by=satisfaction_percent%20desc%2Ctotal_completed%20desc was also easy. While most of the 7kyu katas I did were hard for me.

  • Jasmik Avatar

    This comment has been hidden.

  • denis-codewars18 Avatar

    I don't understand what is wrong expected [ 9, +0, 9, 1, 2, 1, 1, 3, 1, 9, +0, +0, 9, +0, +0, +0, +0, +0, +0, +0 ] to deeply equal [ 9, 9, 1, 2, 1, 1, 3, 1, 9, 9, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0 ]

    +0 what is this?

  • Timeon1 Avatar

    Actually,it's a easier than 5kyu problem, 7ky is enough

  • cestxvcdim Avatar

    So, this problem actually easy for 5 kyu. But if you tried to solve this O(N) and no extra memory, it feels like 5 kyu.

  • Seisuke22 Avatar

    expected: [true, "9", 8, "8", "8", nil, 1, 6, "2", 7, 3, nil, 5, true, nil, "1", "1", "0", "8", "1", 2, "5", "8", [], 0, 0]

    does the test includes other data types?

  • ivozayas Avatar

    A lot of examples are wrong, this site is awful

  • Mstanton98 Avatar

    Agree that this should be a 7 or 8 kyu. Solved in a language agnostic way but I imagine many languages have sorting functions that can essentially one line this.

  • IreneVolodko Avatar

    Super easy kata. Should be an 8 kyu

  • 0xsweat Avatar

    Why is this a 5 kyu instead of an 8 or 7 kyu?

  • LucaBmaster Avatar

    This comment has been hidden.

  • Ben Claw Avatar

    I solved this kata in C and Rust, and I have a question. Why does the function in C mutate the array in place, but in Rust it requires to create a new vector? In Rust, we can use mutable slice to change data in place as well:

    fn move_zeros(arr: &mut [u8]) { todo!() }

  • jadeboy33 Avatar

    This comment has been hidden.

  • GeorgeOkumu Avatar

    Can this be moved to Kyu 7?

  • GeorgeOkumu Avatar

    Can this be moved to Kyu 7?

  • iAmNsengi Avatar

    This comment has been hidden.

  • Dariusz255 Avatar

    nice kata, but this is too simple for 5. Maybe 7?

  • jpbhdrey Avatar

    I got stuck in this test case:

    for array:
    {0, 1, 0, 2, 0, 3, 4, 5}
    expected:
    {1, 2, 3, 4, 5, 1, 2, 3}
    

    which is clearly wrong...

  • D_user Avatar

    Should be 7 or below tbf

  • tomask272 Avatar

    Fine Kata for Golang learner like me, but why 5Kyu? :) Anyway thanks a lot :)

  • michalkmet Avatar

    Example of incorectly failing test for javascript (please see the empty array in the right) expected [ 'a', 'b', null, 'c', 'd', 1, false, 1, 3, 1, 9, {}, 9, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0 ] to deeply equal [ 'a', 'b', null, 'c', 'd', 1, false, 1, 3, [], 1, 9, {}, 9, +0, +0, +0, +0, +0, +0, +0, +0, +0, +0 ]

  • jkimbell Avatar

    Did an earlier version test for False not counting as literal 0, or maybe it was mentioned in the directions? I don't see that, but some of the solutions account for it

  • AndydeCleyre Avatar

    The tests for Factor 0.99 try to USE: math.ranges, which is renamed in that version to ranges, so the tests won't run successfully.

  • exemok Avatar

    preserving the order of the other elements.

    Can't undertand the behaviour of 0.0 - why should it be 0, but 0.0 in result array.

  • Ibraispotato Avatar

    it should be 7kyu

  • vinzmoke-zoro Avatar

    This comment has been hidden.

  • vinzmoke-zoro Avatar

    When I do it in my ide all 0 goes to end but here in my attempt, one zero is less at the end in random test case.

  • caiosouza15 Avatar

    This comment has been hidden.

  • Hedgerock Avatar

    Good kata but a little bit overrated. Guess 6 is a good enough :)

  • Kazgarot Avatar

    Could you please tell me what is wrong with my solution? When I run it in Chrome or Mozilla everything checks out...

  • sfcsarah Avatar

    This comment has been hidden.

  • lake5000 Avatar

    This comment has been hidden.

  • bibo242 Avatar

    This is too easy.

  • Timofey1234567890 Avatar

    Two Go tests are not written correctly when they have already changed

  • saudiGuy Avatar

    python new test framework is required. updated in this fork

  • smokey44 Avatar

    This comment has been hidden.

  • Adi Panchal Avatar

    I think this question is too easy for a 5 kyu. Perhaps a 7 kyu.

  • FanStaF Avatar

    In PHP the second test includes 0.0 in its values: $this->assertSame([9,9,1,2,1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0], moveZeros([9,0.0,0,9,1,2,0,1,0,1,0.0,3,0,1,9,0,0,0,0,9]));

    the digit 0.0 are counted as a zero but expected to be a single zero after moving to the end. All tests will pass if a single 0 is added to the end for any digit that evaluats as 0 (including 0.0).

  • Mendo94822 Avatar

    This comment has been hidden.

  • AlexGuignard Avatar

    This comment has been hidden.

  • crztssr Avatar

    All Test Cases (except one) for Go are incorrect.They are not presserving order of not zeroes values

    Expected
        <[]int | len:20, cap:20>: [5, 6, 8, 1, 7, 3, 1, 9, 0, 1, 0, 0, 0, 0, 9, 0, 0, 0, 0, 0]
    
    to equal
        <[]int | len:20, cap:20>: [5, 6, 7, 8, 1, 1, 3, 1, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]
    
    
    Expected
        <[]int | len:7, cap:7>: [1, 2, -1, 0, -2, 1, 0]
    
    to equal
        <[]int | len:7, cap:7>: [1, -1, 2, -2, 1, 0, 0]
    
  • Cakekaku Avatar

    Doing this in C, passed all sample tests. Then did it on Random Tests and it crashed on the second one with:

    "Test Crashed

    Caught unexpected signal: 6"

    "STDERR: free(): invalid pointer"

    I checked the inputs from the random tests to see if my checks just didn't catch something but it seems to be fine. I also checked my outputs to see if they weren't doing anything weird and it seems to be fine as well.

    I originally assumed it crashed on the end of the first random test but it still executed code after the array mutation. The error seems to appear either after return from the first random test or immediately after the second random test is sent in because it wouldn't even execute the first command which was just a print command so I can't even check if the test inputs are the problem or not.

  • NodirbekMatchanov Avatar

    any test case wrong check pleas. input array and result array do not match input array Array ( [0] => 9 [1] => 0 [2] => 0 [3] => 9 [4] => 1 [5] => 2 [6] => 0 [7] => 1 [8] => 0 [9] => 1 [10] => 0 [11] => 3 [12] => 0 [13] => 1 [14] => 9 [15] => 0 [16] => 0 [17] => 0 [18] => 0 [19] => 9 )

    test array in test case ( 0 => 9 1 => 0.0 2 => 9 3 => 1 4 => 2 5 => 1 6 => 1 7 => 0.0 8 => 3 9 => 1 10 => 9 11 => 9 12 => 0 13 => 0 14 => 0 15 => 0 16 => 0 17 => 0 18 => 0 19 => 0 )

  • ChinmaySahu10 Avatar

    This comment has been hidden.

  • StantStantov Avatar

    This comment has been hidden.

  • JosephPBallantyne Avatar

    it is 5kyu if you solve it by altering the existing array, and not creating a new one

  • vzakysillo Avatar

    This comment has been hidden.

  • mynoxys Avatar

    too easy for a 5 kyu it is a 7 or 8 kyu level

  • DeNöff Avatar

    Wait, in the description it says stuff like "a" and false indicating an object() array. But in the code it takes an integer() as argument. It would make it a bit harder actually, which cant hurt this one.

  • notabot444 Avatar

    This should be 7 or 8kyu tho

  • bdcrisco Avatar

    This comment has been hidden.

  • ryanlkl Avatar

    Does anyone know if it mattered if I made a new array insteadof altering the input? If it didn't then they kyu for this should be atleast 7, 6 at a push

  • danielpopek94 Avatar

    It's maybe 6kyu. So easy

  • deadcode666 Avatar

    This comment has been hidden.

  • Dagur624 Avatar

    This comment has been hidden.

  • dawitstibebu Avatar

    This comment has been hidden.

  • gwynbleiddddd Avatar

    This comment has been hidden.

  • Zone_OTP Avatar

    This comment has been hidden.

  • LothricYoungerPrince Avatar

    У меня сделано правильно, но ничего не работает. Что то вы напутали. Даже пытаться разобраться не буду. Я уверен на сто тысяч миллиардов миллионов процентов, что я прав. Исправьте ошибку.

    Upd: Посмотрел решение, у меня такое же почти(Я не использовал тернарный оператор). У меня пропадают false в ненкоторых случаях. Upd2: Добавил третий знак ровно, всё заработало. Бред. Так сказать, приношу свои извинения. Но по сути я всё равно сделал правильно.

  • norvalbv Avatar

    Should be 7 kyu lol

  • balt2021 Avatar

    This comment has been hidden.

  • OmarMohammedFoad Avatar

    Kata 5 ? really

  • mayevskaya Avatar

    File "/workspace/default/tests.py", line 7 [1, 2, 0, 1, 0, 1, 0, 3, 0, 1]),.
    ^ SyntaxError: invalid syntax

  • Viltho Avatar

    This comment has been hidden.

  • Fidget836 Avatar

    Hi, my code works but depend of the length of the table int, i have a "Test Crashed Caught unexpected signal: 6" "STDERR free(): invalid pointer" Exemple : For "int arr5[] = {0, 9, 5, 4};" that don't work but For "int arr5[] = {0, 9, 5, 4, 4};" that work. Do you have an idea where is the problem ?

  • jpssj Avatar

    Scala.

    Is it an oversight that the types of the lists aren't specified in the solution setup, or is it deliberate?

    def moveZeroes(lst: List): List = ???
    
  • darkcedar Avatar

    I don't think that it cousts 5 kyu

  • ejini战神 Avatar

    NO random tests in CS (at least)

  • ejini战神 Avatar
    • Description should be language-agnostic

    • Should mention that whether "0" is considered as zero, since a lot of solutions in various languages do not consider this part, but somewhat passes the tests.

  • ejini战神 Avatar

    Ruby

    • Function name should be snake_case
  • Voile Avatar

    Negative numbers are missing from the input in at least several language versions. Is this needed? If not this constraint should be removed; random tests in different languages are doing their own thing in deciding whether negative numbers should be included in the input.

  • Feston229 Avatar

    In Python returns that bullshit:

    Traceback (most recent call last): File "/workspace/default/tests.py", line 3, in Test.describe("Basic tests") NameError: name 'Test' is not defined. Did you mean: 'test'?

  • alamagaboy Avatar

    Why not to explain that we should move only zeros as a number? Stupid kata

  • nazmieievilya Avatar

    Feels like 7 kyu kata

  • catmikaaa Avatar

    This comment has been hidden.

  • kodzanse Avatar

    ok guys I see a lot of controversy and kind of I'm starting to feel a bit frustrated with this kata. pls someone explain to me this. since when this is correct test result ? [ 9, +0, 9, 1, 2, 1, 1, 3, 1, 9, +0, +0, 9, +0, +0, +0, +0, +0, +0, +0 ]

  • Oscarlosg Avatar

    This comment has been hidden.

  • Def3p Avatar

    This comment has been hidden.

  • bhaskersanil Avatar

    This comment has been hidden.

  • Serega5j Avatar

    This comment has been hidden.

  • monkey_on_a_keyboard_1 Avatar

    This comment has been hidden.

  • UniverseNature Avatar

    This comment has been hidden.

  • TerryaDzi Avatar

    I think many people didn't understand the kata and kata's description. I think in this kata id of lst must be the same at the end of function. So, most of all solution is wrong.

  • Narek66 Avatar

    it's exactly 5 kyu?

  • mohammadmahdimoniri Avatar

    This comment has been hidden.

  • ilya-smut Avatar

    This comment has been hidden.

  • Rideuz Avatar

    Very helpful!

  • Runy Avatar

    This comment has been hidden.

  • xavierguihot Avatar

    The Scala translation doesn't provide a correct function signature in the solution set-up:

    It should be: def moveZeroes(lst: List[Int]): List[Int] = ???

  • Brodan247 Avatar

    This comment has been hidden.

  • VKonev Avatar

    Something wrong! My code is working, but the tests are adding extra 0 after results, please fix it. And don't tell there is problem with my code, because I've checked it with the same tests in console and it's working, but kata sais that it's wrong! It's bad I can't send screenshot here

  • user1378050 Avatar

    hi there. i can't understand in what is my problem. In instruction of task There isn't anything about "[]","{}"have to be in the end of arr. What's wrong?? and so, in attempt i have a bad result, cause expected [ 'a', 'b', null, 'c', 'd', 1, 1, 3, 1, 9, {}, 9, 0, 0, 0, false, 0, 0, [], 0, 0, 0, 0, 0 ] to deeply equal [ 'a', 'b', null, 'c', 'd', 1, false, 1, 3, [], 1, 9, {}, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ]

  • ibbqcats Avatar

    This comment has been hidden.

  • rad_the_hero Avatar

    This comment has been hidden.

  • Roiqk7 Avatar

    When I run my C++ solution I get this: Exit Code: 132 Can someone explain what it means and how to fix it?

  • user347264 Avatar

    This comment has been hidden.

  • vikatiurne Avatar

    This comment has been hidden.

  • AlaaTarek898 Avatar

    expected [ 9, 9, 1, 2, 1, 1, 3, 1, 9, 0, 0, 0, 9, 0, 0, 0, 0, 0, 0, 0 ] to deeply equal [ 9, 9, 1, 2, 1, 1, 3, 1, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0 ] this is run perfect in visual studio code what is the problem here!!!!!!!!!!!!!!!!!

  • E-Codes Avatar

    The test case isn't not helpful. Please add empty arrays and empty objects in your own program.

  • E-Codes Avatar

    Did anyone else not recieve any points for completing this Kata? I did not check solution.

  • mohammad-amin-safaei Avatar

    This comment has been hidden.

  • livxy Avatar

    This comment has been hidden.

  • yavorant Avatar

    This comment has been hidden.

  • jeffjoseph Avatar

    i tried to get the index of the list but i am getting like this

    0 1 2 0 2 0 2 7 2 0

  • FortunateSmith Avatar

    Anyone else have the issue of tests failing but when running the test in VS code it passes?

  • Piero Lau Avatar

    This comment has been hidden.

  • A.Mahler Avatar

    You should show test data, so I can see myself where is the error. On my data everything is working. The message below doesnt told me anything, I can't see your array. Is it that hard to add 1 line of random test data that can't pass through my function? How can I fix it then?

    • Test Failed
    • Expected and actual are both <System.Int32[65]>
    • Values differ at index [1]
    • Expected: 5
    • But was: 3
  • s4ra Avatar

    This comment has been hidden.

  • skanw Avatar

    not sure why the second test is throwing errors, my code passes the other tests.

  • cuadchris Avatar

    Being new to programming I've kind of stood away from katas that are 6kyu and below. Is this the easiest 5kyu on this site? lol.

  • FirePicaso Avatar

    loved this kata

  • centeroftheuniverse Avatar

    This comment has been hidden.

  • okutewonah Avatar

    I get this error on Python; NameError: name 'Test' is not defined. Did you mean: 'test'?

  • meazes Avatar

    Cool task! I don't know how others have it all counted for me

  • Dibyanath6 Avatar

    I tried this for python. Code worked fine in jupyter but here saying incorrect

  • akar-0 Avatar
  • ben2003 Avatar

    The solution of others will always remind my identity as a baby in coding (>﹏<). But this kata gives me a chance to derive a variation of insertion sort, so I will give 8 / 10 for this kata. XD

  • Art.ka.9494 Avatar

    This comment has been hidden.

  • bennewton91 Avatar

    Slightly easy for a 5 kyu. I'd have given it a seven, personally.

  • GabVlado Avatar

    SUGGESTION IN DESCRIPTION

    1. The function will be return an "array", not only transform the actual array
  • akar-0 Avatar
  • Unnamed Avatar

    This comment has been hidden.

  • Joacob20 Avatar
  • vrx- Avatar

    This comment has been hidden.

  • Naman-Kapoor26 Avatar

    I feel the question should have specified inplace shifting the zeros at the end in a single loop, it would have made it slightly more challenging.

  • arthur08 Avatar

    This comment has been hidden.

  • akar-0 Avatar
  • kasym0055 Avatar

    Very easy kyu.It should be 6 kyu

  • Swag_Legend Avatar

    bruh serious over-ranking issue..

  • Swag_Legend Avatar

    akar-0 my rank is not increasing what to do?

    i am not getting promoted from 5kyu to 4kyu

  • Swag_Legend Avatar

    This comment has been hidden.

  • jenso413 Avatar

    I can see how this would be easy if you thought of a certain way of doing it off the bat, but as someone who did not, it was quite frustrating lol. Good challenge though

  • santiceron023 Avatar

    Golang tests are not ok, please solve it

    Sample: original [1 2 0 1 0 1 0 3 0 1] Expected solution [1, 2, 1, 1, 3, 1, 1, 1, 1, 0, 0, 0, 0] REal solution [1, 2, 1, 1, 3, 1, 0, 0, 0, 0]

  • AbdulSalphan Avatar

    I'm doing this with PHP. Everything fell into places except that my null and boolean values are considered zeroes. Probably a datatype error from my side. Any reference from where I can learn to solve this?

  • Vianou Avatar

    This must be the easiest 5kyu. Atleast, in C++. :-)

  • aroch17 Avatar

    This comment has been hidden.

  • yuriydetsyk Avatar

    This one was weird :D I spent like 1 min to complete it, and after seeing the end solutions I got a bit surprised, why all of them were so complex :\

  • kayibea Avatar

    This comment has been hidden.

  • Unvares Avatar

    I'm not sure if I wrote new Best Practices, but if I did, I would appreciate if you voted up the solution, so others can see it.

    https://www.codewars.com/kata/reviews/52597aa56021e91c93000cb3/groups/62496945be5665000101ca94

  • alex14vdk Avatar

    I think it's too easy for level 5

  • Edgehead888 Avatar

    This comment has been hidden.

  • thmz Avatar

    I'm stuck (at the JavaScript version) and am not sure what's the matter. Getting everytime errors in the random test cases, for example:

    expected [ null, '4', 1, 9, true, null, 9, [], '7', '8', [], null, '4', 1, 3, '0', 0 ] to deeply equal [ null, '4', '0', 1, 9, true, null, 9, [], '7', '8', [], null, '4', 1, 3, 0 ]
    

    My console output says the content of my result variable is [ null, '4', 1, 9, true, null, 9, [], '7', '8', [], null, '4', 1, 3, '0', 0 ] which is the right answer if i understood the task correctly. So does the test possibly have a wrong expectation?

  • Razvan StCr Avatar

    i shouldn't have to deal witht this shit... seriously... all I do is copy-paste from Kata's "example arrays" and suddenly my array is a string. it's been 2 hours, i deleted my code 6 times, just because of this, it's not fair.... it's just not... if i were stupid and the code would be my fault, i would understand, but having EVERYTHING break because I copy-pasted the sample arrays is just not fair to my time and energy.

  • Razvan StCr Avatar

    Can someone please explain to me how the heck is this a string? x = [1, 2, 0, 1, 0, 1, 0, 3, 0, 1]

    The one below, is NOT a string, but the one above is a string, How is that even possible? x = [9, 9, 1, 9, 9, 9, 9, 9, 9, 9, 7, 4, 0, 0]

    Python, you're drunk...

  • radlisowski Avatar

    This comment has been hidden.

  • tema7198 Avatar

    expected '["a","b",null,"c","d",1,1,3,1,9,{},9,0,0,0,0,0,0,0,0,0,0,0,0]' to equal '["a","b",null,"c","d",1,false,1,3,[],1,9,{},9,0,0,0,0,0,0,0,0,0,0]'. Execuse me, but where the hell false and empty array in expected result comes from? If to look at this accurately, it is false among 1 and 1 after "c" and "d" appeared and empty array between 3 and 1 latter. I guess the test machine is totally broken or exactly this kata's test contains bugs. I suggested 3 approaches and my last one shows me expected some pretender values in the result...

  • rafalzw Avatar

    There is something wrong with this testing:

    moveZeros([1,2,0,1,0,1,0,3,0,1])

    expected '[1,3,1,1,2,1,0,0,0,0]' to equal '[1,2,1,1,3,1,0,0,0,0]'

  • scriptures99 Avatar

    There is something wrong with this testing clause: a,0,0,b,,c,d,0,1,false,0,1,0,3,,0,1,9,0,0,[object Object],0,0,9

    there should be a , in the [object Object]? yet i get this error.. wth?

    expected '["a","b",null,"c","d",1,1,3,1,9,{},9,0,0,0,0,0,0,0,0,0,0,0,0]' to equal '["a","b",null,"c","d",1,false,1,3,[],1,9,{},9,0,0,0,0,0,0,0,0,0,0]'

  • skjp21 Avatar

    This comment has been hidden.

  • Nikos96 Avatar

    This comment has been hidden.

  • CreedCoding Avatar

    I dont know why I'm getting an error, actually, a timeout or whatever error, it's not even checking...I tried it on another compiler and it totally worked...it's not working here though!

  • adedude3 Avatar

    great kata! easy if you just want to solve it but cool if you want to practise a better way of solving a problem

  • Richard04 Avatar

    This comment has been hidden.

  • Maksim G Avatar

    hello brother, i get an error, everything is OK in the browser, please help <3

    expected '[9,9,1,2,1,1,3,1,9,0,0,0,9,0,0,0,0,0,0,0]' to equal '[9,9,1,2,1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0]'

  • kirilldonenko Avatar

    I run my function in jsfiddle and chrome console and get result - [9, 9, 1, 2, 1, 1, 3, 1, 9, 9, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0]. But test shows different result - [9,9,9,9,1,2,1,1,3,1,0,0,0,0,0,0,0,0,0,0]. WTF?

  • kirilldonenko Avatar

    This comment has been hidden.

  • D10n1x Avatar

    Instructions: Write an algorithm that takes an array and moves ALL OF THE ZEROS to the END, PRESERVING the order of the other ELEMENTS. Log arr: [ 9, 0, 0, 9, 1, 2, 0, 1, 0, 1, 0, 3, 0, 1, 9, 0, 0, 0, 0, 9 ]

    expected '[9,9,9,9,1,2,1,1,3,1,0,0,0,0,0,0,0,0,0,0]' to equal '[9,9,1,2,1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0]'

    Where in the instructions it says that 9 needs to be moved to the beginning, fix it

  • Paksat Avatar

    This comment has been hidden.

  • nerdess Avatar

    This comment has been hidden.

  • Ansh3r Avatar

    This comment has been hidden.

  • TheHizb Avatar

    This comment has been hidden.

  • pedrogalher Avatar

    I think this Kata should be a 6-7 kyu

  • weirdfishh Avatar

    Way too easy for a 5 kyu

  • mostwontiwill Avatar

    not a coding guru or anyone great for that matter, but i feel like this should be level 7...

  • SergeiNevostruev Avatar

    This comment has been hidden.

  • akar-0 Avatar
  • VukMar Avatar

    I can't get this one... In c++ I pass simple tests but random test it skips one 0,and i don't know why. Been looking at it for 2hours and cant find the solution. I do a loop trough vector and if it find a 0 it erases it and moves it to the end, but skips one 0 in random. Can someone help pls?

  • Vlasyuk_Anatoliy Avatar

    I wrote my solve with used methods of string without loops. Have solutions any limitations? Samples tests is rigth, but then: RangeError: Invalid count value. So litlle additional tests, difficult to investigate.

  • 604karev Avatar

    This comment has been hidden.

  • deepalisangole Avatar

    This comment has been hidden.

  • BoikoVD Avatar

    expected '[9,1,2,1,1,3,1,9,9,9,0,0,0,0,0,0,0,0,0,0]' to equal '[9,9,1,2,1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0]'

    Incorrect test. Fix it

  • Kitty? Avatar

    I would not say that this is a 5-kyu - maybe 6 at max

  • alliehardy  Avatar

    Expected: Array ( 0 => 9 1 => 9 2 => 1 3 => 2 4 => 1 5 => 1 6 => 3 7 => 1 8 => 9 9 => 9 10 => 0 11 => 0 12 => 0 13 => 0 14 => 0 15 => 0 16 => 0 17 => 0 18 => 0 19 => 0 ) Actual : Array ( 0 => 9 1 => 0.0 2 => 9 3 => 1 4 => 2 5 => 1 6 => 1 7 => 0.0 8 => 3 9 => 1 10 => 9 11 => 9 12 => 0 13 => 0 14 => 0 15 => 0 16 => 0 17 => 0 18 => 0 19 => 0 )

    The the above is my failed test...I am having trouble distinguishing 0 from 0.0 in my code using php. Cannot seem to figure this out. Any advice?

  • TwilightCurse Avatar

    Pretty simple for 5 kyu :D

  • JamalH Avatar

    The parameters are incorrect for the initial test. The directions explicitly state that all inputs are arrays. However, the second test input is a string moveZeros( "1,2,1,1,3,10,0,0,0" ) expected to return[1,2,1,1,3,1,0,0,0,0]

  • thommes Avatar

    This comment has been hidden.

  • Taliyah Avatar

    this one is actually not suitable to label as 5kyu, please put its rank down a bit

  • Houssam_ Avatar

    expected '[0,9,9,9,1,2,1,1,3,1,9,0,0,0,0,0,0,0,0,0]' to equal '[9,9,1,2,1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0]'

    That is wrong! Fix your Kata!

  • godunovofc Avatar

    expected '[1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0]' to equal '["a","b","c","d",1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0]' Where do these letters come from?

  • thomaspivaf Avatar

    this one is realy easy, should be 7 or 8 kyu

  • VictorHavran Avatar

    Hi! I've solved this problem in python and i get the correct output in vscode but not here for some reason. Could someone help me?

  • jpsingh82 Avatar

    This comment has been hidden.

  • zegermanguy1 Avatar

    This comment has been hidden.

  • mauro89x Avatar

    Hi, I don't understand the error here, after coding and passing the first test, the attemp before submitting is failing with the following error

    expected '["a","b",null,"c","d",1,1,3,1,9,{},9,0,0,0,0,0,0,0,0,0,0,0,0]' to equal '["a","b",null,"c","d",1,false,1,3,[],1,9,{},9,0,0,0,0,0,0,0,0,0,0]'

    is there an issue with the tests? or am i misunderstanding something? shouldn't be equal to the following --> [a','b',null,'c','d',1,1,3,1,9,{},9,0,0,0,0,0,0,0,0,0,0,0,0] This is what my code is returning.

  • Dennynic Avatar

    Hello! I dont understand. why if "moves all of the zeros to the end", give me an error: expected '[9,0,9,1,2,1,1,3,1,9,0,0,9,0,0,0,0,0,0,0]' to equal '[9,9,1,2,1,1,3,1,9,9,0,0,0,0,0,0,0,0,0,0]'. Nothing to say about 2 zeros one by one in [ 9, 0, 0, 9, 1, 2, 0, 1, 0, 1, 0, 3, 0, 1, 9, 0, 0, 0, 0, 9 ]. Why i should ignore second zero.