Ad
  • Default User Avatar

    This comment is hidden because it contains spoiler information about the solution

  • Custom User Avatar
  • Default User Avatar

    You need chars() to safely iterate UTF characters of a str. Strings are always UTF-8 encoded, so accessing the bytes directly would be problematic. The collect() at the end consumes the Iterator into a String.

    For better functional composition, a more flexible signature would be:

    fn no_space(x: impl IntoIterator<Item=char>) -> impl Iterator<Item=char>
    

    This way you could pass any iterable into the function (including str.chars()), and chain the function lazily, without allocating a String for output.

  • Default User Avatar

    I believe in you, WarriorZero

  • Custom User Avatar

    I suggest to generate the first 10..20 elements or so with your code, and then examine it. You may notice a certain pattern... If so, try to make use of it somehow.

    Cheers

  • Custom User Avatar

    This is an algorithm kata. So an efficient algorithm is required.

    From the looks of it, it suggests nothing but that you're simply not capable enough for this kata.

    My only suggestion is that you shouldn't be attempting this kata in the first place (because of the huge skill mismatch), and you should go try something else.

  • Custom User Avatar

    I'm afraid you might really need to train your reading comprehension skills before training on more katas.

    The descriptions are perfectly clear for the rest of the people, so it's just you.

  • Default User Avatar

    look at the examples!

    pos = positions / peak = value