Earn extra honor and gain new allies!
Honor is earned for each new codewarrior who joins.
Learn more
  • Sorry that it was broken, I do these during my spare time at work so didn't see the replies, I do believe it was solved right?

  • I thought we weren't allowed to use loops?

  • @ FArekkusu
    Your link is to MSTest, using Microsoft.VisualStudio.TestTools.UnitTesting.

    C# on Codewars is using NUnit. The syntax is often similar (and is the same in this case).

    Last I checked NUnit was still more popular, even though MSFT has included MSTest in Visual Studio since 2015.

  • @steffan153 - looks like your edit beat mine by 14 minutes. I used a variable for the tolerence, and my diff only includes the lines I changed.
    This is my first Kata Edit, so I am not sure how revisions are resolved.

  • How should i fix this?

    Do the same as you do in Python?

  • @Lozu @GalGurGurevich @KrenVsem @dlcoe: I added a 1e-8 error margin, please try again.

  • I don't consider this a spoiler, but mods can mark it if they really feel like it:

    (infected * 100 / total) = 83.333333333333329d
    (infected / total) * 100 = 83.333333333333343d

    Only one of those could be the exact match to the original solution.

    In general, it would be best to ask the programmer to round to a specific number of digits, then you can check for exact answers.
    At this point, you do not want to invalidate any solutions.

    One way to fix the problem is allow for a margin of error (perhaps after 10 decimal places) in the solution.
    Then in the description you might want to include

    "Solutions are checked for accuracy to 10 decimal places"

    Assert.AreEqual has a third parameter that was not being used: Assert.AreEqual(double expected, double actual, double tolerance);
    I added a tolerence to the tests in C#. Please try it again now.

  • Off by one error. I was confused by the wording in the error message, fixed it now, thanks

  • ❗❗ The first and the last continent are NOT connected!



    Passed all initial tests, but on random tests I get geht following problem:

    World given:

    80.76923076923077 should be close to 57.69230769230769 with absolute or relative margin of 1e-09

    Lets do a dry run:
    1X00X0X0000X000000000000000000000100X000X010X10X000000000000 will be:

    0000000000001X00X0X0000X000000000000000000000100X000X010X10X since first an last continent are connected.

    Replacing all 0s which are on the same "continent" with 1s yields:

    Counting 42 "infected"(1s) within a total polulation of 52 being around 82%.

    What did I miss?

  • How should i fix this?

  • I have the same problem in C#.
    But if I use decimal, I see next result:

    Expected: 33.333333333333329d
    But was: 33.3333333333333333333333333333337m

    And I have no idea, how to find solution for this problem.

  • Loading more items...