Ad
  • Custom User Avatar

    Same issue. Where:

    1. One number has more digits, and
    2. That number has an MSD of 9, and
    3. A carry causes that MSD to itself carry

    the final carry is ignored when counting; it shouldn't be.

  • Custom User Avatar
  • Custom User Avatar

    I'm using JS too, thanks for looking into it

  • Default User Avatar

    ̶T̶h̶e̶ ̶l̶a̶s̶t̶ ̶o̶n̶e̶ ̶i̶s̶n̶'̶t̶ ̶a̶ ̶c̶a̶r̶r̶y̶,̶ ̶y̶o̶u̶ ̶d̶o̶n̶'̶t̶ ̶c̶a̶r̶r̶y̶ ̶w̶h̶e̶n̶ ̶t̶h̶e̶r̶e̶ ̶a̶r̶e̶ ̶n̶o̶ ̶n̶u̶m̶b̶e̶r̶s̶ ̶l̶e̶f̶t̶ ̶t̶o̶ ̶c̶a̶r̶r̶y̶ ̶t̶o̶,̶ ̶y̶o̶u̶ ̶j̶u̶s̶t̶ ̶a̶d̶d̶ ̶i̶t̶.̶

    edit: actually looking in to it, you're right it should count it as a carry

  • Default User Avatar

    Getting the same issue. My code fails at specific tests. These are tests where one number has more digits than the other, where the longer number begins with 9, and where that 9 would have a carry operation applied to it. My code gets the mathematically correct result, but the test expects one less.

    Either the description isn't informatve enough to tell you to ignore cases like this, or the expected results are wrong. I could throw together something that solves the kata by getting incorrect results, but I'd really rather not do that on principle.

    Should note that I'm using JavaScript in case this is not a problem for other languages.

  • Custom User Avatar

    I have trouble with one random test :

    89953 922317
    which is supposed to output 4
    I don't see how it can be, I find 5 when I run it by hand. It would be 4 if the carry was not counted in one of the operation which would be incorrect.

    log of the operations :

    3 7 +1
    carryValue 1
    carries 1

    5 1
    carryValue 0
    carries 1

    9 3 +1
    carryValue 1
    carries 2

    9 2 +1
    carryValue 1
    carries 3

    8 2 +1
    carryValue 1
    carries 4

    0 9 +1
    carryValue 1
    carries 5

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

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

  • Custom User Avatar

    I'm not convinced that this problem deserves an array and an additional function, looks trendy for sure but not allocating that much memory could be more reasonable.