Ad
  • Custom User Avatar

    I've just checked it, and according to this SO question starting from C++ 11 string are immutable objects (as I thougt from the beginning).

    Trying using int -> string conversions and string concatenation instead.

  • Custom User Avatar

    I totally agree with your logic, copying your example in its entirity and using the g++ compiler runs and produces the correct result without issue.

    This is certainly an issue with how the code is compiled/run in the Kata environment, and not a product of the kata itself.

    I will mark this as resolved for now, but please feel free to continue the discussion :)

  • Custom User Avatar

    You can add char and int because char is int (partially).

    I'm not sure, but I have an insane theory that after mutating the string like you are doing, something really bad happens to it. Try using working with a string as if it was a string (and not a char array (duh)), and I think it may work then.

  • Custom User Avatar

    This is your issue:

    out[8] = '0' + result % 10;

    You are trying to add together a character and an integer.

    Please let me know if your solution works and I will mark this as resolved.

    Ps. The way that you are checking for the instruction is clever!

  • Custom User Avatar

    Could you share what you have? Mark it with a spoiler flag please thanks!

  • Default User Avatar

    I've rewritten the solution again.

    Note that the answer in your example is actually 22 : you forgot to count a 'v'.

  • Default User Avatar

    I think you are still on the old reference solution, in which there was a typo. You may want to save your solution and reset the kata to get the new reference solution.

  • Default User Avatar

    When you pose a question about your code don't post an issue - which makes the author lose honor - simply label your post with "Question".

  • Custom User Avatar

    Yes, they are indeed collinear. (1, 0, 4) cuts the line segment formed by (-7, 0, 0) and (5, 0, 6) in a 2:1 ratio:

    • (1 - -7):(5 - 1) === 8:4 === 2:1
    • y1 === y2 === y3 === 0
    • (4 - 0):(6 - 4) === 4:2 === 2:1