Ad
  • Default User Avatar

    you can view their solution by clicking on 'View Solution'

  • Default User Avatar

    can you solve it by o(n) please?

  • Default User Avatar

    Hi, i am suppose to return both as equal if they are both under or equal 0 health. They expect me to return a string which i did but the expect me to return it without quotation mark. How do i do that?

    Expected: equal to "Lew"
    Actual: "equal to "Harry""

  • Default User Avatar

    I did not know this (very new to Python) but it makes sense. Thanks for pointing it out.

  • Default User Avatar
  • Custom User Avatar
  • Custom User Avatar

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

  • Custom User Avatar

    python new test framework is required. updated in this fork

  • Custom User Avatar

    Let's do it step by step for the C#'s third test:

    fighter1:  Fighter(Harald, 20, 5)
    fighter2:  Fighter(Harry, 5, 4)
    First attacker:  Harry
    
    Harry attacks Harald for 4 hp
    Harald's health: 20 => 16
    
    Harald attacks Harry for 5 hp
    Harry's health: 5 => 0
    
    Harald wins!
    

    Clearly Harald wins in the third testcase and the expected solution is correct.

    Whereas your solution did something like below:

    fighter1:  Fighter(Harald, 20, 5)
    fighter2:  Fighter(Harry, 5, 4)
    First attacker:  Harry
    
    Harry attacks Harald for 4 hp; while Harald attacks Harry for 5 hp
    Harald's health: 20 => 16; Harry's health: 5 => 0
    
    Harry attacks Harald for 4 hp; while Harald attacks Harry for 5 hp
    Harald's health: 16 => 12; Harry's health: 0 => -5
    
    Harry attacks Harald for 4 hp; while Harald attacks Harry for 5 hp
    Harald's health: 12 => 8; Harry's health: -5 => -10
    
    Harry attacks Harald for 4 hp; while Harald attacks Harry for 5 hp
    Harald's health: 8 => 4; Harry's health: -10 => -15
    
    Harry attacks Harald for 4 hp; while Harald attacks Harry for 5 hp
    Harald's health: 4 => 0; Harry's health: -15 => -20
    
    Harry wins!
    

    There is actually problems in your code's logic, so I'll go ahead and mark this as resolved.

    Best of luck in debugging your code & solving this!

  • Custom User Avatar

    I am getting an error in the third test, the code returns "harald" while the test claims it returns "harry". I tested it with the IDE, I don't have any problems.

        if (firstAttacker == fighter1.Name)
            {
                while (fighter1.Health > 0 || fighter2.Health > 0)
                {
                    fighter2.Health -= fighter1.DamagePerAttack;
                    fighter1.Health -= fighter2.DamagePerAttack;
    
                    if (fighter2.Health <= 0) return fighter1.Name;
                }
            }
            else
            {
                while (fighter1.Health > 0 || fighter2.Health > 0)
                {
                    fighter1.Health -= fighter2.DamagePerAttack;
                    fighter2.Health -= fighter1.DamagePerAttack;
    
                    if (fighter1.Health <= 0) return fighter2.Name;
                }
            }
            return "";
    
  • Default User Avatar
  • 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 was looking for this method haha! Thanks :)

  • Loading more items...