Ad
  • Custom User Avatar

    I agree, my initial code was written to remove the longest sequence of the predicate regardless of where it was in the sequence, not if it was just at the start.

    Example, if you have [2,5,6,7,5,9,8,9], and the predicate is odd numbers, my reading of the problem is that I look for the longest sequence of odd numbers ( [7,5,9] ), and remove it, returning [2,5,6,8,9].

    However, the kata tests that you remove the number of predicate only as they occur at the start of the Array..

    So, since this sequence starts with even, you would leave the array untouched and return [2,5,6,7,5,9,8,9].

    I am assuming I misunderstand the meaning of "longest prefix" as well.

    The confusion I think comes in when he calls for the "longest" prefix... but if prefix is only the inital numbers at the start, you will never have a longer and a shorter prefix... you can only have one prefix to be removed. When I read longest, I instantly went looking fot the longest continuous number of predicate values to remove.