6 kyu

Length of longest subsequence of same incrementing values

Description
Loading description...
Algorithms
  • Please sign in or sign up to leave a comment.
  • gabrielclavero Avatar

    I'm just another dude who got confused by the title and the description. I think the kata description should have '-1 -2 -3' as an example, same for '1 1 1'

  • sivisiviku Avatar

    i got this failed test message: Up and down: expected 7 to equal 4 what does it mean?

  • dfhwze Avatar

    Incrementation by negative values? A bit confusing, don't you think?

  • JohanWiltink Avatar

    Why are you passing in a string? Everyone is doing .split(" "), and this breaks for empty string, which does not resolve to empty array.

    Why not simply pass in an array?

  • wthit56 Avatar

    The description (and title) says increment. I took this to mean increasing, but you have tests where the values decrease (decrementing instead). Could you clarify this for me, please?

    • wthit56 Avatar

      Would really like to know the answer to this. I've submitted a valid solution, but I'm working on a more efficient version.

    • Elyx0 Avatar

      Yeah sorry, i could not find an easy title without making it sounds too complicated. I made it to be harder: adding positive numbers between each numbers in the chain was an already seen kata, it's better to think in terms of "same absolute step value between the members of the chain". So -1 -2 -3 would match.

      Question marked resolved by Elyx0 10 years ago
    • wthit56 Avatar

      So would -1 -2 -1 0 2 match also? The "absolute step value" would be 1 in all cases.

    • Elyx0 Avatar

      -1 -2 -1 0 2 will give 3 matched by -2 -1 0. You cannot be ascending and descending in the same chain for the step to work. So no, it won't match -1 -2 -1 0 as a valid chain of 4. I understand that it's tricky to explain. But a lot solved it like this so I thought it was clear. I hope this comment will help future readers.

    • wthit56 Avatar

      Okay, that's fine. The "absolute step value" threw me is all ;P

      To be clearer, I would recommend you change all the mentions of "incremeneting" to be more explicit in what you mean. That should fix everything up for future coders.

    • kolombet Avatar

      I am completly agree with with issue. It needs to be fixed, it messes up the task solving and make solutions hacky

  • wthit56 Avatar

    I'm passing all tests, but getting an error at the end:

    TypeError: Cannot read property 'length' of undefined
       at longestSequenceIn
    

    Not sure why it is happening or how to fix it?

  • OverZealous Avatar

    Please don't use Test.expect, use Test.assertEquals(«actual», «expected»[, msg]) instead, which automatically provides feedback.

    For example:

    Test.expect(longestSequenceIn("10 11") == 2,'Normal chain');
    

    becomes

    Test.assertEquals(longestSequenceIn("10 11"), 2,'Normal chain');
    

    This makes it easier for the solver to figure out what went wrong, rather than only getting a pass/fail response.

  • vferries Avatar

    You're missing simple cases for empty string or list containing only one element.