Ad
  • Custom User Avatar

    python new test framework is required. updated in this fork

  • Custom User Avatar

    JS:

    • mocha + chai framework should be used

    • perhaps also assert.deepEqual instead of wasting CPU computation for individual assertions. Imagine if this were a Unit Testing for banking system software, it would have caused havoc upon release to the public...

  • Custom User Avatar

    Description is a total cluster F***, everything should be generalized and made language-agnostic

  • Custom User Avatar

    python new test framework is required. updated in this fork

  • Custom User Avatar

    I'm having trouble completing this KATA in Clojure. The description says a third argument will be passed with the name of the first attacker, but the argument is not present.

    I assumed Fighter 1 will aways attack first, but several random tests fail. The same happens if I default Fighter 2 to attack first.

  • Custom User Avatar

    C#: method name should be PascalCase (Please refer to implementation of backward compatibility here )

  • Custom User Avatar

    Sorry... but in C++ the kata has to be redesigned, as is it is a sound example of BAD C translation to C++
    I don't raise an issue but...

    Codewars is a learning platform

    a) use std::unique_ptr if you want to use pointers..
    b) but could be better to use refs (Fighter &fighter1) in the call to 'declare_winner' . This would allow to use exactely the kind of prototype stated in the details:

    declare_winner(Fighter("Lew", 10, 2), Fighter("Harry", 5, 4), "Lew")
    

    instead of using naked pointers..
    c) all pseudo "hidden" parms of Fighter class have setters and getters which is (generally) a bad practice in C++.
    d) setHealth() ? should be transformed in "receiveDamage()" returning bool (true) if the fighter is still alive.

  • Default User Avatar

    sorry if this question is dumb but ive been trying to search for what the 'this.variable' in the object does/ means. in this case its this.name, this.health ect.. but im having a hard time finding an answer i understand well. can anyone explain it at all?

  • Custom User Avatar

    ( JS, possibly others )

    Not returning a value is not tested.

  • Custom User Avatar

    COBOL translation (author is inactive).

  • Custom User Avatar

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

  • Default User Avatar

    Newbie questions: If I want to understand how to solve a kata like that. What topics should I know about or study? Thanks

  • Custom User Avatar

    my code is failing due to two or three of the random tests under the attempt portion, both fighters will start out with negative health. Not sure how to proceed and i really want to finish this one.

    in JS

    function declareWinner(fighter1, fighter2, firstAttacker) {
    let hitC1 = 0;

    function whoWon(){
    if(fighter1.health > 0){
    return fighter1.name;
    }
    else {
    return fighter2.name;
    }
    }

    function secondRound(){
    if(fighter1.health > 0 && fighter2.health > 0){
    do {
    if(hitC1 > 0){
    fighter1.health = fighter1.health - fighter2.damagePerAttack;
    fighter2.health = fighter2.health - fighter1.damagePerAttack;
    }
    else {
    fighter2.health = fighter2.health - fighter1.damagePerAttack;
    fighter1.health = fighter1.health - fighter2.damagePerAttack;
    }
    }
    while (fighter1.health > 0 && fighter2.health > 0)
    }
    else{
    whoWon();
    }
    }
    /below decides first attack/
    function fightOn(){
    do {
    if (firstAttacker === fighter1.name){
    fighter2.health = fighter2.health - fighter1.damagePerAttack;
    hitC1++;
    secondRound();
    break;
    }
    else if(firstAttacker === fighter2.name){
    fighter1.health = fighter1.health - fighter2.damagePerAttack;
    secondRound();
    break;
    }
    }
    while(fighter1.health > 0 && fighter2.health > 0)
    }
    /below returns outcome of fight/
    fightOn();
    return whoWon();
    }

  • Default User Avatar

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

  • Custom User Avatar

    Ruby 3.0 should be enabled.

  • Loading more items...