Ad
  • Custom User Avatar

    Removed test with nullptr root.

  • Default User Avatar
  • Custom User Avatar

    Duplicate issue.

  • Custom User Avatar

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

  • Custom User Avatar

    C++ random test segfaults, but maybe you can submit your answer as C. Solution should be similar and C test doesn't segfaults.

  • Custom User Avatar

    The C++ kata has been solved not once, but 209 times.

    There is no firstAttacker in C++, and the calls to the function in both test cases above have the same arguments.

    std::string declareWinner(Fighter* fighter1, Fighter* fighter2, std::string firstAttacker)
    {
        // Your code goes here. Have fun!
    }
    

    That is the code stub for the solution of the kata. Notice the firstAttacker (string) parameter.

    std::string actual = declareWinner(&fighter1, &fighter2, "Harry");
    

    declareWinner is the function
    fighter1 and fighter2 are Fighter isntances
    "Harry" is the firstAttacker

    I'm not actually C++ programmer, but I cannot see a mistake in the code, only in your text and understanding of the kata.

  • Custom User Avatar

    No, they are not the same. In the description example, the firstAttacker is "Lew" while in BasicTest2 it is "Harry".

    Who attacks first, in this case, changes the outcome.

    Your work above where you manually solve the problem is wrong. You start with "Lew(10) attacks Harry(5) with 2; Harry has now 3" when Harry attacks first. This changes the outcome.