7 kyu

Broken sequence

1,527 of 4,401suuuzi
Description
Loading description...
Strings
Fundamentals
  • Please sign in or sign up to leave a comment.
  • SummerTheCoder Avatar

    JS should be updated to Node 18

  • l96alex Avatar

    This comment has been hidden.

  • Princess Aura Avatar

    The returning values are a bit confusing (1 when it's invalid and 0 when it's valid is the opposite of True and False in Python for instance) but I get it.
    What I don't get, is how a valid input with NO missing number should return 0 but an empty input should... also return 0?
    Especially since it is written in the description that we are looking for a sequence of integers starting with 1.
    According to the description, it should be either:

    • an empty sequence is not valid, since it doesn't start with 1
    • an empty sequence is valid but missing 1

    In both cases, the return value should be 1, not 0.

  • mate.sokol Avatar

    I'm begginer my test pass all except :

    test3Digitnumbers It must return 90 expected:<90> but was:<1>

  • Quark Fox Avatar

    Tricky, but nice Thanks suuuzi

  • Crazyandrey Avatar

    This comment has been hidden.

  • cliffstamp Avatar

    Haskell : https://www.codewars.com/kumite/5b9c4f9683c250ce66000122?sel=5b9c4f9683c250ce66000122

    (note the description needs to be fixed in the translation, I need to know how to do a default language).

  • fernode Avatar

    Unhandled rejection TestError: It must return 90 - Expected: 90, instead got: 10 Unhandled rejection TestError: It must return 90 - Expected: 90, instead got: 10

  • ScorpP Avatar

    misleading description

  • valeri.burlacu Avatar

    Hello !

    testShuffledInput It must work for a shuffled input expected:<1> but was:<0

    • who know what the Shuffled Input ?

    testFirstElementMissing It must return 1 for a sequence missing the first element expected:<1> but was:<0>

    • here must to be a number the first ? or what is the problem?
  • anter69 Avatar
    • misleading description ("sequence of positive numbers starting with 1, but one number is missing!" -- not true in many ways),
    • incoherent expected values (return 1 if invalid input, but also return 1 if valid input where 1 is missing)
    • insufficient specification (what to return e.g. for "1 2 2 3" ?)
    • insufficient testing (see previous point, plus no random tests in java)
  • user6206224 Avatar

    This comment has been hidden.

  • user6206224 Avatar

    all, except 1 test fail. all test listed below task code successfully passed, but during submit it doesn't work well.

    It must return 1 for an invalid sequence - Expected: 1, instead got: 0

    wtf is wrong?

  • user426930 Avatar

    I ran the sample test, my code passed all. But when I attempted the solution, all but one failed. I discovered that the one that failed is the number 8 in the sample test... "2 1 4 3 a" . but it didn't give any error in the sample test.

  • kaloudis Avatar

    The random test cases are terrible and contradict some of the other cases

  • hksong Avatar

    You should change the random test cases to test for missing numbers as well. All of them test for non-numeric characters at the moment which should also be changed to different types of non-numeric charactesr. Right now, it only uses 'a'.

    The first suggestion would test the code for finding missing numbers, and the second one would test for whatever code checks for non-numerics.

  • fgkramer Avatar

    I'm getting this error: "It must return 90 - Expected: 90, instead got: 2". Is there any chance to see the test input? All other tests pass, even the random ones. Thanks.

  • Sellitus Avatar

    There needs to be tests for unsorted number sequences, as I just had my mind blown while looking at other's final code who just iterated through the number sequence with no sorting. :)

  • robinmattheussen Avatar

    I seem to have some trouble understanding the failing test cases:

    testFirstElementMissing -> "It must return 1 for a sequence missing the first element". What does that mean? The description clearly states that it should return 1 only when the sequence is invalid (it contains a string with non numeric character). Also, what is the "the first element"? If the sequence is missing the first element, does that mean it is "empty"? Because the description says we should return 0 in that case.

    testShuffledInput -> "It must work for a shuffled input (expected 1)". I don't understand this either. You have written a test that checks if we can handle shuffled (I assume this means unsorted) input. However, you have written this test so that it expects 1, a result which is reserved for a sequence containing invalid characters. Surely if that is the expected result, you can't expect the input to be sortable?

  • zebulan Avatar

    This comment has been hidden.

  • ALYIP Avatar

    I voted 6 kyu , what do you guys think ?

    Fun kata by the way.

  • dinglemouse Avatar
    • What about some 2 digit numbers as input?

    • Also description says "Sequence may be shuffled" does not make sense to me. Check dictionary meaning of sequence

  • SeanSilke Avatar

    the random testing is broken.

    Testing for 16 9 4 20 18 12 8 1 7 14 3 13 10 2 17 5 19 6 15 21 It should work for random tests too: 1 should equal 11

    UPD: I was converting string to numbers. So this is my issu Nevertheless the description can be more clear for this case. Or use in random test non numeric characters.

  • pwdd Avatar

    Instructions could have mentioned case in which the missing number is the first of the sequence. Otherwise, everything looks good.

  • BartBee Avatar

    The description is clearly lacking, same goes for test cases. And while not a very difficult problem I don't think it should be tagged as #fundamentals

  • trungruoi Avatar

    !

  • bebraw Avatar

    Default tests weren't good enough. Maybe add a reversed list and a couple of other cases.

  • mlabrum Avatar

    This is very similar to http://www.codewars.com/kata/55eea63119278d571d00006a and while there are differences (this one deals with strings, unique numbers, and possibly invalid arguments; that one deals with lists of ints and possibly duplicate numbers), I wonder if they are enough to warrant two separate katas.

  • Ab_bh Avatar

    guys my code is running perfectly on IDLe....but the code is incorrect as per this code analyser...can anyone help i did on python

  • jmossel Avatar

    Should non valid squences really be part of this kata? It add just an ugly if statement, don't really see the point.

  • user7261034 Avatar

    I really enjoyed this kata, but I would add some examples of invalid sequences in the description. E.g.

    find_missing_number("1 a 2 5") # returns 1, because it contains a non numeric character

  • nick.strohl Avatar

    The description should mention something about the sequence not actually being sequential in the final tests.

  • sofiia-hlyniana Avatar

    Kata needs more specific explanation, e.g. what is invalid sequence

  • MarkPearlCoZa Avatar

    The description could be a bit clearer.

  • ru-lai Avatar

    Needs to be more clear on what random strings and shuffled strings are.

  • cero Avatar

    Problem definition is not complete. Invalid sequence is not defined. Test cases are not comprehensive enough.I can pass the tests but when I submit my code fails and I do not know why.

  • carlosromel Avatar

    Can anyone define "invalid sequence"?

  • bencodezen Avatar

    Needs to provide a test case for numbers greater than single digit since that is part of the actual tests when submitted.

  • ltoshea Avatar

    Liked that it made me think about manipulating different types like strings lists and sets. Didn't understand while my solution was failing with a ValueError - and still don't. Assume it was due to trying to cast a string as an Int but couldn't see that in the displayed test cases - maybe I missed it. If that is the case definitely add a test case in the bottom right to account for this. Overall could do with a bit of improvement but nice challenge.

  • Jotha Avatar

    C# translation kumited

  • hsheikhm Avatar

    description is too vague!

  • dncarter Avatar

    Instructions not entirely clear

  • vasekhlav Avatar

    I am trying to solve this kata in JavaScript and i got this error: "It must return 1 for a sequence missing the first element - Expected: 1, instead got: 0". What exactly is meant as the first element?

  • aiserid Avatar

    Not a clear definition of "invalid sequence"

  • garfunkel61 Avatar

    I was confused what 'invalid sequence' was. I would add an example of invalid sequence and a test for invalid sequence to basic tests.

  • katrinaofthewelsh Avatar

    I don't know what it means when it's asking for an invalid sequence.

  • stekern Avatar

    Vague description.

  • Phanton Avatar

    it is not clear in the description what an invalid sequence is. Is it one that jumps by more than 1 integer value or one with non-integer characters? This should be more explicit in the description.

  • nicangeli Avatar

    It wasn't immediatly obvious to me what a shuffled sequence meant.

  • RA_ Avatar

    im in ruby

    what defines an 'invalid sequence'

  • baaart Avatar

    The description is very short. It is hard to know what exactly end when should You return. There was no mention about validating strings (that it is possible other things then spaces and numbers and empty strings). Please make description a little bit more descriptive:)

  • Robin479 Avatar

    The description should be talking about "a shuffled set of numbers" right from the start rather than just "a sequence of numbers". It's confusing to read about shuffling only in the last sentence. There should also be a test case to verify/falsify the handling of shuffled sequences.

    The description is unclear about what is a legal input and what is not.

  • WWW21 Avatar

    Most of the problems have already been mentioned: unclear problem description, including unclear input and fringe cases

  • tikitariki Avatar

    It wasn't descriptive enough. I didn't know to expect the input to be an array until after I passed many tests.

    Another issue is that I wasn't sure if I was looking for interruptions in sequences. Knowing that it can be shuffled made sense once I started seeing tests (only after hitting Submit) having a jumble on numbers. That's when I realized I'm supposed to reorder them.

    I have no idea how to rate this Kata on difficulty because depending on what it is asking for, the difficulty varies. You can see how the vagueness can make that even more difficult.

  • user5926886 Avatar

    I keep getting this error even though all the tests pass:

    ValueError: invalid literal for int() with base 10: '_______'

    I can't even refer back to which line the error is being thrown

  • NoiSek Avatar

    Makes no mention of invalid input in the description.

  • voviarka Avatar

    I didn't kwow that sequence could be not only string but array, as well

  • pergk Avatar

    This comment has been hidden.

  • osofem Avatar

    I think the description should include that if a sequence starts with 2, the missing number is 1! The missing number could have been the +1 of the last number (according to your random test)

  • idubrov Avatar

    Lacks tests like "1 2 a3a 5" (should yield 1, as sequence is invalid)

  • MrSkrifle Avatar

    the unsorted random numbers required for the code to be changed from the orignal question

  • Joz Avatar

    The description is unclear. How order of the sequence affects... what is an invalid sequence and so on ( Thnx otherwise, it was rather interesting.

  • kobuswolf Avatar

    The description is slightly unclear (not bad but could have a bit more), nothing is said about the order of the sequence, which leaves you wondering if that factors in. Also, an invalid sequence is not defined, it might be worth mentioning what invalid means... at first I thought it could relate to order, or possibly multiple missing items or something.

    Easy once I knew what to do.

  • jms Avatar

    This comment has been hidden.

  • jms Avatar

    This comment has been hidden.

  • jms Avatar

    This comment has been hidden.

  • mercer Avatar

    Tests break with strict mode.

  • user3043623 Avatar

    Add a few more tests for randomized numbers and a return of zero if the numbers are already sorted.

  • vladlichonos Avatar

    This case fits description and will brake a lot of exisitng solutions. Case of shuffling numbers is not covered. I think below test case will cover it.

    @Test public void test5() { assertEquals("", 2, new BrokenSequence().findMissingNumber("5 3 4 1")); }

  • JustyFY Avatar

    It is not clear what a invalid case is pls be more specific does it mean the string contains more spaces or special char or just char....

  • Al-F Avatar

    Guys, I'd finally reached an impasse: I can't get throw the 7th test of submiting. Does anybody know what kind of sequence it has as an input for Java vercion of kata?

  • niklaus520 Avatar

    This comment has been hidden.

  • user4019457 Avatar

    I enjoyed this kata. My only advice would be to add a few more relevant categories so that it can be found easier ;)

  • JuanEiros Avatar

    This comment has been hidden.

  • oldccoder Avatar

    This comment has been hidden.

  • ChristianECooper Avatar

    This comment has been hidden.

  • fenekku Avatar

    The description states that the sequences start with 1, but the tests validate against sequences not starting with 1.

  • fighterleslie Avatar

    This comment has been hidden.

  • jtschoonhoven Avatar

    Random tests aren't working properly. It's currently asking me to return 0 for an invalid sequence, which the instructions claim should only be returned for an unbroken sequence.

  • bkaes Avatar

    Does it really need to be a string? That just puts another layer on top of it. Isn't an array or a list (depending on the language) sufficient?

  • ZozoFouchtra Avatar

    ...a string with no numbers and spaces _______

    Don't be so cruel !

    ...I will add more tests with invalid sequences.

    Too many invalid things ! Even in the description :

    An invalid sequence must return 1, an invalid sequence must return 0.

    What must an invalid sentence return ?

    (Ok, those sentences are not really invalid but you should admit there're not very very clear)

    And Grazie mille for the translation !

  • pablo.varela Avatar

    I would suggest to new extra sequences to test: 1 2 3 4 55 and a string with no numbers and spaces _______

  • chrisjudice09 Avatar

    the instructions need to be a little more desciptive as it pertains to of the string is empty or if it starts with something other than a 1

  • Sokas Avatar

    You forgot to say that the sequence increments by 1.

  • pablo.varela Avatar

    Now that the n is gone from the provided code, you could get rid of N=5 in the description.

    You have a sequence of positive numbers starting with 1, but one number is missing! Find out the missing number. If the sequence is not broken, you should return 0.

    Examples

    new BrokenSequence().findMissingNumber("1 2 3 5") // returns 4
    
    new BrokenSequence().findMissingNumber("1 2 3 4") // returns 0
    
  • MindWanderer Avatar

    This comment has been hidden.

  • simonharrer Avatar

    State that 0 should be returned when the passed string is empty.

  • pablo.varela Avatar

    Two minor issues:

    • It is not clear from the description that the function must return 0 if the sequence is not broken.
    • The parameter n is not necessary to solve the problem and I think it makes the description more confusing.

    Consider getting rid of that parameter and update the description with something like:

    You have a sequence of positive numbers starting with 1, but one number is missing! Find out the missing number.

    sequence = [1, 2, 3, 5]
    returns "4 is missing"
    
    sequence = [1, 2, 3, 4, 5]
    returns "this sequence is not broken!"
    
    sequence = []
    returns "this sequence is not broken!"
    
  • Tgc Avatar

    What n parameter is for?