Ad
  • Custom User Avatar

    Hmm I forgot to put a sequence.reserve(n+1);

  • Custom User Avatar

    Proof?
    The semantics is exactly the same, and compiler is excellent at figuring out this kind of things.

    Edit: I tried to compile this version and the same with switches instead of if-else. On my compiler (gcc7.3.0) both versions compile to the exact same instruction sequence.

  • Custom User Avatar

    python,thanks.

  • Custom User Avatar

    You're welcome. CodeWars is not perfect, but it really teaches you a lot more that it seems at first sight. :)

  • Custom User Avatar

    Nvm, my bad actually. I'm discovering CodeWars platform and still getting used to it.
    Thanks for the lightning-fast reply.

  • Custom User Avatar

    What "it" should be part of the instructions?

    If you mean the idea to print your output carefully, than please note that this is not an issue with this kata, but a generally good debugging practice that every code warrior learns at some point, as it is a general issue of the CodeWars platform.

    If two things look equals but do not compare, probably they're not equal, and learning to find out how so is a useful programming experience.

  • Default User Avatar
  • Custom User Avatar

    Okay that did it, thanks!
    It should be part of the instructions imho.

  • Custom User Avatar

    Extra spaces before or after the code should be ignored, yes, as stated in the kata description.
    And yes, extra_zeros_handling() test checks this aspect exactly.
    I'm leaving it to you to guess how extra zeros are connected to extra spaces.

    As of your problem, I would suggest printing the output of your function carefully using repr(), or hexlify() (these two examples are for Python), or some other way in the language you use, or maybe wrap your output in <pre> tags to make sure HTML output console does not corrupt your printing.

  • Custom User Avatar

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