F
F
fenixF22016-03-29 19:13:46
C++ / C#
fenixF2, 2016-03-29 19:13:46

Codewars Tests pass, but not when submitting, what's the problem?

I write code

using System;
using System.Text.RegularExpressions;
public class Kata
{
  public static string GoodVsEvil(string good, string evil)
  {
    string shap = @"\s";
    string[] _good = (new Regex(shap)).Split(good);
    string[] _evil = (new Regex(shap)).Split(evil);

    int power_good = 0;
    foreach (string s in _good)
    {
      power_good += Convert.ToInt32(s);
    }

    int power_evil = 0;
    foreach (string s in _evil)
    {
      power_evil += System.Convert.ToInt32(s);
    }

    if (power_good > power_evil)
    { return "Battle Result: Good triumphs over Evil"; }
    else
      if (power_good < power_evil)
    { return "Battle Result: Evil eradicates all trace of Good"; }

    return "Battle Result: No victor on this battle field";
  }
}

Test code
using System;
using NUnit.Framework;

[TestFixture]
public class GoodVsEvil
{
  [Test]
  public static void EvilShouldWin()
  {
    Assert.AreEqual("Battle Result: Evil eradicates all trace of Good", Kata.GoodVsEvil("1 1 1 1 1 1", "1 1 1 1 1 1 1"));
  }
  
  [Test]
  public static void GoodShouldTriumph()
  {
    Assert.AreEqual("Battle Result: Good triumphs over Evil", Kata.GoodVsEvil("0 0 0 0 0 10", "0 1 1 1 1 0 0"));
  }
  
  [Test]
  public static void ShouldBeATie()
  {
    Assert.AreEqual("Battle Result: No victor on this battle field", Kata.GoodVsEvil("1 0 0 0 0 0", "1 0 0 0 0 0 0"));
  }
}

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
Artem Vereschaka, 2016-03-30
@fenixF2

These are the tests available to you.
Still, it seems like, there is an additional set of tests that are not visible to you.
See logs. there is often a hint to the test.

F
fenixF2, 2016-03-30
@fenixF2

Apparently there were problems on the server, and therefore did not pass

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question